Skip to contentSkip to conversation

block: always set partition number to '0' in blk_partition_remap()

PATCH Superseded Hannes Reinecke 3 participants 4 messages Jun 6, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: always set partition number to '0' in blk_partition_remap()

blk_partition_remap() will only clear bi_partno if an actual remapping has happened. But flush request et al don't have an actual size, so the remapping doesn't happen and bi_partno is never cleared. So for stacked devices blk_partition_remap() will be called on each level. If (as is the case for native nvme multipathing) one of the lower-level devices do _not_support partitioning a spurious I/O error is generated.

---
 block/blk-core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
block/blk-core.c +4 -1
index cee03cad99f2..8a2c3a474234 100644
@@ -2225,7 +2225,10 @@ static inline int blk_partition_remap(struct bio *bio)
 		bio->bi_partno = 0;
 		trace_block_bio_remap(bio->bi_disk->queue, bio, part_devt(p),
 				      bio->bi_iter.bi_sector - p->start_sect);
-	}
+	} else
+		/* Set partition number to '0' to avoid repetitive calls */
+		bio->bi_partno = 0;
+
 	ret = 0;
 out:
 	rcu_read_unlock();
Signature · 1 line
2.12.3
maintainer
#1 lore raw
Quoted 6 lines · Hannes Reinecke

blk_partition_remap() will only clear bi_partno if an actual remapping has happened. But flush request et al don't have an actual size, so the remapping doesn't happen and bi_partno is never cleared. So for stacked devices blk_partition_remap() will be called on each level. If (as is the case for native nvme multipathing) one of the lower-level devices do _not_support partitioning a spurious I/O error is generated.

Just move it down, we're now clearing it for both cases.

block/blk-core.c +1 -1
index 3f56be15f17e..cf0ee764b908 100644
@@ -2220,10 +2220,10 @@ static inline int blk_partition_remap(struct bio *bio)
 		if (bio_check_eod(bio, part_nr_sects_read(p)))
 			goto out;
 		bio->bi_iter.bi_sector += p->start_sect;
-		bio->bi_partno = 0;
 		trace_block_bio_remap(bio->bi_disk->queue, bio, part_devt(p),
 				      bio->bi_iter.bi_sector - p->start_sect);
 	}
+	bio->bi_partno = 0;
 	ret = 0;
 out:
 	rcu_read_unlock();
Signature · 1 line
Jens Axboe
#2 lore raw
Quoted 18 lines · On Wed, 6 Jun 2018 08:26:56 -0600 Jens Axboe <[email protected]> wrote:
Quoted 7 lines · Hannes Reinecke

blk_partition_remap() will only clear bi_partno if an actual remapping has happened. But flush request et al don't have an actual size, so the remapping doesn't happen and bi_partno is never cleared. So for stacked devices blk_partition_remap() will be called on each level. If (as is the case for native nvme multipathing) one of the lower-level devices do _not_support partitioning a spurious I/O error is generated.

Just move it down, we're now clearing it for both cases.

block/blk-core.c +0 -0
index 3f56be15f17e..cf0ee764b908 100644
@@ -2220,10 +2220,10 @@ static inline int blk_partition_remap(struct
 bio *bio) if (bio_check_eod(bio, part_nr_sects_read(p)))

block/blk-core.c static inline int blk_partition_remap(struct · line 2229

Quoted 10 lines
block/blk-core.c +1 -1
 			goto out;
 		bio->bi_iter.bi_sector += p->start_sect;
-		bio->bi_partno = 0;
 		trace_block_bio_remap(bio->bi_disk->queue, bio,
 part_devt(p), bio->bi_iter.bi_sector - p->start_sect);
 	}
+	bio->bi_partno = 0;
 	ret = 0;
 out:
 	rcu_read_unlock();

Okay, will be resending.

Cheers,

Hannes

#3 lore raw
In reply to Jens Axboe
Quoted 9 lines · Jens Axboe
Quoted 6 lines · Hannes Reinecke

blk_partition_remap() will only clear bi_partno if an actual remapping has happened. But flush request et al don't have an actual size, so the remapping doesn't happen and bi_partno is never cleared. So for stacked devices blk_partition_remap() will be called on each level. If (as is the case for native nvme multipathing) one of the lower-level devices do _not_support partitioning a spurious I/O error is generated.

Just move it down, we're now clearing it for both cases.

Agreed.