提交 4f522a24 编写于 作者: A Al Viro

d_hash_and_lookup(): export, switch open-coded instances

* calling conventions change - ERR_PTR() is returned on ->d_hash() errors;
NULL is just for dcache miss now.
* exported, open-coded instances in ncpfs and cifs converted.
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 3592ac44
...@@ -82,12 +82,10 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name, ...@@ -82,12 +82,10 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,
cFYI(1, "%s: for %s", __func__, name->name); cFYI(1, "%s: for %s", __func__, name->name);
if (parent->d_op && parent->d_op->d_hash) dentry = d_hash_and_lookup(parent, name);
parent->d_op->d_hash(parent, parent->d_inode, name); if (unlikely(IS_ERR(dentry)))
else return;
name->hash = full_name_hash(name->name, name->len);
dentry = d_lookup(parent, name);
if (dentry) { if (dentry) {
int err; int err;
......
...@@ -1672,7 +1672,6 @@ EXPORT_SYMBOL(d_splice_alias); ...@@ -1672,7 +1672,6 @@ EXPORT_SYMBOL(d_splice_alias);
struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
struct qstr *name) struct qstr *name)
{ {
int error;
struct dentry *found; struct dentry *found;
struct dentry *new; struct dentry *new;
...@@ -1681,10 +1680,12 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, ...@@ -1681,10 +1680,12 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
* if not go ahead and create it now. * if not go ahead and create it now.
*/ */
found = d_hash_and_lookup(dentry->d_parent, name); found = d_hash_and_lookup(dentry->d_parent, name);
if (unlikely(IS_ERR(found)))
goto err_out;
if (!found) { if (!found) {
new = d_alloc(dentry->d_parent, name); new = d_alloc(dentry->d_parent, name);
if (!new) { if (!new) {
error = -ENOMEM; found = ERR_PTR(-ENOMEM);
goto err_out; goto err_out;
} }
...@@ -1725,7 +1726,7 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, ...@@ -1725,7 +1726,7 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
err_out: err_out:
iput(inode); iput(inode);
return ERR_PTR(error); return found;
} }
EXPORT_SYMBOL(d_add_ci); EXPORT_SYMBOL(d_add_ci);
...@@ -1997,12 +1998,10 @@ struct dentry *__d_lookup(const struct dentry *parent, const struct qstr *name) ...@@ -1997,12 +1998,10 @@ struct dentry *__d_lookup(const struct dentry *parent, const struct qstr *name)
* @dir: Directory to search in * @dir: Directory to search in
* @name: qstr of name we wish to find * @name: qstr of name we wish to find
* *
* On hash failure or on lookup failure NULL is returned. * On lookup failure NULL is returned; on bad name - ERR_PTR(-error)
*/ */
struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name) struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name)
{ {
struct dentry *dentry = NULL;
/* /*
* Check for a fs-specific hash function. Note that we must * Check for a fs-specific hash function. Note that we must
* calculate the standard hash first, as the d_op->d_hash() * calculate the standard hash first, as the d_op->d_hash()
...@@ -2010,13 +2009,13 @@ struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name) ...@@ -2010,13 +2009,13 @@ struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name)
*/ */
name->hash = full_name_hash(name->name, name->len); name->hash = full_name_hash(name->name, name->len);
if (dir->d_flags & DCACHE_OP_HASH) { if (dir->d_flags & DCACHE_OP_HASH) {
if (dir->d_op->d_hash(dir, dir->d_inode, name) < 0) int err = dir->d_op->d_hash(dir, dir->d_inode, name);
goto out; if (unlikely(err < 0))
return ERR_PTR(err);
} }
dentry = d_lookup(dir, name); return d_lookup(dir, name);
out:
return dentry;
} }
EXPORT_SYMBOL(d_hash_and_lookup);
/** /**
* d_validate - verify dentry provided from insecure source (deprecated) * d_validate - verify dentry provided from insecure source (deprecated)
...@@ -2995,7 +2994,7 @@ ino_t find_inode_number(struct dentry *dir, struct qstr *name) ...@@ -2995,7 +2994,7 @@ ino_t find_inode_number(struct dentry *dir, struct qstr *name)
ino_t ino = 0; ino_t ino = 0;
dentry = d_hash_and_lookup(dir, name); dentry = d_hash_and_lookup(dir, name);
if (dentry) { if (!IS_ERR_OR_NULL(dentry)) {
if (dentry->d_inode) if (dentry->d_inode)
ino = dentry->d_inode->i_ino; ino = dentry->d_inode->i_ino;
dput(dentry); dput(dentry);
......
...@@ -593,14 +593,10 @@ ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir, ...@@ -593,14 +593,10 @@ ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
return 1; /* I'm not sure */ return 1; /* I'm not sure */
qname.name = __name; qname.name = __name;
qname.hash = full_name_hash(qname.name, qname.len);
if (dentry->d_op && dentry->d_op->d_hash) newdent = d_hash_and_lookup(dentry, &qname);
if (dentry->d_op->d_hash(dentry, dentry->d_inode, &qname) != 0) if (unlikely(IS_ERR(newdent)))
goto end_advance; goto end_advance;
newdent = d_lookup(dentry, &qname);
if (!newdent) { if (!newdent) {
newdent = d_alloc(dentry, &qname); newdent = d_alloc(dentry, &qname);
if (!newdent) if (!newdent)
......
...@@ -2618,6 +2618,7 @@ static void proc_flush_task_mnt(struct vfsmount *mnt, pid_t pid, pid_t tgid) ...@@ -2618,6 +2618,7 @@ static void proc_flush_task_mnt(struct vfsmount *mnt, pid_t pid, pid_t tgid)
name.name = buf; name.name = buf;
name.len = snprintf(buf, sizeof(buf), "%d", pid); name.len = snprintf(buf, sizeof(buf), "%d", pid);
/* no ->d_hash() rejects on procfs */
dentry = d_hash_and_lookup(mnt->mnt_root, &name); dentry = d_hash_and_lookup(mnt->mnt_root, &name);
if (dentry) { if (dentry) {
shrink_dcache_parent(dentry); shrink_dcache_parent(dentry);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册