diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-02-11 23:20:37 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-02-26 02:46:07 -0500 |
commit | 4f522a247bc26d4ab5c8fc406ffffa8b3a77abe3 (patch) | |
tree | ed3ca7fb7316f96e7aab23f9563523521bed3259 /fs | |
parent | 3592ac444017996f5a8ecf85856af0a8938e8fd1 (diff) |
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: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/cifs/readdir.c | 8 | ||||
-rw-r--r-- | fs/dcache.c | 23 | ||||
-rw-r--r-- | fs/ncpfs/dir.c | 10 | ||||
-rw-r--r-- | fs/proc/base.c | 1 |
4 files changed, 18 insertions, 24 deletions
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index 7255b0c7aa7e..df40cc5fd13a 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c | |||
@@ -82,12 +82,10 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name, | |||
82 | 82 | ||
83 | cFYI(1, "%s: for %s", __func__, name->name); | 83 | cFYI(1, "%s: for %s", __func__, name->name); |
84 | 84 | ||
85 | if (parent->d_op && parent->d_op->d_hash) | 85 | dentry = d_hash_and_lookup(parent, name); |
86 | parent->d_op->d_hash(parent, parent->d_inode, name); | 86 | if (unlikely(IS_ERR(dentry))) |
87 | else | 87 | return; |
88 | name->hash = full_name_hash(name->name, name->len); | ||
89 | 88 | ||
90 | dentry = d_lookup(parent, name); | ||
91 | if (dentry) { | 89 | if (dentry) { |
92 | int err; | 90 | int err; |
93 | 91 | ||
diff --git a/fs/dcache.c b/fs/dcache.c index ada6123414ae..ebab049826c0 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -1672,7 +1672,6 @@ EXPORT_SYMBOL(d_splice_alias); | |||
1672 | struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, | 1672 | struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, |
1673 | struct qstr *name) | 1673 | struct qstr *name) |
1674 | { | 1674 | { |
1675 | int error; | ||
1676 | struct dentry *found; | 1675 | struct dentry *found; |
1677 | struct dentry *new; | 1676 | struct dentry *new; |
1678 | 1677 | ||
@@ -1681,10 +1680,12 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, | |||
1681 | * if not go ahead and create it now. | 1680 | * if not go ahead and create it now. |
1682 | */ | 1681 | */ |
1683 | found = d_hash_and_lookup(dentry->d_parent, name); | 1682 | found = d_hash_and_lookup(dentry->d_parent, name); |
1683 | if (unlikely(IS_ERR(found))) | ||
1684 | goto err_out; | ||
1684 | if (!found) { | 1685 | if (!found) { |
1685 | new = d_alloc(dentry->d_parent, name); | 1686 | new = d_alloc(dentry->d_parent, name); |
1686 | if (!new) { | 1687 | if (!new) { |
1687 | error = -ENOMEM; | 1688 | found = ERR_PTR(-ENOMEM); |
1688 | goto err_out; | 1689 | goto err_out; |
1689 | } | 1690 | } |
1690 | 1691 | ||
@@ -1725,7 +1726,7 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, | |||
1725 | 1726 | ||
1726 | err_out: | 1727 | err_out: |
1727 | iput(inode); | 1728 | iput(inode); |
1728 | return ERR_PTR(error); | 1729 | return found; |
1729 | } | 1730 | } |
1730 | EXPORT_SYMBOL(d_add_ci); | 1731 | EXPORT_SYMBOL(d_add_ci); |
1731 | 1732 | ||
@@ -1997,12 +1998,10 @@ next: | |||
1997 | * @dir: Directory to search in | 1998 | * @dir: Directory to search in |
1998 | * @name: qstr of name we wish to find | 1999 | * @name: qstr of name we wish to find |
1999 | * | 2000 | * |
2000 | * On hash failure or on lookup failure NULL is returned. | 2001 | * On lookup failure NULL is returned; on bad name - ERR_PTR(-error) |
2001 | */ | 2002 | */ |
2002 | struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name) | 2003 | struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name) |
2003 | { | 2004 | { |
2004 | struct dentry *dentry = NULL; | ||
2005 | |||
2006 | /* | 2005 | /* |
2007 | * Check for a fs-specific hash function. Note that we must | 2006 | * Check for a fs-specific hash function. Note that we must |
2008 | * calculate the standard hash first, as the d_op->d_hash() | 2007 | * 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 | */ | 2009 | */ |
2011 | name->hash = full_name_hash(name->name, name->len); | 2010 | name->hash = full_name_hash(name->name, name->len); |
2012 | if (dir->d_flags & DCACHE_OP_HASH) { | 2011 | if (dir->d_flags & DCACHE_OP_HASH) { |
2013 | if (dir->d_op->d_hash(dir, dir->d_inode, name) < 0) | 2012 | int err = dir->d_op->d_hash(dir, dir->d_inode, name); |
2014 | goto out; | 2013 | if (unlikely(err < 0)) |
2014 | return ERR_PTR(err); | ||
2015 | } | 2015 | } |
2016 | dentry = d_lookup(dir, name); | 2016 | return d_lookup(dir, name); |
2017 | out: | ||
2018 | return dentry; | ||
2019 | } | 2017 | } |
2018 | EXPORT_SYMBOL(d_hash_and_lookup); | ||
2020 | 2019 | ||
2021 | /** | 2020 | /** |
2022 | * d_validate - verify dentry provided from insecure source (deprecated) | 2021 | * 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 | ino_t ino = 0; | 2994 | ino_t ino = 0; |
2996 | 2995 | ||
2997 | dentry = d_hash_and_lookup(dir, name); | 2996 | dentry = d_hash_and_lookup(dir, name); |
2998 | if (dentry) { | 2997 | if (!IS_ERR_OR_NULL(dentry)) { |
2999 | if (dentry->d_inode) | 2998 | if (dentry->d_inode) |
3000 | ino = dentry->d_inode->i_ino; | 2999 | ino = dentry->d_inode->i_ino; |
3001 | dput(dentry); | 3000 | dput(dentry); |
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index 4117e7b377bb..816326093656 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c | |||
@@ -593,14 +593,10 @@ ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir, | |||
593 | return 1; /* I'm not sure */ | 593 | return 1; /* I'm not sure */ |
594 | 594 | ||
595 | qname.name = __name; | 595 | qname.name = __name; |
596 | qname.hash = full_name_hash(qname.name, qname.len); | ||
597 | |||
598 | if (dentry->d_op && dentry->d_op->d_hash) | ||
599 | if (dentry->d_op->d_hash(dentry, dentry->d_inode, &qname) != 0) | ||
600 | goto end_advance; | ||
601 | |||
602 | newdent = d_lookup(dentry, &qname); | ||
603 | 596 | ||
597 | newdent = d_hash_and_lookup(dentry, &qname); | ||
598 | if (unlikely(IS_ERR(newdent))) | ||
599 | goto end_advance; | ||
604 | if (!newdent) { | 600 | if (!newdent) { |
605 | newdent = d_alloc(dentry, &qname); | 601 | newdent = d_alloc(dentry, &qname); |
606 | if (!newdent) | 602 | if (!newdent) |
diff --git a/fs/proc/base.c b/fs/proc/base.c index 760268d6cba6..9d9625559727 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -2618,6 +2618,7 @@ static void proc_flush_task_mnt(struct vfsmount *mnt, pid_t pid, pid_t tgid) | |||
2618 | 2618 | ||
2619 | name.name = buf; | 2619 | name.name = buf; |
2620 | name.len = snprintf(buf, sizeof(buf), "%d", pid); | 2620 | name.len = snprintf(buf, sizeof(buf), "%d", pid); |
2621 | /* no ->d_hash() rejects on procfs */ | ||
2621 | dentry = d_hash_and_lookup(mnt->mnt_root, &name); | 2622 | dentry = d_hash_and_lookup(mnt->mnt_root, &name); |
2622 | if (dentry) { | 2623 | if (dentry) { |
2623 | shrink_dcache_parent(dentry); | 2624 | shrink_dcache_parent(dentry); |