Skip to contentSkip to conversation

Subject: [PATCH 007/009]: raid10: chunk size check in run

PATCH raz ben yehuda 2 participants 2 messages May 19, 2009 – May 20, 2009 MD RAID

lore
Share & tools
lore
#0 lore raw

have raid10 check chunk size in run method instead of in md

 raid10.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
Signed-off-by [email protected]
drivers/md/raid10.c +9 -1
index 2405add..52ad64e 100644
@@ -2055,7 +2055,15 @@ static int run(mddev_t *mddev)
 		       "at least PAGE_SIZE(%ld).\n", PAGE_SIZE);
 		return -EINVAL;
 	}
-
+	/*
+	 * chunk-size has to be a power of 2
+	 */
+	if ((1 << ffz(~mddev->chunk_size)) != mddev->chunk_size) {
+		printk(KERN_ERR "%s chunk_size of %d not valid\n",
+			mdname(mddev),
+			mddev->chunk_size);
+		return -EINVAL;
+	}
 	nc = mddev->layout & 255;
 	fc = (mddev->layout >> 8) & 255;
 	fo = mddev->layout & (1<<16);
#1 lore raw
Quoted 16 lines · On Tuesday May 19, [email protected] wrote:

have raid10 check chunk size in run method instead of in md

 raid10.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
Signed-off-by [email protected]
drivers/md/raid10.c +2 -1
index 2405add..52ad64e 100644
@@ -2055,7 +2055,15 @@ static int run(mddev_t *mddev)
 		       "at least PAGE_SIZE(%ld).\n", PAGE_SIZE);
 		return -EINVAL;
 	}
-
+	/*
+	 * chunk-size has to be a power of 2

drivers/md/raid10.c static int run(mddev_t *mddev) · line 2069

Quoted 10 lines
drivers/md/raid10.c +7 -0
+	 */
+	if ((1 << ffz(~mddev->chunk_size)) != mddev->chunk_size) {
+		printk(KERN_ERR "%s chunk_size of %d not valid\n",
+			mdname(mddev),
+			mddev->chunk_size);
+		return -EINVAL;
+	}
 	nc = mddev->layout & 255;
 	fc = (mddev->layout >> 8) & 255;
 	fo = mddev->layout & (1<<16);

I combined this with the other chunk_size check in run, so there is only the one printk.

Thanks,
NeilBrown