[PATCH] fuse: Do not mask return value from fuse_direct_io for partially valid data

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] fuse: Do not mask return value from fuse_direct_io for partially valid data

Ashish Samant
If a user calls writev/readv in direct io mode with partially valid data
in the iovec array such that any iovec other than the first one in the
array contains invalid data, we currently return the error for the invalid
iovec.

Instead, we should return the number of bytes already written/read and not
the error as we do in the non direct_io case.

Reported-by: Alexey Kodanev <[hidden email]>
Signed-off-by: Ashish Samant <[hidden email]>
---
 fs/fuse/file.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index b03d253..f135008 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1333,10 +1333,8 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
  fl_owner_t owner = current->files;
  size_t nbytes = min(count, nmax);
  int err = fuse_get_user_pages(req, iter, &nbytes, write);
- if (err) {
- res = err;
+ if (err)
  break;
- }
 
  if (write)
  nres = fuse_send_write(req, io, pos, nbytes, owner);
@@ -1374,7 +1372,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
  if (res > 0)
  *ppos = pos;
 
- return res;
+ return res > 0 ? res : err;
 }
 EXPORT_SYMBOL_GPL(fuse_direct_io);
 
--
1.9.1


------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] fuse: Do not mask return value from fuse_direct_io for partially valid data

Miklos Szeredi
On Wed, Mar 09, 2016 at 10:57:51AM -0800, Ashish Samant wrote:
> If a user calls writev/readv in direct io mode with partially valid data
> in the iovec array such that any iovec other than the first one in the
> array contains invalid data, we currently return the error for the invalid
> iovec.
>
> Instead, we should return the number of bytes already written/read and not
> the error as we do in the non direct_io case.

Okay, the patch looks good in theory.  Except it doesn't compile.

It would be good to know that you at least tried to compile the patch before
sending it and preferably even test out the functionality and that it fixes the
bug (see also Documentations/SubmitChecklist filtered with common sense).

Thanks,
Miklos

>
> Reported-by: Alexey Kodanev <[hidden email]>
> Signed-off-by: Ashish Samant <[hidden email]>
> ---
>  fs/fuse/file.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index b03d253..f135008 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -1333,10 +1333,8 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
>   fl_owner_t owner = current->files;
>   size_t nbytes = min(count, nmax);
>   int err = fuse_get_user_pages(req, iter, &nbytes, write);
> - if (err) {
> - res = err;
> + if (err)
>   break;
> - }
>  
>   if (write)
>   nres = fuse_send_write(req, io, pos, nbytes, owner);
> @@ -1374,7 +1372,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
>   if (res > 0)
>   *ppos = pos;
>  
> - return res;
> + return res > 0 ? res : err;
>  }
>  EXPORT_SYMBOL_GPL(fuse_direct_io);
>  
> --
> 1.9.1
>

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] fuse: Do not mask return value from fuse_direct_io for partially valid data

Ashish Samant


On 03/14/2016 09:47 AM, Miklos Szeredi wrote:
> On Wed, Mar 09, 2016 at 10:57:51AM -0800, Ashish Samant wrote:
>> If a user calls writev/readv in direct io mode with partially valid data
>> in the iovec array such that any iovec other than the first one in the
>> array contains invalid data, we currently return the error for the invalid
>> iovec.
>>
>> Instead, we should return the number of bytes already written/read and not
>> the error as we do in the non direct_io case.
> Okay, the patch looks good in theory.  Except it doesn't compile.
Oops. Sorry about that. It is because err is defined in the while loop
and I was using it outside the loop.
>
> It would be good to know that you at least tried to compile the patch before
> sending it and preferably even test out the functionality and that it fixes the
> bug (see also Documentations/SubmitChecklist filtered with common sense).
Yes, I did compile and test a slightly different version of the patch
before sending it out and it does fix the bug. I will send v2.

Thanks,
Ashish

>
> Thanks,
> Miklos
>
>> Reported-by: Alexey Kodanev <[hidden email]>
>> Signed-off-by: Ashish Samant <[hidden email]>
>> ---
>>   fs/fuse/file.c | 6 ++----
>>   1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
>> index b03d253..f135008 100644
>> --- a/fs/fuse/file.c
>> +++ b/fs/fuse/file.c
>> @@ -1333,10 +1333,8 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
>>   fl_owner_t owner = current->files;
>>   size_t nbytes = min(count, nmax);
>>   int err = fuse_get_user_pages(req, iter, &nbytes, write);
>> - if (err) {
>> - res = err;
>> + if (err)
>>   break;
>> - }
>>  
>>   if (write)
>>   nres = fuse_send_write(req, io, pos, nbytes, owner);
>> @@ -1374,7 +1372,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
>>   if (res > 0)
>>   *ppos = pos;
>>  
>> - return res;
>> + return res > 0 ? res : err;
>>   }
>>   EXPORT_SYMBOL_GPL(fuse_direct_io);
>>  
>> --
>> 1.9.1
>>


------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel