Fix write(2) returns zero bug from 933ec99

For generic_write_checks with 2 args, we can exit when it returns zero because
it means count is zero. However this is not the case for generic_write_checks
with 4 args, where zero means no error.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Haakan T Johansson <f96hajo@chalmers.se>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Closes #5720 
Closes #5726
This commit is contained in:
Chunwei Chen 2017-02-02 09:43:42 -08:00 committed by Brian Behlendorf
parent fc386db191
commit c7af63d62a

View File

@ -387,6 +387,8 @@ zpl_iter_write(struct kiocb *kiocb, struct iov_iter *from)
count = iov_iter_count(from); count = iov_iter_count(from);
ret = generic_write_checks(file, &kiocb->ki_pos, &count, isblk); ret = generic_write_checks(file, &kiocb->ki_pos, &count, isblk);
if (ret)
return (ret);
#else #else
/* /*
* XXX - ideally this check should be in the same lock region with * XXX - ideally this check should be in the same lock region with
@ -394,10 +396,10 @@ zpl_iter_write(struct kiocb *kiocb, struct iov_iter *from)
* append and someone else grow the file. * append and someone else grow the file.
*/ */
ret = generic_write_checks(kiocb, from); ret = generic_write_checks(kiocb, from);
count = ret;
#endif
if (ret <= 0) if (ret <= 0)
return (ret); return (ret);
count = ret;
#endif
if (from->type & ITER_KVEC) if (from->type & ITER_KVEC)
seg = UIO_SYSSPACE; seg = UIO_SYSSPACE;