Message ID | 20161011053418.27645.15241.stgit@pluto.themaw.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Oct 11, 2016 at 01:34:18PM +0800, Ian Kent wrote: > + path = file->f_path; > + > /* > * An empty directory in an autofs file system is always a > * mount point. The daemon must have failed to mount this > @@ -123,7 +126,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file) > * it. > */ > spin_lock(&sbi->lookup_lock); > - if (!d_mountpoint(dentry) && simple_empty(dentry)) { > + if (!path_is_mountpoint(&path) && simple_empty(dentry)) { Why not &file->f_path, provided that you constify that thing properly? > + if (rcu_walk) { > + if (!path_is_mountpoint_rcu(path)) > + return -EISDIR; > + } else { > + if (!path_is_mountpoint(path)) > + return -EISDIR; IDGI. What's the point of _having_ the _rcu() variant, anyway? Here you are probably paying more in terms of i-cache footprint/branch prediction than you win on not doing that rcu_read_lock()/rcu_read_unlock()... _rcu variants make sense when non-RCU case does something you can't do under RCU; here your path_is_mountpoint() is pretty close to being rcu_read_lock()+path_is_mountpoint_rcu()+rcu_read_unlock() anyway... -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, 2016-10-27 at 03:17 +0100, Al Viro wrote: > On Tue, Oct 11, 2016 at 01:34:18PM +0800, Ian Kent wrote: > > > > + path = file->f_path; > > + > > /* > > * An empty directory in an autofs file system is always a > > * mount point. The daemon must have failed to mount this > > @@ -123,7 +126,7 @@ static int autofs4_dir_open(struct inode *inode, struct > > file *file) > > * it. > > */ > > spin_lock(&sbi->lookup_lock); > > - if (!d_mountpoint(dentry) && simple_empty(dentry)) { > > + if (!path_is_mountpoint(&path) && simple_empty(dentry)) { > Why not &file->f_path, provided that you constify that thing properly? Yep, my bad, as pointed out by Eric. Patches to fix that and constify a bunch of things will follow. > > > > > + if (rcu_walk) { > > + if (!path_is_mountpoint_rcu(path)) > > + return -EISDIR; > > + } else { > > + if (!path_is_mountpoint(path)) > > + return -EISDIR; > IDGI. What's the point of _having_ the _rcu() variant, anyway? Here you > are probably paying more in terms of i-cache footprint/branch prediction > than you win on not doing that rcu_read_lock()/rcu_read_unlock()... > > _rcu variants make sense when non-RCU case does something you can't do > under RCU; here your path_is_mountpoint() is pretty close to being > rcu_read_lock()+path_is_mountpoint_rcu()+rcu_read_unlock() anyway... Again, my bad, I'll merge these two and post along with the follow up patches above. Thanks Al, Ian -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c index d47930ad..d7e48fe 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c @@ -107,12 +107,15 @@ static int autofs4_dir_open(struct inode *inode, struct file *file) { struct dentry *dentry = file->f_path.dentry; struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); + struct path path; pr_debug("file=%p dentry=%p %pd\n", file, dentry, dentry); if (autofs4_oz_mode(sbi)) goto out; + path = file->f_path; + /* * An empty directory in an autofs file system is always a * mount point. The daemon must have failed to mount this @@ -123,7 +126,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file) * it. */ spin_lock(&sbi->lookup_lock); - if (!d_mountpoint(dentry) && simple_empty(dentry)) { + if (!path_is_mountpoint(&path) && simple_empty(dentry)) { spin_unlock(&sbi->lookup_lock); return -ENOENT; } @@ -372,15 +375,15 @@ static struct vfsmount *autofs4_d_automount(struct path *path) /* * If the dentry is a symlink it's equivalent to a directory - * having d_mountpoint() true, so there's no need to call back - * to the daemon. + * having path_is_mountpoint() true, so there's no need to call + * back to the daemon. */ if (d_really_is_positive(dentry) && d_is_symlink(dentry)) { spin_unlock(&sbi->fs_lock); goto done; } - if (!d_mountpoint(dentry)) { + if (!path_is_mountpoint(path)) { /* * It's possible that user space hasn't removed directories * after umounting a rootless multi-mount, although it @@ -434,8 +437,13 @@ static int autofs4_d_manage(struct path *path, bool rcu_walk) /* The daemon never waits. */ if (autofs4_oz_mode(sbi)) { - if (!d_mountpoint(dentry)) - return -EISDIR; + if (rcu_walk) { + if (!path_is_mountpoint_rcu(path)) + return -EISDIR; + } else { + if (!path_is_mountpoint(path)) + return -EISDIR; + } return 0; } @@ -463,7 +471,7 @@ static int autofs4_d_manage(struct path *path, bool rcu_walk) if (ino->flags & AUTOFS_INF_WANT_EXPIRE) return 0; - if (d_mountpoint(dentry)) + if (path_is_mountpoint_rcu(path)) return 0; inode = d_inode_rcu(dentry); if (inode && S_ISLNK(inode->i_mode)) @@ -490,7 +498,7 @@ static int autofs4_d_manage(struct path *path, bool rcu_walk) * we can avoid needless calls ->d_automount() and avoid * an incorrect ELOOP error return. */ - if ((!d_mountpoint(dentry) && !simple_empty(dentry)) || + if ((!path_is_mountpoint(path) && !simple_empty(dentry)) || (d_really_is_positive(dentry) && d_is_symlink(dentry))) status = -EISDIR; }