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

ext4: add ext4_sb_block_valid() refactored out of ext4_inode_block_valid()

This API will be needed at places where we don't have an inode
for e.g. while freeing blocks in ext4_group_add_blocks()

Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
Link: https://lore.kernel.org/r/dd34a236543ad5ae7123eeebe0cb69e6bdd44f34.1644992610.git.riteshh@linux.ibm.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

Ritesh Harjani and committed by
Theodore Ts'o
6bc6c2bd bd8247ee

+20 -9
+17 -9
fs/ext4/block_validity.c
··· 292 292 call_rcu(&system_blks->rcu, ext4_destroy_system_zone); 293 293 } 294 294 295 - /* 296 - * Returns 1 if the passed-in block region (start_blk, 297 - * start_blk+count) is valid; 0 if some part of the block region 298 - * overlaps with some other filesystem metadata blocks. 299 - */ 300 - int ext4_inode_block_valid(struct inode *inode, ext4_fsblk_t start_blk, 301 - unsigned int count) 295 + int ext4_sb_block_valid(struct super_block *sb, struct inode *inode, 296 + ext4_fsblk_t start_blk, unsigned int count) 302 297 { 303 - struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); 298 + struct ext4_sb_info *sbi = EXT4_SB(sb); 304 299 struct ext4_system_blocks *system_blks; 305 300 struct ext4_system_zone *entry; 306 301 struct rb_node *n; ··· 324 329 else if (start_blk >= (entry->start_blk + entry->count)) 325 330 n = n->rb_right; 326 331 else { 327 - ret = (entry->ino == inode->i_ino); 332 + ret = 0; 333 + if (inode) 334 + ret = (entry->ino == inode->i_ino); 328 335 break; 329 336 } 330 337 } 331 338 out_rcu: 332 339 rcu_read_unlock(); 333 340 return ret; 341 + } 342 + 343 + /* 344 + * Returns 1 if the passed-in block region (start_blk, 345 + * start_blk+count) is valid; 0 if some part of the block region 346 + * overlaps with some other filesystem metadata blocks. 347 + */ 348 + int ext4_inode_block_valid(struct inode *inode, ext4_fsblk_t start_blk, 349 + unsigned int count) 350 + { 351 + return ext4_sb_block_valid(inode->i_sb, inode, start_blk, count); 334 352 } 335 353 336 354 int ext4_check_blockref(const char *function, unsigned int line,
+3
fs/ext4/ext4.h
··· 3707 3707 unsigned int count); 3708 3708 extern int ext4_check_blockref(const char *, unsigned int, 3709 3709 struct inode *, __le32 *, unsigned int); 3710 + extern int ext4_sb_block_valid(struct super_block *sb, struct inode *inode, 3711 + ext4_fsblk_t start_blk, unsigned int count); 3712 + 3710 3713 3711 3714 /* extents.c */ 3712 3715 struct ext4_ext_path;