[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250825-seicht-anfassen-6c0235f32224@brauner>
Date: Mon, 25 Aug 2025 13:26:00 +0200
From: Christian Brauner <brauner@...nel.org>
To: Josef Bacik <josef@...icpanda.com>
Cc: linux-fsdevel@...r.kernel.org, linux-btrfs@...r.kernel.org,
kernel-team@...com, linux-ext4@...r.kernel.org, linux-xfs@...r.kernel.org,
viro@...iv.linux.org.uk
Subject: Re: [PATCH 22/50] fs: use inode_tryget in find_inode*
On Thu, Aug 21, 2025 at 04:18:33PM -0400, Josef Bacik wrote:
> Now that we never drop the i_count to 0 for valid objects, rework the
> logic in the find_inode* helpers to use inode_tryget() to see if they
> have a live inode. If this fails we can wait for the inode to be freed
> as we know it's currently being evicted.
>
> Signed-off-by: Josef Bacik <josef@...icpanda.com>
> ---
> fs/inode.c | 19 +++++++++----------
> 1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/fs/inode.c b/fs/inode.c
> index b9122c1eee1d..893ac902268b 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -1109,6 +1109,7 @@ long prune_icache_sb(struct super_block *sb, struct shrink_control *sc)
> }
>
> static void __wait_on_freeing_inode(struct inode *inode, bool is_inode_hash_locked);
> +
> /*
> * Called with the inode lock held.
> */
> @@ -1132,16 +1133,15 @@ static struct inode *find_inode(struct super_block *sb,
> if (!test(inode, data))
> continue;
> spin_lock(&inode->i_lock);
> - if (inode->i_state & (I_FREEING|I_WILL_FREE)) {
> - __wait_on_freeing_inode(inode, is_inode_hash_locked);
> - goto repeat;
> - }
> if (unlikely(inode->i_state & I_CREATING)) {
> spin_unlock(&inode->i_lock);
> rcu_read_unlock();
> return ERR_PTR(-ESTALE);
> }
> - __iget(inode);
> + if (!inode_tryget(inode)) {
> + __wait_on_freeing_inode(inode, is_inode_hash_locked);
> + goto repeat;
> + }
> inode_lru_list_del(inode);
> spin_unlock(&inode->i_lock);
> rcu_read_unlock();
> @@ -1174,16 +1174,15 @@ static struct inode *find_inode_fast(struct super_block *sb,
> if (inode->i_sb != sb)
> continue;
> spin_lock(&inode->i_lock);
> - if (inode->i_state & (I_FREEING|I_WILL_FREE)) {
Oh yes, this is such a beautiful change...
> - __wait_on_freeing_inode(inode, is_inode_hash_locked);
> - goto repeat;
> - }
> if (unlikely(inode->i_state & I_CREATING)) {
> spin_unlock(&inode->i_lock);
> rcu_read_unlock();
> return ERR_PTR(-ESTALE);
> }
> - __iget(inode);
> + if (!inode_tryget(inode)) {
> + __wait_on_freeing_inode(inode, is_inode_hash_locked);
> + goto repeat;
> + }
> inode_lru_list_del(inode);
> spin_unlock(&inode->i_lock);
> rcu_read_unlock();
> --
> 2.49.0
>
Powered by blists - more mailing lists