block: fix partial zone append completion handling in req_bio_endio()
[linux-2.6-microblaze.git] / block / blk-mq.c
index fb29ff5..aa9a05f 100644 (file)
@@ -772,11 +772,16 @@ static void req_bio_endio(struct request *rq, struct bio *bio,
                /*
                 * Partial zone append completions cannot be supported as the
                 * BIO fragments may end up not being written sequentially.
+                * For such case, force the completed nbytes to be equal to
+                * the BIO size so that bio_advance() sets the BIO remaining
+                * size to 0 and we end up calling bio_endio() before returning.
                 */
-               if (bio->bi_iter.bi_size != nbytes)
+               if (bio->bi_iter.bi_size != nbytes) {
                        bio->bi_status = BLK_STS_IOERR;
-               else
+                       nbytes = bio->bi_iter.bi_size;
+               } else {
                        bio->bi_iter.bi_sector = rq->__sector;
+               }
        }
 
        bio_advance(bio, nbytes);