mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Huang Shijie <huangsj@hygon.cn>
To: Jan Kara <jack@suse.cz>
Cc: <axboe@kernel.dk>, <viro@zeniv.linux.org.uk>,
	<brauner@kernel.org>, <zhongyuan@hygon.cn>,
	<fangbaoshun@hygon.cn>, <yingzhiwei@hygon.cn>,
	<agruenba@redhat.com>, <mic@digikod.net>, <gnoack@google.com>,
	<paul@paul-moore.com>, <jmorris@namei.org>, <serge@hallyn.com>,
	<aleksa@amutable.com>, <legion@kernel.org>, <david@kernel.org>,
	<sandeen@redhat.com>, <ebiggers@kernel.org>,
	<linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-fsdevel@vger.kernel.org>, <gfs2@lists.linux.dev>,
	<linux-security-module@vger.kernel.org>,
	<sunjunchao@bytedance.com>
Subject: Re: [PATCH 2/3] vfs: convert inode iterators to the unsafe super_iter_inodes()
Date: Tue, 10 Nov 2026 12:01:31 +0800	[thread overview]
Message-ID: <avKXG8jGHhokoXtC@hsj-2U-Workstation> (raw)
In-Reply-To: <phaorzf3wo3qg3dwxwzemtvc3xk644lecgoeeu3th2zx3cv5ml@xzhc2jw7vobi>

在 Mon, Nov 09, 2026 at 11:08:00AM +0100,Jan Kara 写道:
> On Thu 15-10-26 17:38:53, Huang Shijie wrote:
> > Convert VFS internal superblock inode iterators that cannot use
> > referenced inodes to super_iter_inodes() with INO_ITER_F_UNSAFE set:
> >   - Dquot removal
> >   - inode eviction
> >   - The nr_blockdev_pages()
> >   - generic_shutdown_super()
> > 
> > Signed-off-by: Huang Shijie <huangsj@hygon.cn>
> 
> See some comments below.
> 
> > diff --git a/fs/inode.c b/fs/inode.c
> > index a9d37be390a1..139c56ee9d11 100644
> > --- a/fs/inode.c
> > +++ b/fs/inode.c
> > @@ -853,8 +853,11 @@ static void evict(struct inode *inode)
> >   * Dispose-list gets a local list with local inodes in it, so it doesn't
> >   * need to worry about list corruption and SMP locks.
> >   */
> > -static void dispose_list(struct list_head *head)
> > +static bool dispose_list(struct list_head *head)
> >  {
> > +	if (list_empty(head))
> > +		return false;
> > +
> >  	while (!list_empty(head)) {
> >  		struct inode *inode;
> >  
> > @@ -864,6 +867,29 @@ static void dispose_list(struct list_head *head)
> >  		evict(inode);
> >  		cond_resched();
> >  	}
> > +	return true;
> > +}
> > +
> > +static int evict_inode_fn(struct inode *inode, void *data)
> > +{
> > +	struct list_head *dispose = data;
> > +
> 
> Here we miss the unlocked check
>             if (icount_read_once(inode))
>                     continue;
Thanks for pointing this.
	
> so every inode will now go through the i_lock roundtrip.
> 
> > +	spin_lock(&inode->i_lock);
> > +	if (icount_read(inode) ||
> > +	    (inode_state_read(inode) & (I_NEW | I_FREEING | I_WILL_FREE))) {
> > +		spin_unlock(&inode->i_lock);
> > +		return INO_ITER_RET_DONE;
> > +	}
> > +
> > +	inode_state_set(inode, I_FREEING);
> > +	inode_lru_list_del(inode);
> > +	spin_unlock(&inode->i_lock);
> > +	list_add(&inode->i_lru, dispose);
> > +
> > +	/* Abort so evict_inodes() can dispose of the queued inodes first. */
> > +	if (need_resched())
> > +		return INO_ITER_RET_ABORT;
> > +	return INO_ITER_RET_DONE;
> >  }
> 
> The need_resched() handling needs more thought here. The way you've done it
> will just abort the iteration, evict gathered inodes and then restart the
> whole iteration (which will then have to skip again all the inodes we could
> not evict). Which is not what evict_inodes() does today and we really had
> to resort to those tricks to avoid softlockups under certain loads.
> Frankly, this iteration is so special that I'd be willing to leave it
> unconverted for now rather than trying to bend the general iterator for its
> needs.
okay. I will think over it again.

If I really cannot find a good way to avoid the softlockups,
I will keep the code unconverted.

Thanks
Huang Shijie



  reply	other threads:[~2026-11-10  4:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15  9:38 [PATCH 0/3] vfs: add inode iteration method super_iter_inodes Huang Shijie
2026-10-15  9:38 ` [PATCH 1/3] " Huang Shijie
2026-10-15 15:23   ` Stephen Smalley
2026-10-16  2:45     ` Huang Shijie
2026-11-09  9:58   ` Jan Kara
2026-11-10  2:32     ` Huang Shijie
2026-11-09 10:43   ` Jan Kara
2026-11-10  2:38     ` Huang Shijie
2026-10-15  9:38 ` [PATCH 2/3] vfs: convert inode iterators to the unsafe super_iter_inodes() Huang Shijie
2026-11-09 10:08   ` Jan Kara
2026-11-10  4:01     ` Huang Shijie [this message]
2026-10-15  9:38 ` [PATCH 3/3] vfs: convert sb->s_inodes iteration to super_iter_inodes() Huang Shijie
2026-11-09 10:31   ` Jan Kara
2026-10-21 10:58 ` [PATCH 0/3] vfs: add inode iteration method super_iter_inodes Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=avKXG8jGHhokoXtC@hsj-2U-Workstation \
    --to=huangsj@hygon.cn \
    --cc=agruenba@redhat.com \
    --cc=aleksa@amutable.com \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=david@kernel.org \
    --cc=ebiggers@kernel.org \
    --cc=fangbaoshun@hygon.cn \
    --cc=gfs2@lists.linux.dev \
    --cc=gnoack@google.com \
    --cc=jack@suse.cz \
    --cc=jmorris@namei.org \
    --cc=legion@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mic@digikod.net \
    --cc=paul@paul-moore.com \
    --cc=sandeen@redhat.com \
    --cc=serge@hallyn.com \
    --cc=sunjunchao@bytedance.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=yingzhiwei@hygon.cn \
    --cc=zhongyuan@hygon.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®