Commit 4e66c42c authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse

Pull fuse update from Miklos Szeredi:
 "A bugfix and cleanups"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse:
  fuse: release: private_data cannot be NULL
  fuse: cleanup fuse_file refcounting
  fuse: add missing FR_FORCE
parents e58bc927 9a87ad3d
...@@ -473,7 +473,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, ...@@ -473,7 +473,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry,
if (err) { if (err) {
fuse_sync_release(ff, flags); fuse_sync_release(ff, flags);
} else { } else {
file->private_data = fuse_file_get(ff); file->private_data = ff;
fuse_finish_open(inode, file); fuse_finish_open(inode, file);
} }
return err; return err;
......
...@@ -58,7 +58,7 @@ struct fuse_file *fuse_file_alloc(struct fuse_conn *fc) ...@@ -58,7 +58,7 @@ struct fuse_file *fuse_file_alloc(struct fuse_conn *fc)
} }
INIT_LIST_HEAD(&ff->write_entry); INIT_LIST_HEAD(&ff->write_entry);
atomic_set(&ff->count, 0); atomic_set(&ff->count, 1);
RB_CLEAR_NODE(&ff->polled_node); RB_CLEAR_NODE(&ff->polled_node);
init_waitqueue_head(&ff->poll_wait); init_waitqueue_head(&ff->poll_wait);
...@@ -75,7 +75,7 @@ void fuse_file_free(struct fuse_file *ff) ...@@ -75,7 +75,7 @@ void fuse_file_free(struct fuse_file *ff)
kfree(ff); kfree(ff);
} }
struct fuse_file *fuse_file_get(struct fuse_file *ff) static struct fuse_file *fuse_file_get(struct fuse_file *ff)
{ {
atomic_inc(&ff->count); atomic_inc(&ff->count);
return ff; return ff;
...@@ -100,6 +100,7 @@ static void fuse_file_put(struct fuse_file *ff, bool sync) ...@@ -100,6 +100,7 @@ static void fuse_file_put(struct fuse_file *ff, bool sync)
iput(req->misc.release.inode); iput(req->misc.release.inode);
fuse_put_request(ff->fc, req); fuse_put_request(ff->fc, req);
} else if (sync) { } else if (sync) {
__set_bit(FR_FORCE, &req->flags);
__clear_bit(FR_BACKGROUND, &req->flags); __clear_bit(FR_BACKGROUND, &req->flags);
fuse_request_send(ff->fc, req); fuse_request_send(ff->fc, req);
iput(req->misc.release.inode); iput(req->misc.release.inode);
...@@ -146,7 +147,7 @@ int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file, ...@@ -146,7 +147,7 @@ int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file,
ff->open_flags &= ~FOPEN_DIRECT_IO; ff->open_flags &= ~FOPEN_DIRECT_IO;
ff->nodeid = nodeid; ff->nodeid = nodeid;
file->private_data = fuse_file_get(ff); file->private_data = ff;
return 0; return 0;
} }
...@@ -245,14 +246,9 @@ static void fuse_prepare_release(struct fuse_file *ff, int flags, int opcode) ...@@ -245,14 +246,9 @@ static void fuse_prepare_release(struct fuse_file *ff, int flags, int opcode)
void fuse_release_common(struct file *file, int opcode) void fuse_release_common(struct file *file, int opcode)
{ {
struct fuse_file *ff; struct fuse_file *ff = file->private_data;
struct fuse_req *req; struct fuse_req *req = ff->reserved_req;
ff = file->private_data;
if (unlikely(!ff))
return;
req = ff->reserved_req;
fuse_prepare_release(ff, file->f_flags, opcode); fuse_prepare_release(ff, file->f_flags, opcode);
if (ff->flock) { if (ff->flock) {
...@@ -297,13 +293,13 @@ static int fuse_release(struct inode *inode, struct file *file) ...@@ -297,13 +293,13 @@ static int fuse_release(struct inode *inode, struct file *file)
void fuse_sync_release(struct fuse_file *ff, int flags) void fuse_sync_release(struct fuse_file *ff, int flags)
{ {
WARN_ON(atomic_read(&ff->count) > 1); WARN_ON(atomic_read(&ff->count) != 1);
fuse_prepare_release(ff, flags, FUSE_RELEASE); fuse_prepare_release(ff, flags, FUSE_RELEASE);
__set_bit(FR_FORCE, &ff->reserved_req->flags); /*
__clear_bit(FR_BACKGROUND, &ff->reserved_req->flags); * iput(NULL) is a no-op and since the refcount is 1 and everything's
fuse_request_send(ff->fc, ff->reserved_req); * synchronous, we are fine with not doing igrab() here"
fuse_put_request(ff->fc, ff->reserved_req); */
kfree(ff); fuse_file_put(ff, true);
} }
EXPORT_SYMBOL_GPL(fuse_sync_release); EXPORT_SYMBOL_GPL(fuse_sync_release);
......
...@@ -732,7 +732,6 @@ void fuse_read_fill(struct fuse_req *req, struct file *file, ...@@ -732,7 +732,6 @@ void fuse_read_fill(struct fuse_req *req, struct file *file,
int fuse_open_common(struct inode *inode, struct file *file, bool isdir); int fuse_open_common(struct inode *inode, struct file *file, bool isdir);
struct fuse_file *fuse_file_alloc(struct fuse_conn *fc); struct fuse_file *fuse_file_alloc(struct fuse_conn *fc);
struct fuse_file *fuse_file_get(struct fuse_file *ff);
void fuse_file_free(struct fuse_file *ff); void fuse_file_free(struct fuse_file *ff);
void fuse_finish_open(struct inode *inode, struct file *file); void fuse_finish_open(struct inode *inode, struct file *file);
......
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