]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ext4: add did_zero output parameter to ext4_block_zero_page_range()
authorZhang Yi <yi.zhang@huawei.com>
Fri, 27 Mar 2026 10:29:27 +0000 (18:29 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 10 Apr 2026 01:57:51 +0000 (21:57 -0400)
Add a bool *did_zero output parameter to ext4_block_zero_page_range()
and __ext4_block_zero_page_range(). The parameter reports whether a
partial block was zeroed out, which is needed for the upcoming iomap
buffered I/O conversion.

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20260327102939.1095257-2-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/inode.c

index 13cd564f89e1fb2377826447a40992b6ee5019ef..f0c9c63f618b8c28d4f939cb6fcb7fceb9b64422 100644 (file)
@@ -4033,7 +4033,8 @@ void ext4_set_aops(struct inode *inode)
  * racing writeback can come later and flush the stale pagecache to disk.
  */
 static int __ext4_block_zero_page_range(handle_t *handle,
-               struct address_space *mapping, loff_t from, loff_t length)
+               struct address_space *mapping, loff_t from, loff_t length,
+               bool *did_zero)
 {
        unsigned int offset, blocksize, pos;
        ext4_lblk_t iblock;
@@ -4121,6 +4122,8 @@ static int __ext4_block_zero_page_range(handle_t *handle,
                        err = ext4_jbd2_inode_add_write(handle, inode, from,
                                        length);
        }
+       if (!err && did_zero)
+               *did_zero = true;
 
 unlock:
        folio_unlock(folio);
@@ -4136,7 +4139,8 @@ unlock:
  * that corresponds to 'from'
  */
 static int ext4_block_zero_page_range(handle_t *handle,
-               struct address_space *mapping, loff_t from, loff_t length)
+               struct address_space *mapping, loff_t from, loff_t length,
+               bool *did_zero)
 {
        struct inode *inode = mapping->host;
        unsigned blocksize = inode->i_sb->s_blocksize;
@@ -4150,10 +4154,11 @@ static int ext4_block_zero_page_range(handle_t *handle,
                length = max;
 
        if (IS_DAX(inode)) {
-               return dax_zero_range(inode, from, length, NULL,
+               return dax_zero_range(inode, from, length, did_zero,
                                      &ext4_iomap_ops);
        }
-       return __ext4_block_zero_page_range(handle, mapping, from, length);
+       return __ext4_block_zero_page_range(handle, mapping, from, length,
+                                           did_zero);
 }
 
 /*
@@ -4176,7 +4181,7 @@ static int ext4_block_truncate_page(handle_t *handle,
        blocksize = i_blocksize(inode);
        length = blocksize - (from & (blocksize - 1));
 
-       return ext4_block_zero_page_range(handle, mapping, from, length);
+       return ext4_block_zero_page_range(handle, mapping, from, length, NULL);
 }
 
 int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode,
@@ -4199,13 +4204,13 @@ int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode,
        if (start == end &&
            (partial_start || (partial_end != sb->s_blocksize - 1))) {
                err = ext4_block_zero_page_range(handle, mapping,
-                                                lstart, length);
+                                                lstart, length, NULL);
                return err;
        }
        /* Handle partial zero out on the start of the range */
        if (partial_start) {
-               err = ext4_block_zero_page_range(handle, mapping,
-                                                lstart, sb->s_blocksize);
+               err = ext4_block_zero_page_range(handle, mapping, lstart,
+                                                sb->s_blocksize, NULL);
                if (err)
                        return err;
        }
@@ -4213,7 +4218,7 @@ int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode,
        if (partial_end != sb->s_blocksize - 1)
                err = ext4_block_zero_page_range(handle, mapping,
                                                 byte_end - partial_end,
-                                                partial_end + 1);
+                                                partial_end + 1, NULL);
        return err;
 }