Skip to content

Commit

Permalink
fs: fix lost error code in dio_complete
Browse files Browse the repository at this point in the history
commit e259221 ("fs: simplify the
generic_write_sync prototype") reworked callers of generic_write_sync(),
and ended up dropping the error return for the directio path. Prior to
that commit, in dio_complete(), an error would be bubbled up the stack,
but after that commit, errors passed on to dio_complete were eaten up.

This was reported on the list earlier, and a fix was proposed in
https://lore.kernel.org/lkml/[email protected]/, but
never followed up with.  We recently hit this bug in our testing where
fencing io errors, which were previously erroring out with EIO, were
being returned as success operations after this commit.

The fix proposed on the list earlier was a little short -- it would have
still called generic_write_sync() in case `ret` already contained an
error. This fix ensures generic_write_sync() is only called when there's
no pending error in the write. Additionally, transferred is replaced
with ret to bring this code in line with other callers.

Fixes: e259221 ("fs: simplify the generic_write_sync prototype")
Reported-by: Ravi Nankani <[email protected]>
Signed-off-by: Maximilian Heyne <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
CC: Torsten Mehlan <[email protected]>
CC: Uwe Dannowski <[email protected]>
CC: Amit Shah <[email protected]>
CC: David Woodhouse <[email protected]>
CC: [email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
heynemax authored and axboe committed Nov 30, 2018
1 parent 14b0406 commit 41e817b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/direct-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ static ssize_t dio_complete(struct dio *dio, ssize_t ret, unsigned int flags)
*/
dio->iocb->ki_pos += transferred;

if (dio->op == REQ_OP_WRITE)
ret = generic_write_sync(dio->iocb, transferred);
if (ret > 0 && dio->op == REQ_OP_WRITE)
ret = generic_write_sync(dio->iocb, ret);
dio->iocb->ki_complete(dio->iocb, ret, 0);
}

Expand Down

0 comments on commit 41e817b

Please sign in to comment.