Skip to content

Commit 748dc0b

Browse files
damien-lemoalaxboe
authored andcommitted
block: fix partial zone append completion handling in req_bio_endio()
Partial completions of zone append request is not allowed but if a zone append completion indicates a number of completed bytes different from the original BIO size, only the BIO status is set to error. This leads to bio_advance() not setting the BIO size to 0 and thus to not call bio_endio() at the end of req_bio_endio(). Make sure a partially completed zone append is failed and completed immediately by forcing the completed number of bytes (nbytes) to be equal to the BIO size, thus ensuring that bio_endio() is called. Fixes: 297db73 ("block: fix req_bio_endio append error handling") Cc: stable@kernel.vger.org Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Link: https://lore.kernel.org/r/20240110092942.442334-1-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 742e324 commit 748dc0b

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

block/blk-mq.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,11 +772,16 @@ static void req_bio_endio(struct request *rq, struct bio *bio,
772772
/*
773773
* Partial zone append completions cannot be supported as the
774774
* BIO fragments may end up not being written sequentially.
775+
* For such case, force the completed nbytes to be equal to
776+
* the BIO size so that bio_advance() sets the BIO remaining
777+
* size to 0 and we end up calling bio_endio() before returning.
775778
*/
776-
if (bio->bi_iter.bi_size != nbytes)
779+
if (bio->bi_iter.bi_size != nbytes) {
777780
bio->bi_status = BLK_STS_IOERR;
778-
else
781+
nbytes = bio->bi_iter.bi_size;
782+
} else {
779783
bio->bi_iter.bi_sector = rq->__sector;
784+
}
780785
}
781786

782787
bio_advance(bio, nbytes);

0 commit comments

Comments
 (0)