Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Zhang Yi and committed by
Theodore Ts'o
5447c8b9 6ea3b34d

+14 -9
+14 -9
fs/ext4/inode.c
··· 4033 4033 * racing writeback can come later and flush the stale pagecache to disk. 4034 4034 */ 4035 4035 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) 4037 4038 { 4038 4039 unsigned int offset, blocksize, pos; 4039 4040 ext4_lblk_t iblock; ··· 4122 4121 err = ext4_jbd2_inode_add_write(handle, inode, from, 4123 4122 length); 4124 4123 } 4124 + if (!err && did_zero) 4125 + *did_zero = true; 4125 4126 4126 4127 unlock: 4127 4128 folio_unlock(folio); ··· 4139 4136 * that corresponds to 'from' 4140 4137 */ 4141 4138 static int ext4_block_zero_page_range(handle_t *handle, 4142 - struct address_space *mapping, loff_t from, loff_t length) 4139 + struct address_space *mapping, loff_t from, loff_t length, 4140 + bool *did_zero) 4143 4141 { 4144 4142 struct inode *inode = mapping->host; 4145 4143 unsigned blocksize = inode->i_sb->s_blocksize; ··· 4154 4150 length = max; 4155 4151 4156 4152 if (IS_DAX(inode)) { 4157 - return dax_zero_range(inode, from, length, NULL, 4153 + return dax_zero_range(inode, from, length, did_zero, 4158 4154 &ext4_iomap_ops); 4159 4155 } 4160 - return __ext4_block_zero_page_range(handle, mapping, from, length); 4156 + return __ext4_block_zero_page_range(handle, mapping, from, length, 4157 + did_zero); 4161 4158 } 4162 4159 4163 4160 /* ··· 4181 4176 blocksize = i_blocksize(inode); 4182 4177 length = blocksize - (from & (blocksize - 1)); 4183 4178 4184 - return ext4_block_zero_page_range(handle, mapping, from, length); 4179 + return ext4_block_zero_page_range(handle, mapping, from, length, NULL); 4185 4180 } 4186 4181 4187 4182 int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode, ··· 4204 4199 if (start == end && 4205 4200 (partial_start || (partial_end != sb->s_blocksize - 1))) { 4206 4201 err = ext4_block_zero_page_range(handle, mapping, 4207 - lstart, length); 4202 + lstart, length, NULL); 4208 4203 return err; 4209 4204 } 4210 4205 /* Handle partial zero out on the start of the range */ 4211 4206 if (partial_start) { 4212 - err = ext4_block_zero_page_range(handle, mapping, 4213 - lstart, sb->s_blocksize); 4207 + err = ext4_block_zero_page_range(handle, mapping, lstart, 4208 + sb->s_blocksize, NULL); 4214 4209 if (err) 4215 4210 return err; 4216 4211 } ··· 4218 4213 if (partial_end != sb->s_blocksize - 1) 4219 4214 err = ext4_block_zero_page_range(handle, mapping, 4220 4215 byte_end - partial_end, 4221 - partial_end + 1); 4216 + partial_end + 1, NULL); 4222 4217 return err; 4223 4218 } 4224 4219