Skip to contentSkip to conversation

md/raid5: cast chunk_sectors to sector_t value

PATCH Applied Guoqing Jiang 3 participants 4 messages Dec 16, 2020 – Jan 27, 2021 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 md/raid5: cast chunk_sectors to sector_t value

Currently, raid5 calculates dev_sectors from chunk_sectors without proper cast, which is problematic.

---
I think the recently report about raid5 issue could be related with the setting of dev_sectors.

Could someone test it with a large raid5 array? Thanks.

 drivers/md/raid5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid5.c +1 -1
index 3934347..ca0b29a 100644
@@ -7662,7 +7662,7 @@ static int raid5_run(struct mddev *mddev)
 	}
 
 	/* device size must be a multiple of chunk size */
-	mddev->dev_sectors &= ~(mddev->chunk_sectors - 1);
+	mddev->dev_sectors &= ~((sector_t)mddev->chunk_sectors - 1);
 	mddev->resync_max_sectors = mddev->dev_sectors;
 
 	if (mddev->degraded > dirty_parity_disks &&
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 10 lines · Guoqing Jiang

Currently, raid5 calculates dev_sectors from chunk_sectors without proper cast, which is problematic.

---
I think the recently report about raid5 issue could be related with the setting of dev_sectors.

Could someone test it with a large raid5 array? Thanks.

Yes, this was the exact problem. I will apply this to md-next. (probably after the merge window).

Thanks,
Song

Quoted 20 lines
 drivers/md/raid5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid5.c +1 -2
index 3934347..ca0b29a 100644
@@ -7662,7 +7662,7 @@ static int raid5_run(struct mddev *mddev)
        }
 
        /* device size must be a multiple of chunk size */
-       mddev->dev_sectors &= ~(mddev->chunk_sectors - 1);
+       mddev->dev_sectors &= ~((sector_t)mddev->chunk_sectors - 1);
        mddev->resync_max_sectors = mddev->dev_sectors;
 
        if (mddev->degraded > dirty_parity_disks &&
--

2.7.4

#2 lore raw
Quoted 36 lines · Song Liu <[email protected]> 于2020年12月16日周三 上午5:29写道:
Quoted 10 lines · Guoqing Jiang

Currently, raid5 calculates dev_sectors from chunk_sectors without proper cast, which is problematic.

---
I think the recently report about raid5 issue could be related with the setting of dev_sectors.

Could someone test it with a large raid5 array? Thanks.

Yes, this was the exact problem. I will apply this to md-next. (probably after the merge window).

Thanks,
Song

Quoted 16 lines
 drivers/md/raid5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid5.c +1 -1
index 3934347..ca0b29a 100644
@@ -7662,7 +7662,7 @@ static int raid5_run(struct mddev *mddev)
        }
 
        /* device size must be a multiple of chunk size */
-       mddev->dev_sectors &= ~(mddev->chunk_sectors - 1);
+       mddev->dev_sectors &= ~((sector_t)mddev->chunk_sectors - 1);
        mddev->resync_max_sectors = mddev->dev_sectors;
 
Quoted 4 lines
Quoted 4 lines
drivers/md/raid5.c +0 -1
        if (mddev->degraded > dirty_parity_disks &&
--

2.7.4

ping, I cant find it in latest mainline, is it forgotten?

maintainer Applied
#3 lore raw
Quoted 38 lines · Jack Wang
Quoted 36 lines · Song Liu <[email protected]> 于2020年12月16日周三 上午5:29写道:
Quoted 10 lines · Guoqing Jiang

Currently, raid5 calculates dev_sectors from chunk_sectors without proper cast, which is problematic.

---
I think the recently report about raid5 issue could be related with the setting of dev_sectors.

Could someone test it with a large raid5 array? Thanks.

Yes, this was the exact problem. I will apply this to md-next. (probably after the merge window).

Thanks,
Song

Quoted 16 lines
 drivers/md/raid5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid5.c +1 -1
index 3934347..ca0b29a 100644
@@ -7662,7 +7662,7 @@ static int raid5_run(struct mddev *mddev)
        }
 
        /* device size must be a multiple of chunk size */
-       mddev->dev_sectors &= ~(mddev->chunk_sectors - 1);
+       mddev->dev_sectors &= ~((sector_t)mddev->chunk_sectors - 1);
        mddev->resync_max_sectors = mddev->dev_sectors;
 
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
drivers/md/raid5.c +0 -1
        if (mddev->degraded > dirty_parity_disks &&
--

2.7.4

ping, I cant find it in latest mainline, is it forgotten?

Applied to md-next. Thanks.

Song