Commit fb5f51c7 authored by Ian Kent's avatar Ian Kent Committed by Al Viro

vfs: change d_manage() to take a struct path

For the autofs module to be able to reliably check if a dentry is a
mountpoint in a multiple namespace environment the ->d_manage() dentry
operation will need to take a path argument instead of a dentry.

Link: http://lkml.kernel.org/r/20161011053352.27645.83962.stgit@pluto.themaw.netSigned-off-by: default avatarIan Kent <raven@themaw.net>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Omar Sandoval <osandov@osandov.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent e5517c2a
...@@ -20,7 +20,7 @@ prototypes: ...@@ -20,7 +20,7 @@ prototypes:
void (*d_iput)(struct dentry *, struct inode *); void (*d_iput)(struct dentry *, struct inode *);
char *(*d_dname)((struct dentry *dentry, char *buffer, int buflen); char *(*d_dname)((struct dentry *dentry, char *buffer, int buflen);
struct vfsmount *(*d_automount)(struct path *path); struct vfsmount *(*d_automount)(struct path *path);
int (*d_manage)(struct dentry *, bool); int (*d_manage)(const struct path *, bool);
struct dentry *(*d_real)(struct dentry *, const struct inode *, struct dentry *(*d_real)(struct dentry *, const struct inode *,
unsigned int); unsigned int);
......
...@@ -948,7 +948,7 @@ struct dentry_operations { ...@@ -948,7 +948,7 @@ struct dentry_operations {
void (*d_iput)(struct dentry *, struct inode *); void (*d_iput)(struct dentry *, struct inode *);
char *(*d_dname)(struct dentry *, char *, int); char *(*d_dname)(struct dentry *, char *, int);
struct vfsmount *(*d_automount)(struct path *); struct vfsmount *(*d_automount)(struct path *);
int (*d_manage)(struct dentry *, bool); int (*d_manage)(const struct path *, bool);
struct dentry *(*d_real)(struct dentry *, const struct inode *, struct dentry *(*d_real)(struct dentry *, const struct inode *,
unsigned int); unsigned int);
}; };
......
...@@ -32,7 +32,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file); ...@@ -32,7 +32,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file);
static struct dentry *autofs4_lookup(struct inode *, static struct dentry *autofs4_lookup(struct inode *,
struct dentry *, unsigned int); struct dentry *, unsigned int);
static struct vfsmount *autofs4_d_automount(struct path *); static struct vfsmount *autofs4_d_automount(struct path *);
static int autofs4_d_manage(struct dentry *, bool); static int autofs4_d_manage(const struct path *, bool);
static void autofs4_dentry_release(struct dentry *); static void autofs4_dentry_release(struct dentry *);
const struct file_operations autofs4_root_operations = { const struct file_operations autofs4_root_operations = {
...@@ -421,8 +421,9 @@ static struct vfsmount *autofs4_d_automount(struct path *path) ...@@ -421,8 +421,9 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
return NULL; return NULL;
} }
static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk) static int autofs4_d_manage(const struct path *path, bool rcu_walk)
{ {
struct dentry *dentry = path->dentry;
struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
struct autofs_info *ino = autofs4_dentry_ino(dentry); struct autofs_info *ino = autofs4_dentry_ino(dentry);
int status; int status;
......
...@@ -1200,7 +1200,7 @@ static int follow_managed(struct path *path, struct nameidata *nd) ...@@ -1200,7 +1200,7 @@ static int follow_managed(struct path *path, struct nameidata *nd)
if (managed & DCACHE_MANAGE_TRANSIT) { if (managed & DCACHE_MANAGE_TRANSIT) {
BUG_ON(!path->dentry->d_op); BUG_ON(!path->dentry->d_op);
BUG_ON(!path->dentry->d_op->d_manage); BUG_ON(!path->dentry->d_op->d_manage);
ret = path->dentry->d_op->d_manage(path->dentry, false); ret = path->dentry->d_op->d_manage(path, false);
if (ret < 0) if (ret < 0)
break; break;
} }
...@@ -1263,10 +1263,10 @@ int follow_down_one(struct path *path) ...@@ -1263,10 +1263,10 @@ int follow_down_one(struct path *path)
} }
EXPORT_SYMBOL(follow_down_one); EXPORT_SYMBOL(follow_down_one);
static inline int managed_dentry_rcu(struct dentry *dentry) static inline int managed_dentry_rcu(const struct path *path)
{ {
return (dentry->d_flags & DCACHE_MANAGE_TRANSIT) ? return (path->dentry->d_flags & DCACHE_MANAGE_TRANSIT) ?
dentry->d_op->d_manage(dentry, true) : 0; path->dentry->d_op->d_manage(path, true) : 0;
} }
/* /*
...@@ -1282,7 +1282,7 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path, ...@@ -1282,7 +1282,7 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path,
* Don't forget we might have a non-mountpoint managed dentry * Don't forget we might have a non-mountpoint managed dentry
* that wants to block transit. * that wants to block transit.
*/ */
switch (managed_dentry_rcu(path->dentry)) { switch (managed_dentry_rcu(path)) {
case -ECHILD: case -ECHILD:
default: default:
return false; return false;
...@@ -1392,8 +1392,7 @@ int follow_down(struct path *path) ...@@ -1392,8 +1392,7 @@ int follow_down(struct path *path)
if (managed & DCACHE_MANAGE_TRANSIT) { if (managed & DCACHE_MANAGE_TRANSIT) {
BUG_ON(!path->dentry->d_op); BUG_ON(!path->dentry->d_op);
BUG_ON(!path->dentry->d_op->d_manage); BUG_ON(!path->dentry->d_op->d_manage);
ret = path->dentry->d_op->d_manage( ret = path->dentry->d_op->d_manage(path, false);
path->dentry, false);
if (ret < 0) if (ret < 0)
return ret == -EISDIR ? 0 : ret; return ret == -EISDIR ? 0 : ret;
} }
......
...@@ -139,7 +139,7 @@ struct dentry_operations { ...@@ -139,7 +139,7 @@ struct dentry_operations {
void (*d_iput)(struct dentry *, struct inode *); void (*d_iput)(struct dentry *, struct inode *);
char *(*d_dname)(struct dentry *, char *, int); char *(*d_dname)(struct dentry *, char *, int);
struct vfsmount *(*d_automount)(struct path *); struct vfsmount *(*d_automount)(struct path *);
int (*d_manage)(struct dentry *, bool); int (*d_manage)(const struct path *, bool);
struct dentry *(*d_real)(struct dentry *, const struct inode *, struct dentry *(*d_real)(struct dentry *, const struct inode *,
unsigned int); unsigned int);
} ____cacheline_aligned; } ____cacheline_aligned;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment