Skip to content

Commit 5447c8b

Browse files
zhangyi089tytso
authored andcommitted
ext4: add did_zero output parameter to ext4_block_zero_page_range()
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>
1 parent 6ea3b34 commit 5447c8b

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

fs/ext4/inode.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4033,7 +4033,8 @@ void ext4_set_aops(struct inode *inode)
40334033
* racing writeback can come later and flush the stale pagecache to disk.
40344034
*/
40354035
static int __ext4_block_zero_page_range(handle_t *handle,
4036-
struct address_space *mapping, loff_t from, loff_t length)
4036+
struct address_space *mapping, loff_t from, loff_t length,
4037+
bool *did_zero)
40374038
{
40384039
unsigned int offset, blocksize, pos;
40394040
ext4_lblk_t iblock;
@@ -4121,6 +4122,8 @@ static int __ext4_block_zero_page_range(handle_t *handle,
41214122
err = ext4_jbd2_inode_add_write(handle, inode, from,
41224123
length);
41234124
}
4125+
if (!err && did_zero)
4126+
*did_zero = true;
41244127

41254128
unlock:
41264129
folio_unlock(folio);
@@ -4136,7 +4139,8 @@ static int __ext4_block_zero_page_range(handle_t *handle,
41364139
* that corresponds to 'from'
41374140
*/
41384141
static int ext4_block_zero_page_range(handle_t *handle,
4139-
struct address_space *mapping, loff_t from, loff_t length)
4142+
struct address_space *mapping, loff_t from, loff_t length,
4143+
bool *did_zero)
41404144
{
41414145
struct inode *inode = mapping->host;
41424146
unsigned blocksize = inode->i_sb->s_blocksize;
@@ -4150,10 +4154,11 @@ static int ext4_block_zero_page_range(handle_t *handle,
41504154
length = max;
41514155

41524156
if (IS_DAX(inode)) {
4153-
return dax_zero_range(inode, from, length, NULL,
4157+
return dax_zero_range(inode, from, length, did_zero,
41544158
&ext4_iomap_ops);
41554159
}
4156-
return __ext4_block_zero_page_range(handle, mapping, from, length);
4160+
return __ext4_block_zero_page_range(handle, mapping, from, length,
4161+
did_zero);
41574162
}
41584163

41594164
/*
@@ -4176,7 +4181,7 @@ static int ext4_block_truncate_page(handle_t *handle,
41764181
blocksize = i_blocksize(inode);
41774182
length = blocksize - (from & (blocksize - 1));
41784183

4179-
return ext4_block_zero_page_range(handle, mapping, from, length);
4184+
return ext4_block_zero_page_range(handle, mapping, from, length, NULL);
41804185
}
41814186

41824187
int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode,
@@ -4199,21 +4204,21 @@ int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode,
41994204
if (start == end &&
42004205
(partial_start || (partial_end != sb->s_blocksize - 1))) {
42014206
err = ext4_block_zero_page_range(handle, mapping,
4202-
lstart, length);
4207+
lstart, length, NULL);
42034208
return err;
42044209
}
42054210
/* Handle partial zero out on the start of the range */
42064211
if (partial_start) {
4207-
err = ext4_block_zero_page_range(handle, mapping,
4208-
lstart, sb->s_blocksize);
4212+
err = ext4_block_zero_page_range(handle, mapping, lstart,
4213+
sb->s_blocksize, NULL);
42094214
if (err)
42104215
return err;
42114216
}
42124217
/* Handle partial zero out on the end of the range */
42134218
if (partial_end != sb->s_blocksize - 1)
42144219
err = ext4_block_zero_page_range(handle, mapping,
42154220
byte_end - partial_end,
4216-
partial_end + 1);
4221+
partial_end + 1, NULL);
42174222
return err;
42184223
}
42194224

0 commit comments

Comments
 (0)