[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160201191555.GA3524@pc.thejh.net>
Date: Mon, 1 Feb 2016 20:15:56 +0100
From: Jann Horn <jann@...jh.net>
To: Nikhilesh Reddy <reddyn@...eaurora.org>
Cc: torvalds@...ux-foundation.org, Miklos Szeredi <miklos@...redi.hu>,
fuse-devel <fuse-devel@...ts.sourceforge.net>,
linux-kernel@...r.kernel.org, linux-api@...r.kernel.org,
gregkh@...uxfoundation.org, linux-fsdevel@...r.kernel.org,
viro@...iv.linux.org.uk, Richard Weinberger <richard@....at>,
Theodore Ts'o <tytso@....edu>, jack@...e.cz,
Antonio SJ Musumeci <trapexit@...wn.link>, sven.utcke@....de,
Nikolaus Rath <nikolaus@...h.org>,
Jann Horn <jannhorn@...glemail.com>,
Mike Shal <marfey@...il.com>
Subject: Re: [PATCH v5] fuse: Add support for passthrough read/write
On Mon, Feb 01, 2016 at 10:56:27AM -0800, Nikhilesh Reddy wrote:
> diff --git a/fs/fuse/passthrough.c b/fs/fuse/passthrough.c
[...]
> +static ssize_t fuse_passthrough_read_write_iter(struct kiocb *iocb,
> + struct iov_iter *iter, int do_write)
> +{
> + ssize_t ret_val;
> + struct fuse_file *ff;
> + struct file *fuse_file, *passthrough_filp;
> + struct inode *fuse_inode, *passthrough_inode;
> +
> + ff = iocb->ki_filp->private_data;
> + fuse_file = iocb->ki_filp;
> + passthrough_filp = ff->passthrough_filp;
> +
> + /* lock passthrough file to prevent it from being released */
> + get_file(passthrough_filp);
> + iocb->ki_filp = passthrough_filp;
> + fuse_inode = fuse_file->f_path.dentry->d_inode;
> + passthrough_inode = file_inode(passthrough_filp);
> +
> + if (do_write) {
> + if (!passthrough_filp->f_op->write_iter)
> + return -EIO;
> + ret_val = passthrough_filp->f_op->write_iter(iocb, iter);
> +
> + if (ret_val >= 0 || ret_val == -EIOCBQUEUED) {
> + fsstack_copy_inode_size(fuse_inode, passthrough_inode);
> + fsstack_copy_attr_times(fuse_inode, passthrough_inode);
> + }
> + } else {
> + if (!passthrough_filp->f_op->read_iter)
> + return -EIO;
> + ret_val = passthrough_filp->f_op->read_iter(iocb, iter);
> + if (ret_val >= 0 || ret_val == -EIOCBQUEUED)
> + fsstack_copy_attr_atime(fuse_inode, passthrough_inode);
> + }
> +
> + iocb->ki_filp = fuse_file;
> +
> + /* unlock passthrough file */
> + fput(passthrough_filp);
Why the get_file() and fput() in this method? This doesn't look right. There
is no lock you're releasing between get_file() and fput(). What are they
intended for?
Download attachment "signature.asc" of type "application/pgp-signature" (820 bytes)
Powered by blists - more mailing lists