]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
imsm: set array size at Create/Assemble
authorDan Williams <dan.j.williams@intel.com>
Sun, 12 Apr 2009 07:58:28 +0000 (00:58 -0700)
committerDan Williams <dan.j.williams@intel.com>
Sun, 12 Apr 2009 07:58:28 +0000 (00:58 -0700)
imsm arrays round down the effective array size to the closest 1
megabyte boundary so teach get_info_super_imsm and sysfs_set_array to
set 'md/array_size' if available (and make sure ddf uses the default
size).

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
mdadm.h
super-ddf.c
super-intel.c
sysfs.c

diff --git a/mdadm.h b/mdadm.h
index f580e3e807388ead74966e25ffc20f0ff8577252..c33ec2480358f880df2a11dff07454c740de13cf 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -146,6 +146,9 @@ struct mdinfo {
        unsigned long long      component_size; /* same as array.size, except in
                                                 * sectors and up to 64bits.
                                                 */
+       unsigned long long      custom_array_size; /* size for non-default sized
+                                                   * arrays (in sectors)
+                                                   */
        int                     reshape_active;
        unsigned long long      reshape_progress;
        unsigned long long      resync_start;
index 6455deeee148cd1a9cbc01b2e3f37115f612dc39..6a8705567957a645ae1195bd59fa755021790327 100644 (file)
@@ -1374,6 +1374,7 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info)
                __be32_to_cpu(*(__u32*)(vc->conf.guid+16));
        info->array.utime         = DECADE + __be32_to_cpu(vc->conf.timestamp);
        info->array.chunk_size    = 512 << vc->conf.chunk_shift;
+       info->custom_array_size   = 0;
 
        if (cd >= 0 && cd < ddf->mppe) {
                info->data_offset         = __be64_to_cpu(vc->lba_offset[cd]);
index 3befc3d0712d21b576d6849bb74f465ce33e9e52..b41ab3b133113dbf45fd3cb1565e3301798f9c04 100644 (file)
@@ -1203,6 +1203,9 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info)
        info->array.utime         = 0;
        info->array.chunk_size    = __le16_to_cpu(map->blocks_per_strip) << 9;
        info->array.state         = !dev->vol.dirty;
+       info->custom_array_size   = __le32_to_cpu(dev->size_high);
+       info->custom_array_size   <<= 32;
+       info->custom_array_size   |= __le32_to_cpu(dev->size_low);
 
        info->disk.major = 0;
        info->disk.minor = 0;
diff --git a/sysfs.c b/sysfs.c
index 2dad7d3fd8c9969aefc636ce46213576aa4e85b1..48d1f54264818097c22ba8322d03e4703e2c19dd 100644 (file)
--- a/sysfs.c
+++ b/sysfs.c
@@ -506,6 +506,20 @@ int sysfs_set_array(struct mdinfo *info, int vers)
        rv |= sysfs_set_num(info, NULL, "chunk_size", info->array.chunk_size);
        rv |= sysfs_set_num(info, NULL, "layout", info->array.layout);
        rv |= sysfs_set_num(info, NULL, "component_size", info->component_size/2);
+       if (info->custom_array_size) {
+               int rc;
+
+               rc = sysfs_set_num(info, NULL, "array_size",
+                                  info->custom_array_size/2);
+               if (rc && errno == ENOENT) {
+                       fprintf(stderr, Name ": This kernel does not "
+                               "have the md/array_size attribute, "
+                               "the array may be larger than expected\n");
+                       rc = 0;
+               }
+               rv |= rc;
+       }
+
        if (info->array.level > 0)
                rv |= sysfs_set_num(info, NULL, "resync_start", info->resync_start);
        return rv;