Skip to content

Commit a89afe5

Browse files
JasonYanHwaxboe
authored andcommitted
block: fix the return errno for direct IO
If the last bio returned is not dio->bio, the status of the bio will not assigned to dio->bio if it is error. This will cause the whole IO status wrong. ksoftirqd/21-117 [021] ..s. 4017.966090: 8,0 C N 4883648 [0] <idle>-0 [018] ..s. 4017.970888: 8,0 C WS 4924800 + 1024 [0] <idle>-0 [018] ..s. 4017.970909: 8,0 D WS 4935424 + 1024 [<idle>] <idle>-0 [018] ..s. 4017.970924: 8,0 D WS 4936448 + 321 [<idle>] ksoftirqd/21-117 [021] ..s. 4017.995033: 8,0 C R 4883648 + 336 [65475] ksoftirqd/21-117 [021] d.s. 4018.001988: myprobe1: (blkdev_bio_end_io+0x0/0x168) bi_status=7 ksoftirqd/21-117 [021] d.s. 4018.001992: myprobe: (aio_complete_rw+0x0/0x148) x0=0xffff802f2595ad80 res=0x12a000 res2=0x0 We always have to assign bio->bi_status to dio->bio.bi_status because we will only check dio->bio.bi_status when we return the whole IO to the upper layer. Fixes: 542ff7b ("block: new direct I/O implementation") Cc: [email protected] Cc: Christoph Hellwig <[email protected]> Cc: Jens Axboe <[email protected]> Reviewed-by: Ming Lei <[email protected]> Signed-off-by: Jason Yan <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent c0c14e9 commit a89afe5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/block_dev.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,10 @@ static void blkdev_bio_end_io(struct bio *bio)
307307
struct blkdev_dio *dio = bio->bi_private;
308308
bool should_dirty = dio->should_dirty;
309309

310-
if (dio->multi_bio && !atomic_dec_and_test(&dio->ref)) {
311-
if (bio->bi_status && !dio->bio.bi_status)
312-
dio->bio.bi_status = bio->bi_status;
313-
} else {
310+
if (bio->bi_status && !dio->bio.bi_status)
311+
dio->bio.bi_status = bio->bi_status;
312+
313+
if (!dio->multi_bio || atomic_dec_and_test(&dio->ref)) {
314314
if (!dio->is_sync) {
315315
struct kiocb *iocb = dio->iocb;
316316
ssize_t ret;

0 commit comments

Comments
 (0)