You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
orangefs_lookup: simplify
d_splice_alias() can handle NULL and ERR_PTR() for inode just fine... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
+8
-56
@@ -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,
|
|||||||
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) {
|
orangefs_set_timeout(dentry);
|
||||||
/*
|
inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn);
|
||||||
* if no inode was found, add a negative dentry to
|
} else if (ret == -ENOENT) {
|
||||||
* dcache anyway; if we don't, we don't hold expected
|
inode = NULL;
|
||||||
* lookup semantics and we most noticeably break
|
} else {
|
||||||
* 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 */
|
/* must be a non-recoverable error */
|
||||||
res = ERR_PTR(ret);
|
inode = ERR_PTR(ret);
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
orangefs_set_timeout(dentry);
|
|
||||||
|
|
||||||
inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn);
|
|
||||||
if (IS_ERR(inode)) {
|
|
||||||
gossip_debug(GOSSIP_NAME_DEBUG,
|
|
||||||
"error %ld from iget\n", PTR_ERR(inode));
|
|
||||||
res = ERR_CAST(inode);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 */
|
||||||
|
|||||||
Reference in New Issue
Block a user