Skip to content

Commit

Permalink
Fix write(2) returns zero bug from 933ec99
Browse files Browse the repository at this point in the history
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 openzfs#5720 
Closes openzfs#5726
  • Loading branch information
tuxoko authored and wli5 committed Feb 27, 2017
1 parent 24b9370 commit cdfc6bb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions module/zfs/zpl_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,17 +387,19 @@ zpl_iter_write(struct kiocb *kiocb, struct iov_iter *from)

count = iov_iter_count(from);
ret = generic_write_checks(file, &kiocb->ki_pos, &count, isblk);
if (ret)
return (ret);
#else
/*
* XXX - ideally this check should be in the same lock region with
* write operations, so that there's no TOCTTOU race when doing
* append and someone else grow the file.
*/
ret = generic_write_checks(kiocb, from);
count = ret;
#endif
if (ret <= 0)
return (ret);
count = ret;
#endif

if (from->type & ITER_KVEC)
seg = UIO_SYSSPACE;
Expand Down

0 comments on commit cdfc6bb

Please sign in to comment.