]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-mbr.c
Grow: Remove unnecessary optimization
[thirdparty/mdadm.git] / super-mbr.c
index bbbc65bf3173f66c06f2ced55bba0900a12b1f15..1bbe57a971639fc67aa606ea921b057e86e2fdb8 100644 (file)
@@ -57,6 +57,11 @@ static void examine_mbr(struct supertype *st, char *homehost)
 
        printf("   MBR Magic : %04x\n", sb->magic);
        for (i = 0; i < MBR_PARTITIONS; i++)
+               /*
+                * Have to make every access through sb rather than using a
+                * pointer to the partition table (or an entry), since the
+                * entries are not properly aligned.
+                */
                if (sb->parts[i].blocks_num)
                        printf("Partition[%d] : %12lu sectors at %12lu (type %02x)\n",
                               i,
@@ -81,13 +86,10 @@ static int load_super_mbr(struct supertype *st, int fd, char *devname)
        free_mbr(st);
 
        if (posix_memalign((void**)&super, 512, 512) != 0) {
-               pr_err("%s could not allocate superblock\n",
-                       __func__);
+               pr_err("could not allocate superblock\n");
                return 1;
        }
 
-       ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
-
        lseek(fd, 0, 0);
        if (read(fd, super, sizeof(*super)) != sizeof(*super)) {
                if (devname)
@@ -96,7 +98,7 @@ static int load_super_mbr(struct supertype *st, int fd, char *devname)
                free(super);
                return 1;
        }
+
        if (super->magic != MBR_SIGNATURE_MAGIC) {
                if (devname)
                        pr_err("No partition table found on %s\n",
@@ -121,13 +123,10 @@ static int store_mbr(struct supertype *st, int fd)
        struct MBR *old, *super;
 
        if (posix_memalign((void**)&old, 512, 512) != 0) {
-               pr_err("%s could not allocate superblock\n",
-                       __func__);
+               pr_err("could not allocate superblock\n");
                return 1;
        }
 
-       ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
-
        lseek(fd, 0, 0);
        if (read(fd, old, sizeof(*old)) != sizeof(*old)) {
                free(old);
@@ -157,8 +156,13 @@ static void getinfo_mbr(struct supertype *st, struct mdinfo *info, char *map)
        info->component_size = 0;
 
        for (i = 0; i < MBR_PARTITIONS ; i++)
+               /*
+                * Have to make every access through sb rather than using a
+                * pointer to the partition table (or an entry), since the
+                * entries are not properly aligned.
+                */
                if (sb->parts[i].blocks_num) {
-                       unsigned long last = 
+                       unsigned long last =
                                (unsigned long)__le32_to_cpu(sb->parts[i].blocks_num)
                                + (unsigned long)__le32_to_cpu(sb->parts[i].first_sect_lba);
                        if (last > info->component_size)
@@ -187,8 +191,9 @@ static struct supertype *match_metadata_desc(char *arg)
 static int validate_geometry(struct supertype *st, int level,
                             int layout, int raiddisks,
                             int *chunk, unsigned long long size,
+                            unsigned long long data_offset,
                             char *subdev, unsigned long long *freesize,
-                            int verbose)
+                            int consistency_policy, int verbose)
 {
        pr_err("mbr metadata cannot be used this way\n");
        return 0;