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/dcache.c | |
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/dcache.c')
-rw-r--r-- | fs/dcache.c | 23 |
1 files changed, 11 insertions, 12 deletions
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); |