Re: [PATCH v2 48/54] fs: remove some spurious I_FREEING references in inode.c
From: Christian Brauner <brauner@kernel.org>
Date: 2025-08-28 12:40:29
Also in:
linux-btrfs, linux-fsdevel, linux-xfs
On Tue, Aug 26, 2025 at 11:39:48AM -0400, Josef Bacik wrote:
quoted hunk ↗ jump to hunk
Now that we have the i_count reference count rules set so that we only go into these evict paths with a 0 count, update the sanity checks to check that instead of I_FREEING. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/inode.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)diff --git a/fs/inode.c b/fs/inode.c index eb74f7b5e967..da38c9fbb9a7 100644 --- a/fs/inode.c +++ b/fs/inode.c@@ -858,7 +858,7 @@ void clear_inode(struct inode *inode) */ xa_unlock_irq(&inode->i_data.i_pages); BUG_ON(!list_empty(&inode->i_data.i_private_list)); - BUG_ON(!(inode->i_state & I_FREEING)); + BUG_ON(icount_read(inode) != 0); BUG_ON(inode->i_state & I_CLEAR); BUG_ON(!list_empty(&inode->i_wb_list));
These should probably all be WARN_ON()s.
quoted hunk ↗ jump to hunk
/* don't need i_lock here, no concurrent mods to i_state */@@ -871,19 +871,19 @@ EXPORT_SYMBOL(clear_inode); * to. We remove any pages still attached to the inode and wait for any IO that * is still in progress before finally destroying the inode. * - * An inode must already be marked I_FREEING so that we avoid the inode being + * An inode must already have an i_count of 0 so that we avoid the inode being * moved back onto lists if we race with other code that manipulates the lists * (e.g. writeback_single_inode). The caller is responsible for setting this. * * An inode must already be removed from the LRU list before being evicted from - * the cache. This should occur atomically with setting the I_FREEING state - * flag, so no inodes here should ever be on the LRU when being evicted. + * the cache. This should always be the case as the LRU list holds an i_count + * reference on the inode, and we only evict inodes with an i_count of 0. */ static void evict(struct inode *inode) { const struct super_operations *op = inode->i_sb->s_op; - BUG_ON(!(inode->i_state & I_FREEING)); + BUG_ON(icount_read(inode) != 0); BUG_ON(!list_empty(&inode->i_lru)); if (!list_empty(&inode->i_io_list))@@ -897,8 +897,8 @@ static void evict(struct inode *inode) /* * Wait for flusher thread to be done with the inode so that filesystem * does not start destroying it while writeback is still running. Since - * the inode has I_FREEING set, flusher thread won't start new work on - * the inode. We just have to wait for running writeback to finish. + * the inode has a 0 i_count, flusher thread won't start new work on the + * inode. We just have to wait for running writeback to finish. */ inode_wait_for_writeback(inode); spin_unlock(&inode->i_lock);-- 2.49.0