blk-merge: warn if figured out segment number is bigger than nr_phys_segments
authorMing Lei <ming.lei@canonical.com>
Tue, 24 Nov 2015 02:35:31 +0000 (10:35 +0800)
committerJens Axboe <axboe@fb.com>
Tue, 24 Nov 2015 03:16:55 +0000 (20:16 -0700)
We had seen lots of reports of this kind issue, so add one
warnning in blk-merge, then it can be triggered easily and
avoid to depend on warning/bug from drivers.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-merge.c

index 50793cdc53314d5b0da41639cb804c6029918a81..41a55ba0d78e8a97b5707a9194cce3b6ebd1c811 100644 (file)
@@ -428,6 +428,12 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq,
        if (sg)
                sg_mark_end(sg);
 
+       /*
+        * Something must have been wrong if the figured number of
+        * segment is bigger than number of req's physical segments
+        */
+       WARN_ON(nsegs > rq->nr_phys_segments);
+
        return nsegs;
 }
 EXPORT_SYMBOL(blk_rq_map_sg);