Commit c500ebaa authored by Miklos Szeredi's avatar Miklos Szeredi

fuse: convert flush to simple api

Add 'force' to fuse_args and use fuse_get_req_nofail_nopages() to allocate
the request in that case.
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent 40ac7ab2
...@@ -255,7 +255,7 @@ EXPORT_SYMBOL_GPL(fuse_get_req_for_background); ...@@ -255,7 +255,7 @@ EXPORT_SYMBOL_GPL(fuse_get_req_for_background);
* filesystem should not have it's own file open. If deadlock is * filesystem should not have it's own file open. If deadlock is
* intentional, it can still be broken by "aborting" the filesystem. * intentional, it can still be broken by "aborting" the filesystem.
*/ */
struct fuse_req *fuse_get_req_nofail_nopages(struct fuse_conn *fc) static struct fuse_req *fuse_get_req_nofail_nopages(struct fuse_conn *fc)
{ {
struct fuse_req *req; struct fuse_req *req;
...@@ -570,9 +570,14 @@ ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args) ...@@ -570,9 +570,14 @@ ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args)
struct fuse_req *req; struct fuse_req *req;
ssize_t ret; ssize_t ret;
if (args->force) {
req = fuse_get_req_nofail_nopages(fc);
__set_bit(FR_FORCE, &req->flags);
} else {
req = fuse_get_req(fc, 0); req = fuse_get_req(fc, 0);
if (IS_ERR(req)) if (IS_ERR(req))
return PTR_ERR(req); return PTR_ERR(req);
}
/* Needs to be done after fuse_get_req() so that fc->minor is valid */ /* Needs to be done after fuse_get_req() so that fc->minor is valid */
fuse_adjust_compat(fc, args); fuse_adjust_compat(fc, args);
......
...@@ -410,8 +410,8 @@ static int fuse_flush(struct file *file, fl_owner_t id) ...@@ -410,8 +410,8 @@ static int fuse_flush(struct file *file, fl_owner_t id)
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_file *ff = file->private_data; struct fuse_file *ff = file->private_data;
struct fuse_req *req;
struct fuse_flush_in inarg; struct fuse_flush_in inarg;
FUSE_ARGS(args);
int err; int err;
if (is_bad_inode(inode)) if (is_bad_inode(inode))
...@@ -432,19 +432,17 @@ static int fuse_flush(struct file *file, fl_owner_t id) ...@@ -432,19 +432,17 @@ static int fuse_flush(struct file *file, fl_owner_t id)
if (err) if (err)
return err; return err;
req = fuse_get_req_nofail_nopages(fc);
memset(&inarg, 0, sizeof(inarg)); memset(&inarg, 0, sizeof(inarg));
inarg.fh = ff->fh; inarg.fh = ff->fh;
inarg.lock_owner = fuse_lock_owner_id(fc, id); inarg.lock_owner = fuse_lock_owner_id(fc, id);
req->in.h.opcode = FUSE_FLUSH; args.opcode = FUSE_FLUSH;
req->in.h.nodeid = get_node_id(inode); args.nodeid = get_node_id(inode);
req->in.numargs = 1; args.in_numargs = 1;
req->in.args[0].size = sizeof(inarg); args.in_args[0].size = sizeof(inarg);
req->in.args[0].value = &inarg; args.in_args[0].value = &inarg;
__set_bit(FR_FORCE, &req->flags); args.force = true;
fuse_request_send(fc, req);
err = req->out.h.error; err = fuse_simple_request(fc, &args);
fuse_put_request(fc, req);
if (err == -ENOSYS) { if (err == -ENOSYS) {
fc->no_flush = 1; fc->no_flush = 1;
err = 0; err = 0;
......
...@@ -291,6 +291,7 @@ struct fuse_args { ...@@ -291,6 +291,7 @@ struct fuse_args {
uint32_t opcode; uint32_t opcode;
unsigned short in_numargs; unsigned short in_numargs;
unsigned short out_numargs; unsigned short out_numargs;
bool force:1;
bool out_argvar:1; bool out_argvar:1;
struct fuse_in_arg in_args[3]; struct fuse_in_arg in_args[3];
struct fuse_arg out_args[2]; struct fuse_arg out_args[2];
...@@ -919,11 +920,6 @@ struct fuse_req *fuse_get_req_for_background(struct fuse_conn *fc, ...@@ -919,11 +920,6 @@ struct fuse_req *fuse_get_req_for_background(struct fuse_conn *fc,
*/ */
void __fuse_get_request(struct fuse_req *req); void __fuse_get_request(struct fuse_req *req);
/**
* Gets a requests for a file operation, always succeeds
*/
struct fuse_req *fuse_get_req_nofail_nopages(struct fuse_conn *fc);
/** /**
* Decrement reference count of a request. If count goes to zero free * Decrement reference count of a request. If count goes to zero free
* the request. * the request.
......
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