Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+44 −37
Original line number Diff line number Diff line
@@ -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 *ff;

	ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL);
	if (ff) {
	if (unlikely(!ff))
		return NULL;

	ff->reserved_req = fuse_request_alloc();
		if (!ff->reserved_req) {
	if (unlikely(!ff->reserved_req)) {
		kfree(ff);
		return NULL;
		} else {
	}

	INIT_LIST_HEAD(&ff->write_entry);
	atomic_set(&ff->count, 0);
	RB_CLEAR_NODE(&ff->polled_node);
	init_waitqueue_head(&ff->poll_wait);

	spin_lock(&fc->lock);
	ff->kh = ++fc->khctr;
	spin_unlock(&fc->lock);
		}
		RB_CLEAR_NODE(&ff->polled_node);
		init_waitqueue_head(&ff->poll_wait);
	}

	return ff;
}

@@ -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)
{
	struct fuse_file *ff = file->private_data;
	if (ff) {
		struct fuse_conn *fc = get_fuse_conn(inode);
		struct fuse_req *req = ff->reserved_req;
	struct fuse_conn *fc;
	struct fuse_file *ff;
	struct fuse_req *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,
			  isdir ? FUSE_RELEASEDIR : FUSE_RELEASE);
@@ -178,14 +188,11 @@ int fuse_release_common(struct inode *inode, struct file *file, int isdir)

	wake_up_interruptible_sync(&ff->poll_wait);
	/*
		 * Normally this will send the RELEASE request,
		 * however if some asynchronous READ or WRITE requests
		 * are outstanding, the sending will be delayed
	 * Normally this will send the RELEASE request, however if
	 * some asynchronous READ or WRITE requests are outstanding,
	 * the sending will be delayed.
	 */
	fuse_file_put(ff);
	}

	/* Return value is ignored by VFS */
	return 0;
}