Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 36190
b: refs/heads/master
c: bcdc5e0
h: refs/heads/master
v: v3
  • Loading branch information
Ian Kent authored and Linus Torvalds committed Sep 27, 2006
1 parent a32eb60 commit e5822a3
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1183dc943cae8b0fddca0b310c26052b2355e04b
refs/heads/master: bcdc5e019d9f525a9f181a7de642d3a9c27c7610
38 changes: 30 additions & 8 deletions trunk/fs/autofs4/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
nd.flags = LOOKUP_DIRECTORY;
ret = (dentry->d_op->d_revalidate)(dentry, &nd);

if (!ret) {
if (ret <= 0) {
if (ret < 0)
status = ret;
dcache_dir_close(inode, file);
goto out;
}
Expand Down Expand Up @@ -400,13 +402,23 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
int oz_mode = autofs4_oz_mode(sbi);
int flags = nd ? nd->flags : 0;
int status = 0;
int status = 1;

/* Pending dentry */
if (autofs4_ispending(dentry)) {
if (!oz_mode)
status = try_to_fill_dentry(dentry, flags);
return !status;
/* The daemon never causes a mount to trigger */
if (oz_mode)
return 1;

/*
* A zero status is success otherwise we have a
* negative error code.
*/
status = try_to_fill_dentry(dentry, flags);
if (status == 0)
return 1;

return status;
}

/* Negative dentry.. invalidate if "old" */
Expand All @@ -421,9 +433,19 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
DPRINTK("dentry=%p %.*s, emptydir",
dentry, dentry->d_name.len, dentry->d_name.name);
spin_unlock(&dcache_lock);
if (!oz_mode)
status = try_to_fill_dentry(dentry, flags);
return !status;
/* The daemon never causes a mount to trigger */
if (oz_mode)
return 1;

/*
* A zero status is success otherwise we have a
* negative error code.
*/
status = try_to_fill_dentry(dentry, flags);
if (status == 0)
return 1;

return status;
}
spin_unlock(&dcache_lock);

Expand Down
50 changes: 35 additions & 15 deletions trunk/fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,30 @@ void release_open_intent(struct nameidata *nd)
fput(nd->intent.open.file);
}

static inline struct dentry *
do_revalidate(struct dentry *dentry, struct nameidata *nd)
{
int status = dentry->d_op->d_revalidate(dentry, nd);
if (unlikely(status <= 0)) {
/*
* The dentry failed validation.
* If d_revalidate returned 0 attempt to invalidate
* the dentry otherwise d_revalidate is asking us
* to return a fail status.
*/
if (!status) {
if (!d_invalidate(dentry)) {
dput(dentry);
dentry = NULL;
}
} else {
dput(dentry);
dentry = ERR_PTR(status);
}
}
return dentry;
}

/*
* Internal lookup() using the new generic dcache.
* SMP-safe
Expand All @@ -386,12 +410,9 @@ static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name,
if (!dentry)
dentry = d_lookup(parent, name);

if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
if (!dentry->d_op->d_revalidate(dentry, nd) && !d_invalidate(dentry)) {
dput(dentry);
dentry = NULL;
}
}
if (dentry && dentry->d_op && dentry->d_op->d_revalidate)
dentry = do_revalidate(dentry, nd);

return dentry;
}

Expand Down Expand Up @@ -484,10 +505,9 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, s
*/
mutex_unlock(&dir->i_mutex);
if (result->d_op && result->d_op->d_revalidate) {
if (!result->d_op->d_revalidate(result, nd) && !d_invalidate(result)) {
dput(result);
result = do_revalidate(result, nd);
if (!result)
result = ERR_PTR(-ENOENT);
}
}
return result;
}
Expand Down Expand Up @@ -767,12 +787,12 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
goto done;

need_revalidate:
if (dentry->d_op->d_revalidate(dentry, nd))
goto done;
if (d_invalidate(dentry))
goto done;
dput(dentry);
goto need_lookup;
dentry = do_revalidate(dentry, nd);
if (!dentry)
goto need_lookup;
if (IS_ERR(dentry))
goto fail;
goto done;

fail:
return PTR_ERR(dentry);
Expand Down

0 comments on commit e5822a3

Please sign in to comment.