mirror of
https://github.com/torvalds/linux.git
synced 2026-06-05 13:06:59 +02:00
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>
This commit is contained in:
parent
6ea3b34d86
commit
5447c8b9de
|
|
@ -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 @@ static int __ext4_block_zero_page_range(handle_t *handle,
|
|||
* 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user