VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
author: David Jeffery <djeffery@redhat.com> 2021-02-11 09:38:07 -0500 committer: Jens Axboe <axboe@kernel.dk> 2021-03-23 10:39:57 -0600 commit: a958937ff166fc60d1c3a721036f6ff41bfa2821 parent: 5116784039f0421e9a619023cfba3e302c3d9adc
Commit Summary:
block: recalculate segment count for multi-segment discards correctly
Diffstat:
1 file changed, 7 insertions, 0 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c
index ffb4aa0ea68b..4d97fb6dd226 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -382,6 +382,14 @@ unsigned int blk_recalc_rq_segments(struct request *rq)
 	switch (bio_op(rq->bio)) {
 	case REQ_OP_DISCARD:
 	case REQ_OP_SECURE_ERASE:
+		if (queue_max_discard_segments(rq->q) > 1) {
+			struct bio *bio = rq->bio;
+
+			for_each_bio(bio)
+				nr_phys_segs++;
+			return nr_phys_segs;
+		}
+		return 1;
 	case REQ_OP_WRITE_ZEROES:
 		return 0;
 	case REQ_OP_WRITE_SAME: