Skip to content

Commit

Permalink
fuse: optimize fallocate on permanent failure
Browse files Browse the repository at this point in the history
If userspace filesystem doesn't support fallocate, remember this and don't send
request next time.

Signed-off-by: Miklos Szeredi <[email protected]>
  • Loading branch information
Miklos Szeredi committed Apr 26, 2012
1 parent 05ba1f0 commit 519c604
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,9 @@ long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
};
int err;

if (fc->no_fallocate)
return -EOPNOTSUPP;

req = fuse_get_req(fc);
if (IS_ERR(req))
return PTR_ERR(req);
Expand All @@ -2196,6 +2199,10 @@ long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
req->in.args[0].value = &inarg;
fuse_request_send(fc, req);
err = req->out.h.error;
if (err == -ENOSYS) {
fc->no_fallocate = 1;
err = -EOPNOTSUPP;
}
fuse_put_request(fc, req);

return err;
Expand Down
3 changes: 3 additions & 0 deletions fs/fuse/fuse_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ struct fuse_conn {
/** Are BSD file locking primitives not implemented by fs? */
unsigned no_flock:1;

/** Is fallocate not implemented by fs? */
unsigned no_fallocate:1;

/** The number of requests waiting for completion */
atomic_t num_waiting;

Expand Down

0 comments on commit 519c604

Please sign in to comment.