Commit 04bb1ba1 authored by Al Viro's avatar Al Viro

orangefs_lookup: simplify

d_splice_alias() can handle NULL and ERR_PTR() for inode just fine...
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 0ed883fd
...@@ -110,7 +110,6 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -110,7 +110,6 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry,
struct orangefs_inode_s *parent = ORANGEFS_I(dir); struct orangefs_inode_s *parent = ORANGEFS_I(dir);
struct orangefs_kernel_op_s *new_op; struct orangefs_kernel_op_s *new_op;
struct inode *inode; struct inode *inode;
struct dentry *res;
int ret = -EINVAL; int ret = -EINVAL;
/* /*
...@@ -158,65 +157,18 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -158,65 +157,18 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry,
new_op->downcall.resp.lookup.refn.fs_id, new_op->downcall.resp.lookup.refn.fs_id,
ret); ret);
if (ret < 0) { if (ret >= 0) {
if (ret == -ENOENT) {
/*
* if no inode was found, add a negative dentry to
* dcache anyway; if we don't, we don't hold expected
* lookup semantics and we most noticeably break
* during directory renames.
*
* however, if the operation failed or exited, do not
* add the dentry (e.g. in the case that a touch is
* issued on a file that already exists that was
* interrupted during this lookup -- no need to add
* another negative dentry for an existing file)
*/
gossip_debug(GOSSIP_NAME_DEBUG,
"orangefs_lookup: Adding *negative* dentry "
"%p for %pd\n",
dentry,
dentry);
d_add(dentry, NULL);
res = NULL;
goto out;
}
/* must be a non-recoverable error */
res = ERR_PTR(ret);
goto out;
}
orangefs_set_timeout(dentry); orangefs_set_timeout(dentry);
inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn); inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn);
if (IS_ERR(inode)) { } else if (ret == -ENOENT) {
gossip_debug(GOSSIP_NAME_DEBUG, inode = NULL;
"error %ld from iget\n", PTR_ERR(inode)); } else {
res = ERR_CAST(inode); /* must be a non-recoverable error */
goto out; inode = ERR_PTR(ret);
} }
gossip_debug(GOSSIP_NAME_DEBUG,
"%s:%s:%d "
"Found good inode [%lu] with count [%d]\n",
__FILE__,
__func__,
__LINE__,
inode->i_ino,
(int)atomic_read(&inode->i_count));
/* update dentry/inode pair into dcache */
res = d_splice_alias(inode, dentry);
gossip_debug(GOSSIP_NAME_DEBUG,
"Lookup success (inode ct = %d)\n",
(int)atomic_read(&inode->i_count));
out:
op_release(new_op); op_release(new_op);
return res; return d_splice_alias(inode, dentry);
} }
/* return 0 on success; non-zero otherwise */ /* return 0 on success; non-zero otherwise */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment