]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
imsm: fix default chunk in the !orom case
authorDan Williams <dan.j.williams@intel.com>
Mon, 18 Jul 2011 20:52:29 +0000 (06:52 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 19 Jul 2011 06:53:08 +0000 (16:53 +1000)
Set a valid default in the !orom case, otherwise we segfault, or
otherwise fail.

Cc: Anna Czarnowska <anna.czarnowska@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
platform-intel.h
super-intel.c

index e24ae37928b3b422664e41faed530e979de05708..6c094d72692b42465241e2ee0c3240604cc921a7 100644 (file)
@@ -167,21 +167,6 @@ static inline int fls(int x)
        return r;
 }
 
-/**
- * imsm_orom_default_chunk - return the largest chunk size supported via orom
- * @orom: orom pointer from find_imsm_orom
- */
-static inline int imsm_orom_default_chunk(const struct imsm_orom *orom)
-{
-       int fs = fls(orom->sss);
-
-       if (!fs)
-               return 0;
-
-       return min(512, (1 << fs));
-}
-
-
 enum sys_dev_type {
        SYS_DEV_UNKNOWN = 0,
        SYS_DEV_SAS,
@@ -189,7 +174,6 @@ enum sys_dev_type {
        SYS_DEV_MAX
 };
 
-
 struct sys_dev {
        enum sys_dev_type type;
        char *path;
index b5868e93126304ff2bb5989872ac91d8ae00e0c3..b4540137570402a8f1a27dec2936159ea6c8b60e 100644 (file)
@@ -4915,6 +4915,15 @@ static int is_raid_level_supported(const struct imsm_orom *orom, int level, int
        return 0;
 }
 
+static int imsm_default_chunk(const struct imsm_orom *orom)
+{
+       /* up to 512 if the plaform supports it, otherwise the platform max.
+        * 128 if no platform detected
+        */
+       int fs = max(7, orom ? fls(orom->sss) : 0);
+
+       return min(512, (1 << fs));
+}
 
 #define pr_vrb(fmt, arg...) (void) (verbose && fprintf(stderr, Name fmt, ##arg))
 /*
@@ -4943,15 +4952,16 @@ validate_geometry_imsm_orom(struct intel_super *super, int level, int layout,
                        level, raiddisks, raiddisks > 1 ? "s" : "");
                return 0;
        }
-       if (super->orom && level != 1) {
-               if (chunk && (*chunk == 0 || *chunk == UnSet))
-                       *chunk = imsm_orom_default_chunk(super->orom);
-               else if (chunk && !imsm_orom_has_chunk(super->orom, *chunk)) {
-                       pr_vrb(": platform does not support a chunk size of: "
-                              "%d\n", *chunk);
-                       return 0;
-               }
+
+       if (chunk && (*chunk == 0 || *chunk == UnSet))
+               *chunk = imsm_default_chunk(super->orom);
+
+       if (super->orom && chunk && !imsm_orom_has_chunk(super->orom, *chunk)) {
+               pr_vrb(": platform does not support a chunk size of: "
+                      "%d\n", *chunk);
+               return 0;
        }
+
        if (layout != imsm_level_to_layout(level)) {
                if (level == 5)
                        pr_vrb(": imsm raid 5 only supports the left-asymmetric layout\n");
@@ -5301,9 +5311,8 @@ static void default_geometry_imsm(struct supertype *st, int *level, int *layout,
        if (level && layout && *layout == UnSet)
                *layout = imsm_level_to_layout(*level);
 
-       if (chunk && (*chunk == UnSet || *chunk == 0) && 
-           super && super->orom)
-               *chunk = imsm_orom_default_chunk(super->orom);
+       if (chunk && (*chunk == UnSet || *chunk == 0))
+               *chunk = imsm_default_chunk(super->orom);
 }
 
 static void handle_missing(struct intel_super *super, struct imsm_dev *dev);