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 ext4_fc_eligible()

Testing EXT4_MF_FC_INELIGIBLE is almost always combined with testing
ext4_fc_disabled(). The code can be simplified by combining these two
in a new ext4_fc_eligible().

In ext4_fc_track_inode() this moves the ext4_fc_disabled() test after
ext4_fc_mark_ineligible(), but as that is a non-op when
ext4_fc_disabled() is true, this is no no consequence.

Note that it is important to still call ext4_fc_mark_ineligible() in
ext4_fc_track_inode() even when ext4_fc_eligible() would return true.
ext4_fc_mark_ineligible() does not ONLY set the "INELIGIBLE" flag but
also updates ->s_fc_ineligible_tid to make sure that the flag remains
set until all ineligible transactions have been committed.

Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: NeilBrown <neil@brown.name>
Link: https://patch.msgid.link/20260320000838.3797494-3-neilb@ownmail.net
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

NeilBrown and committed by
Theodore Ts'o
0f5f14f3 28793746

+14 -29
+14 -29
fs/ext4/fast_commit.c
··· 224 224 (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)); 225 225 } 226 226 227 + static bool ext4_fc_eligible(struct super_block *sb) 228 + { 229 + return !ext4_fc_disabled(sb) && 230 + !(ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE)); 231 + } 232 + 227 233 /* 228 234 * Remove inode from fast commit list. If the inode is being committed 229 235 * we wait until inode commit is done. ··· 479 473 { 480 474 struct inode *inode = d_inode(dentry); 481 475 482 - if (ext4_fc_disabled(inode->i_sb)) 483 - return; 484 - 485 - if (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_INELIGIBLE)) 486 - return; 487 - 488 - __ext4_fc_track_unlink(handle, inode, dentry); 476 + if (ext4_fc_eligible(inode->i_sb)) 477 + __ext4_fc_track_unlink(handle, inode, dentry); 489 478 } 490 479 491 480 void __ext4_fc_track_link(handle_t *handle, ··· 501 500 { 502 501 struct inode *inode = d_inode(dentry); 503 502 504 - if (ext4_fc_disabled(inode->i_sb)) 505 - return; 506 - 507 - if (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_INELIGIBLE)) 508 - return; 509 - 510 - __ext4_fc_track_link(handle, inode, dentry); 503 + if (ext4_fc_eligible(inode->i_sb)) 504 + __ext4_fc_track_link(handle, inode, dentry); 511 505 } 512 506 513 507 void __ext4_fc_track_create(handle_t *handle, struct inode *inode, ··· 523 527 { 524 528 struct inode *inode = d_inode(dentry); 525 529 526 - if (ext4_fc_disabled(inode->i_sb)) 527 - return; 528 - 529 - if (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_INELIGIBLE)) 530 - return; 531 - 532 - __ext4_fc_track_create(handle, inode, dentry); 530 + if (ext4_fc_eligible(inode->i_sb)) 531 + __ext4_fc_track_create(handle, inode, dentry); 533 532 } 534 533 535 534 /* __track_fn for inode tracking */ ··· 548 557 if (S_ISDIR(inode->i_mode)) 549 558 return; 550 559 551 - if (ext4_fc_disabled(inode->i_sb)) 552 - return; 553 - 554 560 if (ext4_should_journal_data(inode)) { 555 561 ext4_fc_mark_ineligible(inode->i_sb, 556 562 EXT4_FC_REASON_INODE_JOURNAL_DATA, handle); 557 563 return; 558 564 } 559 565 560 - if (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_INELIGIBLE)) 566 + if (!ext4_fc_eligible(inode->i_sb)) 561 567 return; 562 568 563 569 /* ··· 632 644 if (S_ISDIR(inode->i_mode)) 633 645 return; 634 646 635 - if (ext4_fc_disabled(inode->i_sb)) 636 - return; 637 - 638 - if (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_INELIGIBLE)) 647 + if (!ext4_fc_eligible(inode->i_sb)) 639 648 return; 640 649 641 650 if (ext4_has_inline_data(inode)) {