]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ext4: support uncached buffered I/O
authorTaotao Chen <chentaotao@didiglobal.com>
Wed, 16 Jul 2025 09:36:09 +0000 (09:36 +0000)
committerChristian Brauner <brauner@kernel.org>
Wed, 16 Jul 2025 12:48:18 +0000 (14:48 +0200)
Set FOP_DONTCACHE in ext4_file_operations to declare support for
uncached buffered I/O.

To handle this flag, update ext4_write_begin() and ext4_da_write_begin()
to use write_begin_get_folio(), which encapsulates FGP_DONTCACHE logic
based on iocb->ki_flags.

Part of a series refactoring address_space_operations write_begin and
write_end callbacks to use struct kiocb for passing write context and
flags.

Signed-off-by: Taotao Chen <chentaotao@didiglobal.com>
Link: https://lore.kernel.org/20250716093559.217344-6-chentaotao@didiglobal.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/ext4/file.c
fs/ext4/inode.c

index 21df81347147cc7ab3648590b6dbd40e31e2c20b..274b41a476c8fc653bb19eafe6923bbc6ddd52c7 100644 (file)
@@ -977,7 +977,8 @@ const struct file_operations ext4_file_operations = {
        .splice_write   = iter_file_splice_write,
        .fallocate      = ext4_fallocate,
        .fop_flags      = FOP_MMAP_SYNC | FOP_BUFFER_RASYNC |
-                         FOP_DIO_PARALLEL_WRITE,
+                         FOP_DIO_PARALLEL_WRITE |
+                         FOP_DONTCACHE,
 };
 
 const struct inode_operations ext4_file_inode_operations = {
index 9a16efd072bb8608d45e02f6b00c0de39c38483a..5c7024051f1edb3ad52904234793b717858298c2 100644 (file)
@@ -1264,7 +1264,6 @@ static int ext4_write_begin(const struct kiocb *iocb,
        struct folio *folio;
        pgoff_t index;
        unsigned from, to;
-       fgf_t fgp = FGP_WRITEBEGIN;
 
        ret = ext4_emergency_state(inode->i_sb);
        if (unlikely(ret))
@@ -1288,16 +1287,14 @@ static int ext4_write_begin(const struct kiocb *iocb,
        }
 
        /*
-        * __filemap_get_folio() can take a long time if the
+        * write_begin_get_folio() can take a long time if the
         * system is thrashing due to memory pressure, or if the folio
         * is being written back.  So grab it first before we start
         * the transaction handle.  This also allows us to allocate
         * the folio (if needed) without using GFP_NOFS.
         */
 retry_grab:
-       fgp |= fgf_set_order(len);
-       folio = __filemap_get_folio(mapping, index, fgp,
-                                   mapping_gfp_mask(mapping));
+       folio = write_begin_get_folio(iocb, mapping, index, len);
        if (IS_ERR(folio))
                return PTR_ERR(folio);
 
@@ -3046,7 +3043,6 @@ static int ext4_da_write_begin(const struct kiocb *iocb,
        struct folio *folio;
        pgoff_t index;
        struct inode *inode = mapping->host;
-       fgf_t fgp = FGP_WRITEBEGIN;
 
        ret = ext4_emergency_state(inode->i_sb);
        if (unlikely(ret))
@@ -3072,9 +3068,7 @@ static int ext4_da_write_begin(const struct kiocb *iocb,
        }
 
 retry:
-       fgp |= fgf_set_order(len);
-       folio = __filemap_get_folio(mapping, index, fgp,
-                                   mapping_gfp_mask(mapping));
+       folio = write_begin_get_folio(iocb, mapping, index, len);
        if (IS_ERR(folio))
                return PTR_ERR(folio);