All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikhilesh Reddy <reddyn-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
To: Jann Horn <jann-XZ1E9jl8jIdeoWH0uzbU5w@public.gmane.org>
Cc: torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org,
	Miklos Szeredi <miklos-sUDqSbJrdHQHWmgEVkV9KA@public.gmane.org>,
	fuse-devel
	<fuse-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org,
	Richard Weinberger <richard-/L3Ra7n9ekc@public.gmane.org>,
	Theodore Ts'o <tytso-3s7WtUTddSA@public.gmane.org>,
	jack-AlSwsSmVLrQ@public.gmane.org,
	Antonio SJ Musumeci
	<trapexit-wGTF+nt6ur047o9RxwvyTQ@public.gmane.org>,
	sven.utcke-Mmb7MZpHnFY@public.gmane.org,
	Nikolaus Rath <nikolaus-BTH8mxji4b0@public.gmane.org>,
	Jann Horn <jannhorn-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>,
	Mike Shal <marfey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH v5] fuse: Add support for passthrough read/write
Date: Wed, 03 Feb 2016 11:05:32 -0800	[thread overview]
Message-ID: <56B24F7C.4060703@codeaurora.org> (raw)
In-Reply-To: <20160201194526.GA11837-J1fxOzX/cBvk1uMJSBkQmQ@public.gmane.org>

On 02/01/2016 11:45 AM, Jann Horn wrote:
> On Mon, Feb 01, 2016 at 11:28:51AM -0800, Nikhilesh Reddy wrote:
>> On Mon 01 Feb 2016 11:15:56 AM PST, Jann Horn wrote:
>>> 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?
>>
>> Hi
>>
>> Thanks for reviewing the code.
>>
>> The passthrough file could be released under our feet say  if the userspace
>> fuse daemon crashed or was killed  ( while we are processing the read or the
>> write) causing bad things to happen.
>> The calls here are to increase the count temporarily  and then decrease it
>> so that we dont release in the middle of a write and everything is
>> gracefully handled...
>>
>> I have a comment right before the get_file call above saying the same thing.
>> Please let me know if you have any more questions.
>
> If that is the case, why can't the passthrough file be released before the
> get_file() call, e.g. while the core processing the filesystem read request
> is entering fuse_passthrough_read_write_iter()?
>
> As far as I can tell, you can drop the get_file() and fput() calls.
> fuse_setup_passthrough() already took a reference to the file for you, that
> reference can only be dropped in fuse_passthrough_release(), and the VFS
> ensures that no release call happens while a read or write is pending.
>
I just feel uncomfortable with dropping them. I thought they could be 
released ( i/o ) takes longer than the actual execution... but if i can 
be sure of it then maybe..

-- 
Thanks
Nikhilesh Reddy

Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

WARNING: multiple messages have this Message-ID (diff)
From: Nikhilesh Reddy <reddyn@codeaurora.org>
To: Jann Horn <jann@thejh.net>
Cc: torvalds@linux-foundation.org, Miklos Szeredi <miklos@szeredi.hu>,
	fuse-devel <fuse-devel@lists.sourceforge.net>,
	linux-kernel@vger.kernel.org, linux-api@vger.kernel.org,
	gregkh@linuxfoundation.org, linux-fsdevel@vger.kernel.org,
	viro@zeniv.linux.org.uk, Richard Weinberger <richard@nod.at>,
	Theodore Ts'o <tytso@mit.edu>,
	jack@suse.cz, Antonio SJ Musumeci <trapexit@spawn.link>,
	sven.utcke@gmx.de, Nikolaus Rath <nikolaus@rath.org>,
	Jann Horn <jannhorn@googlemail.com>, Mike Shal <marfey@gmail.com>
Subject: Re: [PATCH v5] fuse: Add support for passthrough read/write
Date: Wed, 03 Feb 2016 11:05:32 -0800	[thread overview]
Message-ID: <56B24F7C.4060703@codeaurora.org> (raw)
In-Reply-To: <20160201194526.GA11837@pc.thejh.net>

On 02/01/2016 11:45 AM, Jann Horn wrote:
> On Mon, Feb 01, 2016 at 11:28:51AM -0800, Nikhilesh Reddy wrote:
>> On Mon 01 Feb 2016 11:15:56 AM PST, Jann Horn wrote:
>>> 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?
>>
>> Hi
>>
>> Thanks for reviewing the code.
>>
>> The passthrough file could be released under our feet say  if the userspace
>> fuse daemon crashed or was killed  ( while we are processing the read or the
>> write) causing bad things to happen.
>> The calls here are to increase the count temporarily  and then decrease it
>> so that we dont release in the middle of a write and everything is
>> gracefully handled...
>>
>> I have a comment right before the get_file call above saying the same thing.
>> Please let me know if you have any more questions.
>
> If that is the case, why can't the passthrough file be released before the
> get_file() call, e.g. while the core processing the filesystem read request
> is entering fuse_passthrough_read_write_iter()?
>
> As far as I can tell, you can drop the get_file() and fput() calls.
> fuse_setup_passthrough() already took a reference to the file for you, that
> reference can only be dropped in fuse_passthrough_release(), and the VFS
> ensures that no release call happens while a read or write is pending.
>
I just feel uncomfortable with dropping them. I thought they could be 
released ( i/o ) takes longer than the actual execution... but if i can 
be sure of it then maybe..

-- 
Thanks
Nikhilesh Reddy

Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

  parent reply	other threads:[~2016-02-03 19:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-01 18:56 [PATCH v5] fuse: Add support for passthrough read/write Nikhilesh Reddy
     [not found] ` <56AFAA5B.3000006-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-02-01 19:15   ` Jann Horn
2016-02-01 19:15     ` Jann Horn
     [not found]     ` <20160201191555.GA3524-J1fxOzX/cBvk1uMJSBkQmQ@public.gmane.org>
2016-02-01 19:28       ` Nikhilesh Reddy
2016-02-01 19:28         ` Nikhilesh Reddy
2016-02-01 19:45         ` Jann Horn
     [not found]           ` <20160201194526.GA11837-J1fxOzX/cBvk1uMJSBkQmQ@public.gmane.org>
2016-02-03 19:05             ` Nikhilesh Reddy [this message]
2016-02-03 19:05               ` Nikhilesh Reddy
2016-02-03 19:56               ` Jann Horn
2016-03-04 12:23   ` [fuse-devel] " Andrew Karpow
2016-03-04 12:23     ` Andrew Karpow
2016-03-04 12:23     ` Andrew Karpow
2016-02-02  8:10 ` Jann Horn
     [not found]   ` <20160202081035.GA18246-J1fxOzX/cBvk1uMJSBkQmQ@public.gmane.org>
2016-02-03 19:05     ` Nikhilesh Reddy
2016-02-03 19:05       ` Nikhilesh Reddy
2016-02-03 19:53       ` Jann Horn
2016-02-03 20:16         ` Nikhilesh Reddy
2016-02-03 20:42           ` Jann Horn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56B24F7C.4060703@codeaurora.org \
    --to=reddyn-sgv2jx0feol9jmxxk+q4oq@public.gmane.org \
    --cc=fuse-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=jack-AlSwsSmVLrQ@public.gmane.org \
    --cc=jann-XZ1E9jl8jIdeoWH0uzbU5w@public.gmane.org \
    --cc=jannhorn-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org \
    --cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=marfey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=miklos-sUDqSbJrdHQHWmgEVkV9KA@public.gmane.org \
    --cc=nikolaus-BTH8mxji4b0@public.gmane.org \
    --cc=richard-/L3Ra7n9ekc@public.gmane.org \
    --cc=sven.utcke-Mmb7MZpHnFY@public.gmane.org \
    --cc=torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=trapexit-wGTF+nt6ur047o9RxwvyTQ@public.gmane.org \
    --cc=tytso-3s7WtUTddSA@public.gmane.org \
    --cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.