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.

vfs: drop one lock trip in evict()

Most commonly neither I_LRU_ISOLATING nor I_SYNC are set, but the stock
kernel takes a back-to-back relock trip to check for them.

It probably can be avoided altogether, but for now massage things back
to just one lock acquire.

Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Link: https://lore.kernel.org/r/20240813143626.1573445-1-mjguzik@gmail.com
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Mateusz Guzik and committed by
Christian Brauner
57510c58 3a987b88

+6 -16
+3 -14
fs/fs-writeback.c
··· 1510 1510 * Wait for writeback on an inode to complete. Called with i_lock held. 1511 1511 * Caller must make sure inode cannot go away when we drop i_lock. 1512 1512 */ 1513 - static void __inode_wait_for_writeback(struct inode *inode) 1514 - __releases(inode->i_lock) 1515 - __acquires(inode->i_lock) 1513 + void inode_wait_for_writeback(struct inode *inode) 1516 1514 { 1517 1515 DEFINE_WAIT_BIT(wq, &inode->i_state, __I_SYNC); 1518 1516 wait_queue_head_t *wqh; 1519 1517 1518 + lockdep_assert_held(&inode->i_lock); 1520 1519 wqh = bit_waitqueue(&inode->i_state, __I_SYNC); 1521 1520 while (inode->i_state & I_SYNC) { 1522 1521 spin_unlock(&inode->i_lock); ··· 1523 1524 TASK_UNINTERRUPTIBLE); 1524 1525 spin_lock(&inode->i_lock); 1525 1526 } 1526 - } 1527 - 1528 - /* 1529 - * Wait for writeback on an inode to complete. Caller must have inode pinned. 1530 - */ 1531 - void inode_wait_for_writeback(struct inode *inode) 1532 - { 1533 - spin_lock(&inode->i_lock); 1534 - __inode_wait_for_writeback(inode); 1535 - spin_unlock(&inode->i_lock); 1536 1527 } 1537 1528 1538 1529 /* ··· 1746 1757 */ 1747 1758 if (wbc->sync_mode != WB_SYNC_ALL) 1748 1759 goto out; 1749 - __inode_wait_for_writeback(inode); 1760 + inode_wait_for_writeback(inode); 1750 1761 } 1751 1762 WARN_ON(inode->i_state & I_SYNC); 1752 1763 /*
+3 -2
fs/inode.c
··· 507 507 508 508 static void inode_wait_for_lru_isolating(struct inode *inode) 509 509 { 510 - spin_lock(&inode->i_lock); 510 + lockdep_assert_held(&inode->i_lock); 511 511 if (inode->i_state & I_LRU_ISOLATING) { 512 512 DEFINE_WAIT_BIT(wq, &inode->i_state, __I_LRU_ISOLATING); 513 513 wait_queue_head_t *wqh; ··· 518 518 spin_lock(&inode->i_lock); 519 519 WARN_ON(inode->i_state & I_LRU_ISOLATING); 520 520 } 521 - spin_unlock(&inode->i_lock); 522 521 } 523 522 524 523 /** ··· 689 690 690 691 inode_sb_list_del(inode); 691 692 693 + spin_lock(&inode->i_lock); 692 694 inode_wait_for_lru_isolating(inode); 693 695 694 696 /* ··· 699 699 * the inode. We just have to wait for running writeback to finish. 700 700 */ 701 701 inode_wait_for_writeback(inode); 702 + spin_unlock(&inode->i_lock); 702 703 703 704 if (op->evict_inode) { 704 705 op->evict_inode(inode);