linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fox Chen <foxhlchen@gmail.com>
To: Ian Kent <raven@themaw.net>
Cc: Tejun Heo <tj@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Rick Lindsley <ricklind@linux.vnet.ibm.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	David Howells <dhowells@redhat.com>,
	Miklos Szeredi <miklos@szeredi.hu>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH 0/6] kernfs: proposed locking and concurrency improvement
Date: Mon, 11 Jan 2021 15:04:55 +0800	[thread overview]
Message-ID: <CAC2o3D+W70pzEd0MQ1Osxnin=j2mxwH4KdAYwR1mB67LyLbf5Q@mail.gmail.com> (raw)
In-Reply-To: <42efbb86327c2f5a8378d734edc231e3c5a34053.camel@themaw.net>

On Mon, Jan 11, 2021 at 12:20 PM Ian Kent <raven@themaw.net> wrote:
>
> On Mon, 2021-01-11 at 11:19 +0800, Ian Kent wrote:
> > On Wed, 2021-01-06 at 10:38 +0800, Fox Chen wrote:
> > > Hi Ian,
> > >
> > > I am rethinking this problem. Can we simply use a global lock?
> > >
> > >  In your original patch 5, you have a global mutex attr_mutex to
> > > protect attr, if we change it to a rwsem, is it enough to protect
> > > both
> > > inode and attr while having the concurrent read ability?
> > >
> > > like this patch I submitted. ( clearly, I missed __kernfs_iattrs
> > > part,
> > > but just about that idea )
> > > https://lore.kernel.org/lkml/20201207084333.179132-1-foxhlchen@gmail.com/
> >
> > I don't think so.
> >
> > kernfs_refresh_inode() writes to the inode so taking a read lock
> > will allow multiple processes to concurrently update it which is
> > what we need to avoid.

Oh, got it. I missed the inode part. my bad. :(

> > It's possibly even more interesting.
> >
> > For example, kernfs_iop_rmdir() and kernfs_iop_mkdir() might alter
> > the inode link count (I don't know if that would be the sort of thing
> > they would do but kernfs can't possibly know either). Both of these
> > functions rely on the VFS locking for exclusion but the inode link
> > count is updated in kernfs_refresh_inode() too.
> >
> > That's the case now, without any patches.
>
> So it's not so easy to get the inode from just the kernfs object
> so these probably aren't a problem ...

IIUC only when dop->revalidate, iop->lookup being called, the result
of rmdir/mkdir will be sync with vfs.

kernfs_node is detached from vfs inode/dentry to save ram.

> >
> > I'm not entirely sure what's going on in kernfs_refresh_inode().
> >
> > It could be as simple as being called with a NULL inode because
> > the dentry concerned is negative at that point. I haven't had
> > time to look closely at it TBH but I have been thinking about it.

um, It shouldn't be called with a NULL inode, right?

inode->i_mode = kn->mode;

otherwise will crash.

> Certainly this can be called without a struct iattr having been
> allocated ... and given it probably needs to remain a pointer
> rather than embedded in the node the inode link count update
> can't easily be protected from concurrent updates.
>
> If it was ok to do the allocation at inode creation the problem
> becomes much simpler to resolve but I thought there were concerns
> about ram consumption (although I don't think that was exactly what
> was said?).
>

you meant iattr to be allocated at inode creation time??
yes, I think so. it's due to ram consumption.



thanks,
fox

  reply	other threads:[~2021-01-11  7:06 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-22  7:47 [PATCH 0/6] kernfs: proposed locking and concurrency improvement Ian Kent
2020-12-22  7:47 ` [PATCH 1/6] kernfs: move revalidate to be near lookup Ian Kent
2020-12-22  7:47 ` [PATCH 2/6] kernfs: use VFS negative dentry caching Ian Kent
2020-12-22  7:47 ` [PATCH 3/6] kernfs: use revision to identify directory node changes Ian Kent
2020-12-22  7:48 ` [PATCH 4/6] kernfs: switch kernfs to use an rwsem Ian Kent
2020-12-22  7:48 ` [PATCH 5/6] kernfs: stay in rcu-walk mode if possible Ian Kent
2021-02-05  8:23   ` Fox Chen
2021-02-05 12:10     ` Ian Kent
2020-12-22  7:48 ` [PATCH 6/6] kernfs: add a spinlock to kernfs iattrs for inode updates Ian Kent
2020-12-24  6:23   ` [kernfs] ca0f27ecb7: BUG:kernel_NULL_pointer_dereference,address kernel test robot
2020-12-23  7:30 ` [PATCH 0/6] kernfs: proposed locking and concurrency improvement Fox Chen
2021-01-04  0:42   ` Ian Kent
2021-01-06  2:38     ` Fox Chen
2021-01-11  3:19       ` Ian Kent
2021-01-11  4:20         ` Ian Kent
2021-01-11  7:04           ` Fox Chen [this message]
2021-01-11  8:42             ` Ian Kent
2021-01-11  9:02               ` Fox Chen
2021-01-12  0:27                 ` Ian Kent
2021-01-13  5:17                 ` Ian Kent
2021-01-13  7:00                   ` Fox Chen
2021-01-13  7:47                     ` Ian Kent
2021-01-13  7:50                       ` Ian Kent
2021-01-13  8:00                         ` Fox Chen
2021-01-14  3:20                           ` Fox Chen
2021-01-14  5:37                           ` Ian Kent

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='CAC2o3D+W70pzEd0MQ1Osxnin=j2mxwH4KdAYwR1mB67LyLbf5Q@mail.gmail.com' \
    --to=foxhlchen@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=raven@themaw.net \
    --cc=ricklind@linux.vnet.ibm.com \
    --cc=tj@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).