Skip to content

Commit

Permalink
stop passing nameidata * to ->d_revalidate()
Browse files Browse the repository at this point in the history
Just the lookup flags.  Die, bastard, die...

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jul 14, 2012
1 parent fa3c56b commit 0b728e1
Show file tree
Hide file tree
Showing 25 changed files with 74 additions and 84 deletions.
2 changes: 1 addition & 1 deletion Documentation/filesystems/Locking
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ be able to use diff(1).

--------------------------- dentry_operations --------------------------
prototypes:
int (*d_revalidate)(struct dentry *, struct nameidata *);
int (*d_revalidate)(struct dentry *, unsigned int);
int (*d_hash)(const struct dentry *, const struct inode *,
struct qstr *);
int (*d_compare)(const struct dentry *, const struct inode *,
Expand Down
5 changes: 5 additions & 0 deletions Documentation/filesystems/porting
Original file line number Diff line number Diff line change
Expand Up @@ -431,3 +431,8 @@ release it yourself.
d_alloc_root() is gone, along with a lot of bugs caused by code
misusing it. Replacement: d_make_root(inode). The difference is,
d_make_root() drops the reference to inode if dentry allocation fails.

--
[mandatory]
The witch is dead! Well, 1/3 of it, anyway. ->d_revalidate() does *not*
take struct nameidata anymore; just the flags.
8 changes: 4 additions & 4 deletions Documentation/filesystems/vfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ the VFS uses a default. As of kernel 2.6.22, the following members are
defined:

struct dentry_operations {
int (*d_revalidate)(struct dentry *, struct nameidata *);
int (*d_revalidate)(struct dentry *, unsigned int);
int (*d_hash)(const struct dentry *, const struct inode *,
struct qstr *);
int (*d_compare)(const struct dentry *, const struct inode *,
Expand All @@ -921,11 +921,11 @@ struct dentry_operations {
dcache. Most filesystems leave this as NULL, because all their
dentries in the dcache are valid

d_revalidate may be called in rcu-walk mode (nd->flags & LOOKUP_RCU).
d_revalidate may be called in rcu-walk mode (flags & LOOKUP_RCU).
If in rcu-walk mode, the filesystem must revalidate the dentry without
blocking or storing to the dentry, d_parent and d_inode should not be
used without care (because they can go NULL), instead nd->inode should
be used.
used without care (because they can change and, in d_inode case, even
become NULL under us).

If a situation is encountered that rcu-walk cannot handle, return
-ECHILD and it will be called again in ref-walk mode.
Expand Down
4 changes: 2 additions & 2 deletions fs/9p/vfs_dentry.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ static void v9fs_dentry_release(struct dentry *dentry)
}
}

static int v9fs_lookup_revalidate(struct dentry *dentry, struct nameidata *nd)
static int v9fs_lookup_revalidate(struct dentry *dentry, unsigned int flags)
{
struct p9_fid *fid;
struct inode *inode;
struct v9fs_inode *v9inode;

if (nd->flags & LOOKUP_RCU)
if (flags & LOOKUP_RCU)
return -ECHILD;

inode = dentry->d_inode;
Expand Down
6 changes: 3 additions & 3 deletions fs/afs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
struct nameidata *nd);
static int afs_dir_open(struct inode *inode, struct file *file);
static int afs_readdir(struct file *file, void *dirent, filldir_t filldir);
static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd);
static int afs_d_revalidate(struct dentry *dentry, unsigned int flags);
static int afs_d_delete(const struct dentry *dentry);
static void afs_d_release(struct dentry *dentry);
static int afs_lookup_filldir(void *_cookie, const char *name, int nlen,
Expand Down Expand Up @@ -598,7 +598,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
* - NOTE! the hit can be a negative hit too, so we can't assume we have an
* inode
*/
static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)
{
struct afs_vnode *vnode, *dir;
struct afs_fid uninitialized_var(fid);
Expand All @@ -607,7 +607,7 @@ static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
void *dir_version;
int ret;

if (nd->flags & LOOKUP_RCU)
if (flags & LOOKUP_RCU)
return -ECHILD;

vnode = AFS_FS_I(dentry->d_inode);
Expand Down
6 changes: 3 additions & 3 deletions fs/ceph/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,12 +1042,12 @@ static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry)
/*
* Check if cached dentry can be trusted.
*/
static int ceph_d_revalidate(struct dentry *dentry, struct nameidata *nd)
static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags)
{
int valid = 0;
struct inode *dir;

if (nd && nd->flags & LOOKUP_RCU)
if (flags & LOOKUP_RCU)
return -ECHILD;

dout("d_revalidate %p '%.*s' inode %p offset %lld\n", dentry,
Expand Down Expand Up @@ -1094,7 +1094,7 @@ static void ceph_d_release(struct dentry *dentry)
}

static int ceph_snapdir_d_revalidate(struct dentry *dentry,
struct nameidata *nd)
unsigned int flags)
{
/*
* Eventually, we'll want to revalidate snapped metadata
Expand Down
8 changes: 4 additions & 4 deletions fs/cifs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,9 +700,9 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
}

static int
cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd)
cifs_d_revalidate(struct dentry *direntry, unsigned int flags)
{
if (nd && (nd->flags & LOOKUP_RCU))
if (flags & LOOKUP_RCU)
return -ECHILD;

if (direntry->d_inode) {
Expand Down Expand Up @@ -731,15 +731,15 @@ cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd)
* This may be nfsd (or something), anyway, we can't see the
* intent of this. So, since this can be for creation, drop it.
*/
if (!nd)
if (!flags)
return 0;

/*
* Drop the negative dentry, in order to make sure to use the
* case sensitive name which is specified by user if this is
* for creation.
*/
if (nd->flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET))
if (flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET))
return 0;

if (time_after(jiffies, direntry->d_time + HZ) || !lookupCacheEnabled)
Expand Down
6 changes: 3 additions & 3 deletions fs/coda/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static int coda_rename(struct inode *old_inode, struct dentry *old_dentry,
static int coda_readdir(struct file *file, void *buf, filldir_t filldir);

/* dentry ops */
static int coda_dentry_revalidate(struct dentry *de, struct nameidata *nd);
static int coda_dentry_revalidate(struct dentry *de, unsigned int flags);
static int coda_dentry_delete(const struct dentry *);

/* support routines */
Expand Down Expand Up @@ -536,12 +536,12 @@ static int coda_venus_readdir(struct file *coda_file, void *buf,
}

/* called when a cache lookup succeeds */
static int coda_dentry_revalidate(struct dentry *de, struct nameidata *nd)
static int coda_dentry_revalidate(struct dentry *de, unsigned int flags)
{
struct inode *inode;
struct coda_inode_info *cii;

if (nd->flags & LOOKUP_RCU)
if (flags & LOOKUP_RCU)
return -ECHILD;

inode = de->d_inode;
Expand Down
20 changes: 4 additions & 16 deletions fs/ecryptfs/dentry.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/**
* ecryptfs_d_revalidate - revalidate an ecryptfs dentry
* @dentry: The ecryptfs dentry
* @nd: The associated nameidata
* @flags: lookup flags
*
* Called when the VFS needs to revalidate a dentry. This
* is called whenever a name lookup finds a dentry in the
Expand All @@ -42,32 +42,20 @@
* Returns 1 if valid, 0 otherwise.
*
*/
static int ecryptfs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
static int ecryptfs_d_revalidate(struct dentry *dentry, unsigned int flags)
{
struct dentry *lower_dentry;
struct vfsmount *lower_mnt;
struct dentry *dentry_save = NULL;
struct vfsmount *vfsmount_save = NULL;
int rc = 1;

if (nd && nd->flags & LOOKUP_RCU)
if (flags & LOOKUP_RCU)
return -ECHILD;

lower_dentry = ecryptfs_dentry_to_lower(dentry);
lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry);
if (!lower_dentry->d_op || !lower_dentry->d_op->d_revalidate)
goto out;
if (nd) {
dentry_save = nd->path.dentry;
vfsmount_save = nd->path.mnt;
nd->path.dentry = lower_dentry;
nd->path.mnt = lower_mnt;
}
rc = lower_dentry->d_op->d_revalidate(lower_dentry, nd);
if (nd) {
nd->path.dentry = dentry_save;
nd->path.mnt = vfsmount_save;
}
rc = lower_dentry->d_op->d_revalidate(lower_dentry, flags);
if (dentry->d_inode) {
struct inode *lower_inode =
ecryptfs_inode_to_lower(dentry->d_inode);
Expand Down
12 changes: 6 additions & 6 deletions fs/fat/namei_vfat.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ static int vfat_revalidate_shortname(struct dentry *dentry)
return ret;
}

static int vfat_revalidate(struct dentry *dentry, struct nameidata *nd)
static int vfat_revalidate(struct dentry *dentry, unsigned int flags)
{
if (nd && nd->flags & LOOKUP_RCU)
if (flags & LOOKUP_RCU)
return -ECHILD;

/* This is not negative dentry. Always valid. */
Expand All @@ -52,9 +52,9 @@ static int vfat_revalidate(struct dentry *dentry, struct nameidata *nd)
return vfat_revalidate_shortname(dentry);
}

static int vfat_revalidate_ci(struct dentry *dentry, struct nameidata *nd)
static int vfat_revalidate_ci(struct dentry *dentry, unsigned int flags)
{
if (nd && nd->flags & LOOKUP_RCU)
if (flags & LOOKUP_RCU)
return -ECHILD;

/*
Expand All @@ -74,15 +74,15 @@ static int vfat_revalidate_ci(struct dentry *dentry, struct nameidata *nd)
* This may be nfsd (or something), anyway, we can't see the
* intent of this. So, since this can be for creation, drop it.
*/
if (!nd)
if (!flags)
return 0;

/*
* Drop the negative dentry, in order to make sure to use the
* case sensitive name which is specified by user if this is
* for creation.
*/
if (nd->flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET))
if (flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET))
return 0;

return vfat_revalidate_shortname(dentry);
Expand Down
4 changes: 2 additions & 2 deletions fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ u64 fuse_get_attr_version(struct fuse_conn *fc)
* the lookup once more. If the lookup results in the same inode,
* then refresh the attributes, timeouts and mark the dentry valid.
*/
static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd)
static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
{
struct inode *inode;

Expand All @@ -174,7 +174,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd)
if (!inode)
return 0;

if (nd && (nd->flags & LOOKUP_RCU))
if (flags & LOOKUP_RCU)
return -ECHILD;

fc = get_fuse_conn(inode);
Expand Down
6 changes: 3 additions & 3 deletions fs/gfs2/dentry.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
/**
* gfs2_drevalidate - Check directory lookup consistency
* @dentry: the mapping to check
* @nd:
* @flags: lookup flags
*
* Check to make sure the lookup necessary to arrive at this inode from its
* parent is still good.
*
* Returns: 1 if the dentry is ok, 0 if it isn't
*/

static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
static int gfs2_drevalidate(struct dentry *dentry, unsigned int flags)
{
struct dentry *parent;
struct gfs2_sbd *sdp;
Expand All @@ -44,7 +44,7 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
int error;
int had_lock = 0;

if (nd && nd->flags & LOOKUP_RCU)
if (flags & LOOKUP_RCU)
return -ECHILD;

parent = dget_parent(dentry);
Expand Down
4 changes: 2 additions & 2 deletions fs/hfs/sysdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

/* dentry case-handling: just lowercase everything */

static int hfs_revalidate_dentry(struct dentry *dentry, struct nameidata *nd)
static int hfs_revalidate_dentry(struct dentry *dentry, unsigned int flags)
{
struct inode *inode;
int diff;

if (nd->flags & LOOKUP_RCU)
if (flags & LOOKUP_RCU)
return -ECHILD;

inode = dentry->d_inode;
Expand Down
6 changes: 3 additions & 3 deletions fs/jfs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,7 @@ static int jfs_ci_compare(const struct dentry *parent,
return result;
}

static int jfs_ci_revalidate(struct dentry *dentry, struct nameidata *nd)
static int jfs_ci_revalidate(struct dentry *dentry, unsigned int flags)
{
/*
* This is not negative dentry. Always valid.
Expand All @@ -1589,15 +1589,15 @@ static int jfs_ci_revalidate(struct dentry *dentry, struct nameidata *nd)
* This may be nfsd (or something), anyway, we can't see the
* intent of this. So, since this can be for creation, drop it.
*/
if (!nd)
if (!flags)
return 0;

/*
* Drop the negative dentry, in order to make sure to use the
* case sensitive name which is specified by user if this is
* for creation.
*/
if (nd->flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET))
if (flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET))
return 0;
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ static int unlazy_walk(struct nameidata *nd, struct dentry *dentry)

static inline int d_revalidate(struct dentry *dentry, struct nameidata *nd)
{
return dentry->d_op->d_revalidate(dentry, nd);
return dentry->d_op->d_revalidate(dentry, nd ? nd->flags : 0);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions fs/ncpfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const struct inode_operations ncp_dir_inode_operations =
/*
* Dentry operations routines
*/
static int ncp_lookup_validate(struct dentry *, struct nameidata *);
static int ncp_lookup_validate(struct dentry *, unsigned int);
static int ncp_hash_dentry(const struct dentry *, const struct inode *,
struct qstr *);
static int ncp_compare_dentry(const struct dentry *, const struct inode *,
Expand Down Expand Up @@ -290,7 +290,7 @@ leave_me:;


static int
ncp_lookup_validate(struct dentry *dentry, struct nameidata *nd)
ncp_lookup_validate(struct dentry *dentry, unsigned int flags)
{
struct ncp_server *server;
struct dentry *parent;
Expand All @@ -302,7 +302,7 @@ ncp_lookup_validate(struct dentry *dentry, struct nameidata *nd)
if (dentry == dentry->d_sb->s_root)
return 1;

if (nd->flags & LOOKUP_RCU)
if (flags & LOOKUP_RCU)
return -ECHILD;

parent = dget_parent(dentry);
Expand Down
Loading

0 comments on commit 0b728e1

Please sign in to comment.