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 <[email protected]>
Reviewed-by: Haakan T Johansson <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Closes openzfs#5720 
Closes openzfs#5726
  • Loading branch information
tuxoko authored and behlendorf committed Feb 2, 2017
1 parent 82c29b1 commit 9c6dd14
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 9c6dd14

Please sign in to comment.