]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
imsm: add verbose flag to compare_super
authorMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Fri, 5 Feb 2021 13:29:58 +0000 (14:29 +0100)
committerJes Sorensen <jsorensen@fb.com>
Mon, 8 Mar 2021 15:43:29 +0000 (10:43 -0500)
IMSM does more than comparing metadata and errors reported directly
from compare_super_imsm can be useful.

Add verbose flag to compare_super method and make all not critical
error printing configurable.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Assemble.c
Examine.c
Incremental.c
mdadm.h
super-ddf.c
super-intel.c
super0.c
super1.c

index ed0ddfb1d3d5f8e56efa0d8ecac3c8aa4fe46221..48556d8c819dc85fac7ccda954cfbaefd9561908 100644 (file)
@@ -435,7 +435,7 @@ static int select_devices(struct mddev_dev *devlist,
 
                        if (st->ss != tst->ss ||
                            st->minor_version != tst->minor_version ||
-                           st->ss->compare_super(st, tst) != 0) {
+                           st->ss->compare_super(st, tst, 1) != 0) {
                                /* Some mismatch. If exactly one array matches this host,
                                 * we can resolve on that one.
                                 * Or, if we are auto assembling, we just ignore the second
index 7013480d6dd80846cc2f464d3ba23c9e8e21284d..4381cd567789cfb522b4be7667efd0a78309be31 100644 (file)
--- a/Examine.c
+++ b/Examine.c
@@ -130,7 +130,7 @@ int Examine(struct mddev_dev *devlist,
                        char *d;
                        for (ap = arrays; ap; ap = ap->next) {
                                if (st->ss == ap->st->ss &&
-                                   st->ss->compare_super(ap->st, st) == 0)
+                                   st->ss->compare_super(ap->st, st, 0) == 0)
                                        break;
                        }
                        if (!ap) {
index e849bdda5fc1a6a01df3ce505db2e913aaf1c1e3..cd9cc0fc8bb6437bc156aa04bd0282ed36e919a3 100644 (file)
@@ -400,7 +400,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
                        }
                        st2 = dup_super(st);
                        if (st2->ss->load_super(st2, dfd2, NULL) ||
-                           st->ss->compare_super(st, st2) != 0) {
+                           st->ss->compare_super(st, st2, 1) != 0) {
                                pr_err("metadata mismatch between %s and chosen array %s\n",
                                       devname, chosen_name);
                                close(dfd2);
diff --git a/mdadm.h b/mdadm.h
index 1ee6c92e3f9fcb448f480350fc3c9edd78cfd6cd..60575af0a3bb1bd6fbc96860fb3c333300aa7118 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -966,7 +966,8 @@ extern struct superswitch {
         * moved in, otherwise the superblock in 'st' is compared with
         * 'tst'.
         */
-       int (*compare_super)(struct supertype *st, struct supertype *tst);
+       int (*compare_super)(struct supertype *st, struct supertype *tst,
+                            int verbose);
        /* Load metadata from a single device.  If 'devname' is not NULL
         * print error messages as appropriate */
        int (*load_super)(struct supertype *st, int fd, char *devname);
index 7cd5702d81fa3547c3f7f070058ba83509fea883..2314762007070f4df551b134d10c25f8d8a6ee58 100644 (file)
@@ -3914,7 +3914,8 @@ static int store_super_ddf(struct supertype *st, int fd)
        return 0;
 }
 
-static int compare_super_ddf(struct supertype *st, struct supertype *tst)
+static int compare_super_ddf(struct supertype *st, struct supertype *tst,
+                            int verbose)
 {
        /*
         * return:
index c3466d0c5ccf31adca2c355e0df865b8946c74af..98af3b5e953fc4361afb09cd0def71443addb4bc 100644 (file)
@@ -3815,7 +3815,8 @@ static void imsm_copy_dev(struct imsm_dev *dest, struct imsm_dev *src)
        memcpy(dest, src, sizeof_imsm_dev(src, 0));
 }
 
-static int compare_super_imsm(struct supertype *st, struct supertype *tst)
+static int compare_super_imsm(struct supertype *st, struct supertype *tst,
+                             int verbose)
 {
        /*
         * return:
@@ -3838,18 +3839,20 @@ static int compare_super_imsm(struct supertype *st, struct supertype *tst)
         */
        if (!check_env("IMSM_NO_PLATFORM") && first->hba && sec->hba) {
                if (first->hba->type != sec->hba->type) {
-                       fprintf(stderr,
-                               "HBAs of devices do not match %s != %s\n",
-                               get_sys_dev_type(first->hba->type),
-                               get_sys_dev_type(sec->hba->type));
+                       if (verbose)
+                               pr_err("HBAs of devices do not match %s != %s\n",
+                                      get_sys_dev_type(first->hba->type),
+                                      get_sys_dev_type(sec->hba->type));
                        return 3;
                }
+
                if (first->orom != sec->orom) {
-                       fprintf(stderr,
-                               "HBAs of devices do not match %s != %s\n",
-                               first->hba->pci_id, sec->hba->pci_id);
+                       if (verbose)
+                               pr_err("HBAs of devices do not match %s != %s\n",
+                                      first->hba->pci_id, sec->hba->pci_id);
                        return 3;
                }
+
        }
 
        /* if an anchor does not have num_raid_devs set then it is a free
@@ -6948,7 +6951,7 @@ count_volumes_list(struct md_list *devlist, char *homehost,
 
                        if (st->ss != tst->ss ||
                            st->minor_version != tst->minor_version ||
-                           st->ss->compare_super(st, tst) != 0) {
+                           st->ss->compare_super(st, tst, 1) != 0) {
                                /* Some mismatch. If exactly one array matches this host,
                                 * we can resolve on that one.
                                 * Or, if we are auto assembling, we just ignore the second
index 6af140bbf72197223e54fd37b9d1fd1ac28167ad..b79b97a9e0acfe7224258b334249f6b2c8f7da1a 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -926,7 +926,8 @@ static int write_init_super0(struct supertype *st)
        return rv;
 }
 
-static int compare_super0(struct supertype *st, struct supertype *tst)
+static int compare_super0(struct supertype *st, struct supertype *tst,
+                         int verbose)
 {
        /*
         * return:
index 7b03329dac916e4ec7659b27ff1140af01921daa..c05e6237db5c2f4d15508650469456e18758d80a 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -2144,7 +2144,8 @@ out:
        return rv;
 }
 
-static int compare_super1(struct supertype *st, struct supertype *tst)
+static int compare_super1(struct supertype *st, struct supertype *tst,
+                         int verbose)
 {
        /*
         * return: