Commit 6b675738 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Miklos Szeredi

fuse: Protect ff->reserved_req via corresponding fi->lock

This is rather natural action after previous patches, and it just decreases
load of fc->lock.
Signed-off-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent c9d8f5f0
...@@ -251,17 +251,18 @@ static struct fuse_req *get_reserved_req(struct fuse_conn *fc, ...@@ -251,17 +251,18 @@ static struct fuse_req *get_reserved_req(struct fuse_conn *fc,
struct file *file) struct file *file)
{ {
struct fuse_req *req = NULL; struct fuse_req *req = NULL;
struct fuse_inode *fi = get_fuse_inode(file_inode(file));
struct fuse_file *ff = file->private_data; struct fuse_file *ff = file->private_data;
do { do {
wait_event(fc->reserved_req_waitq, ff->reserved_req); wait_event(fc->reserved_req_waitq, ff->reserved_req);
spin_lock(&fc->lock); spin_lock(&fi->lock);
if (ff->reserved_req) { if (ff->reserved_req) {
req = ff->reserved_req; req = ff->reserved_req;
ff->reserved_req = NULL; ff->reserved_req = NULL;
req->stolen_file = get_file(file); req->stolen_file = get_file(file);
} }
spin_unlock(&fc->lock); spin_unlock(&fi->lock);
} while (!req); } while (!req);
return req; return req;
...@@ -273,16 +274,17 @@ static struct fuse_req *get_reserved_req(struct fuse_conn *fc, ...@@ -273,16 +274,17 @@ static struct fuse_req *get_reserved_req(struct fuse_conn *fc,
static void put_reserved_req(struct fuse_conn *fc, struct fuse_req *req) static void put_reserved_req(struct fuse_conn *fc, struct fuse_req *req)
{ {
struct file *file = req->stolen_file; struct file *file = req->stolen_file;
struct fuse_inode *fi = get_fuse_inode(file_inode(file));
struct fuse_file *ff = file->private_data; struct fuse_file *ff = file->private_data;
WARN_ON(req->max_pages); WARN_ON(req->max_pages);
spin_lock(&fc->lock); spin_lock(&fi->lock);
memset(req, 0, sizeof(*req)); memset(req, 0, sizeof(*req));
fuse_request_init(req, NULL, NULL, 0); fuse_request_init(req, NULL, NULL, 0);
BUG_ON(ff->reserved_req); BUG_ON(ff->reserved_req);
ff->reserved_req = req; ff->reserved_req = req;
wake_up_all(&fc->reserved_req_waitq); wake_up_all(&fc->reserved_req_waitq);
spin_unlock(&fc->lock); spin_unlock(&fi->lock);
fput(file); fput(file);
} }
......
...@@ -166,7 +166,10 @@ struct fuse_file { ...@@ -166,7 +166,10 @@ struct fuse_file {
/** Fuse connection for this file */ /** Fuse connection for this file */
struct fuse_conn *fc; struct fuse_conn *fc;
/** Request reserved for flush and release */ /*
* Request reserved for flush and release.
* Modified under relative fuse_inode::lock.
*/
struct fuse_req *reserved_req; struct fuse_req *reserved_req;
/** Kernel file handle guaranteed to be unique */ /** Kernel file handle guaranteed to be unique */
......
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