[PATCH v2 0/5] fs: refactor write_begin/write_end and add ext4 IOCB_DONTCACHE support

陈涛涛 Taotao Chen posted 5 patches 3 months, 2 weeks ago
There is a newer version of this series
Documentation/filesystems/locking.rst     |   4 +-
Documentation/filesystems/vfs.rst         |   4 +-
block/fops.c                              |   6 +-
drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 112 ++++++----------------
fs/adfs/inode.c                           |   4 +-
fs/affs/file.c                            |  12 +--
fs/bcachefs/fs-io-buffered.c              |   4 +-
fs/bcachefs/fs-io-buffered.h              |   4 +-
fs/bfs/file.c                             |   2 +-
fs/buffer.c                               |  18 ++--
fs/ceph/addr.c                            |   6 +-
fs/ecryptfs/mmap.c                        |  10 +-
fs/exfat/file.c                           |  14 ++-
fs/exfat/inode.c                          |   6 +-
fs/ext2/inode.c                           |   6 +-
fs/ext4/file.c                            |   3 +-
fs/ext4/inode.c                           |  25 ++---
fs/f2fs/data.c                            |   4 +-
fs/fat/inode.c                            |   8 +-
fs/fuse/file.c                            |   5 +-
fs/hfs/hfs_fs.h                           |   2 +-
fs/hfs/inode.c                            |   4 +-
fs/hfsplus/hfsplus_fs.h                   |   2 +-
fs/hfsplus/inode.c                        |   4 +-
fs/hostfs/hostfs_kern.c                   |   6 +-
fs/hpfs/file.c                            |   8 +-
fs/hugetlbfs/inode.c                      |   4 +-
fs/jffs2/file.c                           |   8 +-
fs/jfs/inode.c                            |   6 +-
fs/libfs.c                                |   4 +-
fs/minix/inode.c                          |   2 +-
fs/nfs/file.c                             |   6 +-
fs/nilfs2/inode.c                         |   6 +-
fs/ntfs3/file.c                           |   7 +-
fs/ntfs3/inode.c                          |   6 +-
fs/ntfs3/ntfs_fs.h                        |   4 +-
fs/ocfs2/aops.c                           |   4 +-
fs/omfs/file.c                            |   2 +-
fs/orangefs/inode.c                       |   6 +-
fs/ubifs/file.c                           |   4 +-
fs/udf/inode.c                            |   9 +-
fs/ufs/inode.c                            |   6 +-
fs/vboxsf/file.c                          |   4 +-
include/linux/buffer_head.h               |   4 +-
include/linux/fs.h                        |   6 +-
mm/filemap.c                              |   4 +-
mm/shmem.c                                |   4 +-
47 files changed, 176 insertions(+), 213 deletions(-)
[PATCH v2 0/5] fs: refactor write_begin/write_end and add ext4 IOCB_DONTCACHE support
Posted by 陈涛涛 Taotao Chen 3 months, 2 weeks ago
From: Taotao Chen <chentaotao@didiglobal.com>

This patch series refactors the address_space_operations write_begin()
and write_end() callbacks to take struct kiocb * as their first argument,
allowing IOCB flags such as IOCB_DONTCACHE to propagate to filesystem’s
buffered write path.

Ext4 is updated to implement handling of the IOCB_DONTCACHE flag in its
buffered write path and to advertise support via the FOP_DONTCACHE file
operation flag.

Additionally, the i915 driver’s shmem write paths are updated to bypass
the legacy write_begin/write_end interface in favor of directly calling
write_iter(), using a constructed synchronous kiocb. Another i915 patch
replaces a manual write loop with kernel_write() in shmem object creation.

Tested with ext4 and i915 GEM workloads.

Changes since v1:
- ext4 uses kiocb->ki_flags directly instead of fsdata.
- write_begin/write_end interface is changed to take struct kiocb *
  instead of struct file *.
- i915 shmem_pwrite refactored to use write_iter() directly instead
  of write_begin/write_end.
- i915 GEM shmem object creation replaced manual write loop with
  kernel_write().

Taotao Chen (5):
  drm/i915: Use kernel_write() in shmem object create
  drm/i915: Refactor shmem_pwrite() to use kiocb and write_iter
  fs: change write_begin/write_end interface to take struct kiocb *
  ext4: handle IOCB_DONTCACHE in buffered write path
  ext4: declare support for FOP_DONTCACHE

 Documentation/filesystems/locking.rst     |   4 +-
 Documentation/filesystems/vfs.rst         |   4 +-
 block/fops.c                              |   6 +-
 drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 112 ++++++----------------
 fs/adfs/inode.c                           |   4 +-
 fs/affs/file.c                            |  12 +--
 fs/bcachefs/fs-io-buffered.c              |   4 +-
 fs/bcachefs/fs-io-buffered.h              |   4 +-
 fs/bfs/file.c                             |   2 +-
 fs/buffer.c                               |  18 ++--
 fs/ceph/addr.c                            |   6 +-
 fs/ecryptfs/mmap.c                        |  10 +-
 fs/exfat/file.c                           |  14 ++-
 fs/exfat/inode.c                          |   6 +-
 fs/ext2/inode.c                           |   6 +-
 fs/ext4/file.c                            |   3 +-
 fs/ext4/inode.c                           |  25 ++---
 fs/f2fs/data.c                            |   4 +-
 fs/fat/inode.c                            |   8 +-
 fs/fuse/file.c                            |   5 +-
 fs/hfs/hfs_fs.h                           |   2 +-
 fs/hfs/inode.c                            |   4 +-
 fs/hfsplus/hfsplus_fs.h                   |   2 +-
 fs/hfsplus/inode.c                        |   4 +-
 fs/hostfs/hostfs_kern.c                   |   6 +-
 fs/hpfs/file.c                            |   8 +-
 fs/hugetlbfs/inode.c                      |   4 +-
 fs/jffs2/file.c                           |   8 +-
 fs/jfs/inode.c                            |   6 +-
 fs/libfs.c                                |   4 +-
 fs/minix/inode.c                          |   2 +-
 fs/nfs/file.c                             |   6 +-
 fs/nilfs2/inode.c                         |   6 +-
 fs/ntfs3/file.c                           |   7 +-
 fs/ntfs3/inode.c                          |   6 +-
 fs/ntfs3/ntfs_fs.h                        |   4 +-
 fs/ocfs2/aops.c                           |   4 +-
 fs/omfs/file.c                            |   2 +-
 fs/orangefs/inode.c                       |   6 +-
 fs/ubifs/file.c                           |   4 +-
 fs/udf/inode.c                            |   9 +-
 fs/ufs/inode.c                            |   6 +-
 fs/vboxsf/file.c                          |   4 +-
 include/linux/buffer_head.h               |   4 +-
 include/linux/fs.h                        |   6 +-
 mm/filemap.c                              |   4 +-
 mm/shmem.c                                |   4 +-
 47 files changed, 176 insertions(+), 213 deletions(-)

-- 
2.34.1
Re: [PATCH v2 0/5] fs: refactor write_begin/write_end and add ext4 IOCB_DONTCACHE support
Posted by Matthew Wilcox 3 months, 2 weeks ago
On Tue, Jun 24, 2025 at 12:11:59PM +0000, 陈涛涛 Taotao Chen wrote:
> From: Taotao Chen <chentaotao@didiglobal.com>
> 
> This patch series refactors the address_space_operations write_begin()
> and write_end() callbacks to take struct kiocb * as their first argument,
> allowing IOCB flags such as IOCB_DONTCACHE to propagate to filesystem’s
> buffered write path.
> 
> Ext4 is updated to implement handling of the IOCB_DONTCACHE flag in its
> buffered write path and to advertise support via the FOP_DONTCACHE file
> operation flag.
> 
> Additionally, the i915 driver’s shmem write paths are updated to bypass
> the legacy write_begin/write_end interface in favor of directly calling
> write_iter(), using a constructed synchronous kiocb. Another i915 patch
> replaces a manual write loop with kernel_write() in shmem object creation.

Thanks, this is a really good cleanup.
Re: [PATCH v2 0/5] fs: refactor write_begin/write_end and add ext4 IOCB_DONTCACHE support
Posted by hch@infradead.org 3 months, 2 weeks ago
Thanks, I really like the i915 work to stop the shmem abuse.

I still hate it that we just change the write_begin/end ops while still
in the address_space ops vs passing explicit callbacks, because that
means we'll some other version of that abuse back sooner or later :(