Re: [RFC][PATCHSET v3] non-recursive pathname resolution & RCU symlinks

From: Al Viro
Date: Fri May 15 2015 - 21:39:17 EST


On Fri, May 15, 2015 at 05:45:56PM -0700, Linus Torvalds wrote:

> Al, do you have any ideas? Personally, I've wanted to make I_mutex a
> rwsem for a long time, but right now pretty much everything uses it
> for exclusion. For example, filename lookup is clearly just reading
> the directory, so it should take a rwsem for reading, right? No. Not
> the way it is done now. Filename lookup wants the directory inode
> exclusively because that guarantees that we create just one dentry and
> call the filesystem ->lookup only once on that dentry.

rwsem by itself won't do us much good there. Look: for multiple lookups on
the same existing entry we could try to teach d_splice_alias() to cope,
etc. But what happens when a bunch of processes looks for the same
inexistent entry? And no, "who cares about fuckloads of negatives with
the same name" isn't a good answer - suppose we do mkdir() after that.
OK, so we'll find a negative dentry in dcache. And tell the filesystem
to create the sucker. Done. Made it positive. Now, do we hunt down
all _other_ negative dentries for it? Or never keep negative ones at
all. Or slap some kind of ->d_revalidate() there to catch all negative
dentries creates before the last mkdir/creat/mknod/symlink/link in given
parent?

One possibility would be a new dentry state - "being looked up". Hashed,
treated as "fall out of RCU mode" for lazy pathwalk purposes, and places
where we call ->lookup() would (while still holding ->i_mutex on parent
shared) wait for that state to end. Places where we call ->d_revalidate()
(with or without ->i_mutex on parent) would also wait on those.

It would need a careful analysis of tree-walkers, though. Doable, but there
might be dragons. In case of e.g. ceph - swamp ones, with mirror in the line
of sight...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/