Skip to content

Commit

Permalink
fuse: clean up return in fuse_dentry_revalidate()
Browse files Browse the repository at this point in the history
On errors unrelated to the filesystem's state (ENOMEM, ENOTCONN) return the
error itself from ->d_revalidate() insted of returning zero (invalid).

Also make a common label for invalidating the dentry.  This will be used by
the next patch.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Miklos Szeredi authored and Al Viro committed Sep 5, 2013
1 parent 5835f33 commit e2a6b95
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,11 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
struct inode *inode;
struct dentry *parent;
struct fuse_conn *fc;
int ret;

inode = ACCESS_ONCE(entry->d_inode);
if (inode && is_bad_inode(inode))
return 0;
goto invalid;
else if (fuse_dentry_time(entry) < get_jiffies_64()) {
int err;
struct fuse_entry_out outarg;
Expand All @@ -195,20 +196,23 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)

/* For negative dentries, always do a fresh lookup */
if (!inode)
return 0;
goto invalid;

ret = -ECHILD;
if (flags & LOOKUP_RCU)
return -ECHILD;
goto out;

fc = get_fuse_conn(inode);
req = fuse_get_req_nopages(fc);
ret = PTR_ERR(req);
if (IS_ERR(req))
return 0;
goto out;

forget = fuse_alloc_forget();
if (!forget) {
fuse_put_request(fc, req);
return 0;
ret = -ENOMEM;
goto out;
}

attr_version = fuse_get_attr_version(fc);
Expand All @@ -227,15 +231,15 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
struct fuse_inode *fi = get_fuse_inode(inode);
if (outarg.nodeid != get_node_id(inode)) {
fuse_queue_forget(fc, forget, outarg.nodeid, 1);
return 0;
goto invalid;
}
spin_lock(&fc->lock);
fi->nlookup++;
spin_unlock(&fc->lock);
}
kfree(forget);
if (err || (outarg.attr.mode ^ inode->i_mode) & S_IFMT)
return 0;
goto invalid;

fuse_change_attributes(inode, &outarg.attr,
entry_attr_timeout(&outarg),
Expand All @@ -249,7 +253,13 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
dput(parent);
}
}
return 1;
ret = 1;
out:
return ret;

invalid:
ret = 0;
goto out;
}

static int invalid_nodeid(u64 nodeid)
Expand Down

0 comments on commit e2a6b95

Please sign in to comment.