summaryrefslogtreecommitdiff
path: root/block/blk-core.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-05-09 04:33:56 +0300
committerJens Axboe <axboe@kernel.dk>2018-05-14 22:16:13 +0300
commit0ba99ca4838bc75481a4bf0e70bad20b0a5457c7 (patch)
treeb39b4f4fe72a4b4ff1016a512d40998dfb1d595c /block/blk-core.c
parent6e6e811d747bfe40228dc72309450803ef74d380 (diff)
downloadlinux-0ba99ca4838bc75481a4bf0e70bad20b0a5457c7.tar.xz
block: Add warning for bi_next not NULL in bio_endio()
Recently found a bug where a driver left bi_next not NULL and then called bio_endio(), and then the submitter of the bio used bio_copy_data() which was treating src and dst as lists of bios. Fixed that bug by splitting out bio_list_copy_data(), but in case other things are depending on bi_next in weird ways, add a warning to help avoid more bugs like that in the future. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-core.c')
-rw-r--r--block/blk-core.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index b431558f39bc..43370faee935 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -279,6 +279,10 @@ static void req_bio_endio(struct request *rq, struct bio *bio,
bio_advance(bio, nbytes);
/* don't actually finish bio if it's part of flush sequence */
+ /*
+ * XXX this code looks suspicious - it's not consistent with advancing
+ * req->bio in caller
+ */
if (bio->bi_iter.bi_size == 0 && !(rq->rq_flags & RQF_FLUSH_SEQ))
bio_endio(bio);
}
@@ -3083,8 +3087,10 @@ bool blk_update_request(struct request *req, blk_status_t error,
struct bio *bio = req->bio;
unsigned bio_bytes = min(bio->bi_iter.bi_size, nr_bytes);
- if (bio_bytes == bio->bi_iter.bi_size)
+ if (bio_bytes == bio->bi_iter.bi_size) {
req->bio = bio->bi_next;
+ bio->bi_next = NULL;
+ }
/* Completion has already been traced */
bio_clear_flag(bio, BIO_TRACE_COMPLETION);