Skip to contentSkip to conversation

brd: Add an option to disable 512e sector size

PATCH New Mark Lehrer 1 participant 1 message Apr 9, 2019

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

PATCH 1/1 brd: Add an option to disable 512e sector size

From: Mark Lehrer <[email protected]>

This patch adds a new option, "disable_512e", which causes the driver to set the blk_queue_logical_block_size to 4K to match the blk_queue_physical_block_size. If this option is left at the default, brd will work the same way it always has so this shouldn't affect anyone unexpectedly.

---

drivers/block/brd.c 2019-04-08 10:20:58.248623425 -0600 renamed from drivers/block/brd.c 2019-04-08 09:57:42.016921473 -0600 +8 -0
diff -uprN a/drivers/block/brd.c b/drivers/block/brd.c
@@ -342,6 +342,10 @@ static int max_part = 1;
 module_param(max_part, int, 0444);
 MODULE_PARM_DESC(max_part, "Num Minors to reserve between devices");
 
+static int disable_512e = 0;
+module_param(disable_512e, int, 0444);
+MODULE_PARM_DESC(disable_512e, "Disable Logical 512e sector size");
+
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR);
 MODULE_ALIAS("rd");
@@ -389,6 +393,10 @@ static struct brd_device *brd_alloc(int
          *  is harmless)
          */
         blk_queue_physical_block_size(brd->brd_queue, PAGE_SIZE);
+
+       if (disable_512e)
+               blk_queue_logical_block_size(brd->brd_queue, PAGE_SIZE);
+
         disk = brd->brd_disk = alloc_disk(max_part);
         if (!disk)
                 goto out_free_queue;