Skip to content

Commit e2a6b95

Browse files
Miklos SzerediAl Viro
authored andcommitted
fuse: clean up return in fuse_dentry_revalidate()
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 <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 5835f33 commit e2a6b95

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

fs/fuse/dir.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,11 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
182182
struct inode *inode;
183183
struct dentry *parent;
184184
struct fuse_conn *fc;
185+
int ret;
185186

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

196197
/* For negative dentries, always do a fresh lookup */
197198
if (!inode)
198-
return 0;
199+
goto invalid;
199200

201+
ret = -ECHILD;
200202
if (flags & LOOKUP_RCU)
201-
return -ECHILD;
203+
goto out;
202204

203205
fc = get_fuse_conn(inode);
204206
req = fuse_get_req_nopages(fc);
207+
ret = PTR_ERR(req);
205208
if (IS_ERR(req))
206-
return 0;
209+
goto out;
207210

208211
forget = fuse_alloc_forget();
209212
if (!forget) {
210213
fuse_put_request(fc, req);
211-
return 0;
214+
ret = -ENOMEM;
215+
goto out;
212216
}
213217

214218
attr_version = fuse_get_attr_version(fc);
@@ -227,15 +231,15 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
227231
struct fuse_inode *fi = get_fuse_inode(inode);
228232
if (outarg.nodeid != get_node_id(inode)) {
229233
fuse_queue_forget(fc, forget, outarg.nodeid, 1);
230-
return 0;
234+
goto invalid;
231235
}
232236
spin_lock(&fc->lock);
233237
fi->nlookup++;
234238
spin_unlock(&fc->lock);
235239
}
236240
kfree(forget);
237241
if (err || (outarg.attr.mode ^ inode->i_mode) & S_IFMT)
238-
return 0;
242+
goto invalid;
239243

240244
fuse_change_attributes(inode, &outarg.attr,
241245
entry_attr_timeout(&outarg),
@@ -249,7 +253,13 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
249253
dput(parent);
250254
}
251255
}
252-
return 1;
256+
ret = 1;
257+
out:
258+
return ret;
259+
260+
invalid:
261+
ret = 0;
262+
goto out;
253263
}
254264

255265
static int invalid_nodeid(u64 nodeid)

0 commit comments

Comments
 (0)