Skip to contentSkip to conversation

THE INITIAL VALUE OF wp_offset MAY BE NOT THE POWER OF 2

PATCH In review Atharva Tiwari 4 participants 5 messages Dec 10, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 THE INITIAL VALUE OF wp_offset MAY BE NOT THE POWER OF 2

---
 block/blk-zoned.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-zoned.c +2 -1
index 263e28b72053..60f8bddf9295 100644
@@ -1,3 +1,4 @@
+
 // SPDX-License-Identifier: GPL-2.0
 /*
  * Zoned block device handling
@@ -530,7 +531,7 @@ static struct blk_zone_wplug *disk_get_and_lock_zone_wplug(struct gendisk *disk,
 	spin_lock_init(&zwplug->lock);
 	zwplug->flags = 0;
 	zwplug->zone_no = zno;
-	zwplug->wp_offset = sector & (disk->queue->limits.chunk_sectors - 1);
+	zwplug->wp_offset = bdev_offset_from_zone_start(disk->part0, sector);
 	bio_list_init(&zwplug->bio_list);
 	INIT_WORK(&zwplug->bio_work, blk_zone_wplug_bio_work);
 	zwplug->disk = disk;
Signature · 1 line
2.43.0
#1 lore raw
Quoted 2 lines · Atharva Tiwari

---

You at least need to state why.

Quoted 21 lines
  block/blk-zoned.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-zoned.c +2 -1
index 263e28b72053..60f8bddf9295 100644
@@ -1,3 +1,4 @@
+
  // SPDX-License-Identifier: GPL-2.0
  /*
   * Zoned block device handling
@@ -530,7 +531,7 @@ static struct blk_zone_wplug *disk_get_and_lock_zone_wplug(struct gendisk *disk,
  	spin_lock_init(&zwplug->lock);
  	zwplug->flags = 0;
  	zwplug->zone_no = zno;
-	zwplug->wp_offset = sector & (disk->queue->limits.chunk_sectors - 1);
+	zwplug->wp_offset = bdev_offset_from_zone_start(disk->part0, sector);
  	bio_list_init(&zwplug->bio_list);
  	INIT_WORK(&zwplug->bio_work, blk_zone_wplug_bio_work);
  	zwplug->disk = disk;
#3 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 5 lines · Johannes Thumshirn
Quoted 2 lines · Atharva Tiwari

---

You at least need to state why.

Which will be hard to prove given that we atually check that it can't during disk registration.

I know, so I wanted the explanation ;)

#4 lore raw
In reply to Atharva Tiwari

block/blk-zoned.c static struct blk_zone_wplug *disk_get_and_lock_zone_wplug(struct gendisk *disk, · line 537

Quoted 9 lines · Atharva Tiwari
block/blk-zoned.c +1 -1
@@ -530,7 +531,7 @@ static struct blk_zone_wplug *disk_get_and_lock_zone_wplug(struct gendisk *disk,
  	spin_lock_init(&zwplug->lock);
  	zwplug->flags = 0;
  	zwplug->zone_no = zno;
-	zwplug->wp_offset = sector & (disk->queue->limits.chunk_sectors - 1);
+	zwplug->wp_offset = bdev_offset_from_zone_start(disk->part0, sector);
  	bio_list_init(&zwplug->bio_list);
  	INIT_WORK(&zwplug->bio_work, blk_zone_wplug_bio_work);
  	zwplug->disk = disk;

The above looks like a duplicate of this patch:
https://lore.kernel.org/linux-block/[email protected]/