Commit 6b2db28a authored by Tejun Heo's avatar Tejun Heo Committed by Miklos Szeredi

fuse: misc cleanups

* fuse_file_alloc() was structured in weird way.  The success path was
  split between else block and code following the block.  Restructure
  the code such that it's easier to read and modify.

* Unindent success path of fuse_release_common() to ease future
  changes.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
parent fd9db729
...@@ -49,22 +49,26 @@ static int fuse_send_open(struct inode *inode, struct file *file, int isdir, ...@@ -49,22 +49,26 @@ static int fuse_send_open(struct inode *inode, struct file *file, int isdir,
struct fuse_file *fuse_file_alloc(struct fuse_conn *fc) struct fuse_file *fuse_file_alloc(struct fuse_conn *fc)
{ {
struct fuse_file *ff; struct fuse_file *ff;
ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL); ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL);
if (ff) { if (unlikely(!ff))
return NULL;
ff->reserved_req = fuse_request_alloc(); ff->reserved_req = fuse_request_alloc();
if (!ff->reserved_req) { if (unlikely(!ff->reserved_req)) {
kfree(ff); kfree(ff);
return NULL; return NULL;
} else { }
INIT_LIST_HEAD(&ff->write_entry); INIT_LIST_HEAD(&ff->write_entry);
atomic_set(&ff->count, 0); atomic_set(&ff->count, 0);
RB_CLEAR_NODE(&ff->polled_node);
init_waitqueue_head(&ff->poll_wait);
spin_lock(&fc->lock); spin_lock(&fc->lock);
ff->kh = ++fc->khctr; ff->kh = ++fc->khctr;
spin_unlock(&fc->lock); spin_unlock(&fc->lock);
}
RB_CLEAR_NODE(&ff->polled_node);
init_waitqueue_head(&ff->poll_wait);
}
return ff; return ff;
} }
...@@ -158,10 +162,16 @@ void fuse_release_fill(struct fuse_file *ff, u64 nodeid, int flags, int opcode) ...@@ -158,10 +162,16 @@ void fuse_release_fill(struct fuse_file *ff, u64 nodeid, int flags, int opcode)
int fuse_release_common(struct inode *inode, struct file *file, int isdir) int fuse_release_common(struct inode *inode, struct file *file, int isdir)
{ {
struct fuse_file *ff = file->private_data; struct fuse_conn *fc;
if (ff) { struct fuse_file *ff;
struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_req *req;
struct fuse_req *req = ff->reserved_req;
ff = file->private_data;
if (unlikely(!ff))
return 0; /* return value is ignored by VFS */
fc = get_fuse_conn(inode);
req = ff->reserved_req;
fuse_release_fill(ff, get_node_id(inode), file->f_flags, fuse_release_fill(ff, get_node_id(inode), file->f_flags,
isdir ? FUSE_RELEASEDIR : FUSE_RELEASE); isdir ? FUSE_RELEASEDIR : FUSE_RELEASE);
...@@ -178,14 +188,11 @@ int fuse_release_common(struct inode *inode, struct file *file, int isdir) ...@@ -178,14 +188,11 @@ int fuse_release_common(struct inode *inode, struct file *file, int isdir)
wake_up_interruptible_sync(&ff->poll_wait); wake_up_interruptible_sync(&ff->poll_wait);
/* /*
* Normally this will send the RELEASE request, * Normally this will send the RELEASE request, however if
* however if some asynchronous READ or WRITE requests * some asynchronous READ or WRITE requests are outstanding,
* are outstanding, the sending will be delayed * the sending will be delayed.
*/ */
fuse_file_put(ff); fuse_file_put(ff);
}
/* Return value is ignored by VFS */
return 0; return 0;
} }
......
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