Skip to contentSkip to conversation

md/raid1: round up to bdev_logical_block_size in narrow_write_error

PATCH In review Nate Dailey 2 participants 2 messages Feb 12, 2015 – Feb 16, 2015 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 md/raid1: round up to bdev_logical_block_size in narrow_write_error

This modifies raid1's narrow_write_error to round up block_sectors to the device's logical block size.

This prevents sd complaining about "Bad block number requested" for non-512-byte sector disks.

---

drivers/md/raid1.c 2015-02-10 15:29:45.000000000 -0500 renamed from drivers/md/raid1.c 2015-02-10 15:29:02.000000000 -0500 +2 -1
diff -Nupr a/drivers/md/raid1.c b/drivers/md/raid1.c
@@ -2206,7 +2206,8 @@ static int narrow_write_error(struct r1b
        if (rdev->badblocks.shift < 0)
                return 0;
 
-       block_sectors = 1 << rdev->badblocks.shift;
+       block_sectors = roundup(1 << rdev->badblocks.shift,
+                               bdev_logical_block_size(rdev->bdev) >> 9);
        sector = r1_bio->sector;
        sectors = ((sector + block_sectors)
                   & ~(sector_t)(block_sectors - 1))
#1 lore raw
Quoted 23 lines · On Thu, 12 Feb 2015 12:02:09 -0500 Nate Dailey <[email protected]> wrote:

This modifies raid1's narrow_write_error to round up block_sectors to the device's logical block size.

This prevents sd complaining about "Bad block number requested" for non-512-byte sector disks.

---

diff -Nupr a/drivers/md/raid1.c b/drivers/md/raid1.c

drivers/md/raid1.c 2015-02-10 15:29:45.000000000 -0500 renamed from drivers/md/raid1.c 2015-02-10 15:29:02.000000000 -0500 +2 -2
@@ -2206,7 +2206,8 @@ static int narrow_write_error(struct r1b
        if (rdev->badblocks.shift < 0)
                return 0;
 
-       block_sectors = 1 << rdev->badblocks.shift;
+       block_sectors = roundup(1 << rdev->badblocks.shift,
+                               bdev_logical_block_size(rdev->bdev) >> 9);
        sector = r1_bio->sector;
        sectors = ((sector + block_sectors)
                   & ~(sector_t)(block_sectors - 1))
--
Quoted 3 lines

To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Thanks. I've applied this patch and a similar one for RAID10.

This patch had spaces where it should have had tabs (and had no space at all on one line which should have had a space).
I've fixed all that up, but if you find yourself submitting more patches in future it would be worth working out how to convince your mailer to send the patches cleanly with no TAB->space conversions.

Thanks,
NeilBrown