multipathd: fix reservation_key check
[multipath-tools/.git] / libmultipath / config.c
index 9d3f3e1..085a3e1 100644 (file)
@@ -25,6 +25,7 @@
 #include "prio.h"
 #include "devmapper.h"
 #include "mpath_cmd.h"
+#include "propsel.h"
 
 static int
 hwe_strmatch (struct hwentry *hwe1, struct hwentry *hwe2)
@@ -318,6 +319,7 @@ set_param_str(char * str)
 static int
 merge_hwe (struct hwentry * dst, struct hwentry * src)
 {
+       char id[SCSI_VENDOR_SIZE+PATH_PRODUCT_SIZE];
        merge_str(vendor);
        merge_str(product);
        merge_str(revision);
@@ -349,19 +351,12 @@ merge_hwe (struct hwentry * dst, struct hwentry * src)
        merge_num(delay_wait_checks);
        merge_num(skip_kpartx);
        merge_num(max_sectors_kb);
-       merge_num(san_path_err_threshold);
-       merge_num(san_path_err_forget_rate);
-       merge_num(san_path_err_recovery_time);
-
-       /*
-        * Make sure features is consistent with
-        * no_path_retry
-        */
-       if (dst->no_path_retry == NO_PATH_RETRY_FAIL)
-               remove_feature(&dst->features, "queue_if_no_path");
-       else if (dst->no_path_retry != NO_PATH_RETRY_UNDEF)
-               add_feature(&dst->features, "queue_if_no_path");
+       merge_num(ghost_delay);
 
+       snprintf(id, sizeof(id), "%s/%s", dst->vendor, dst->product);
+       reconcile_features_with_options(id, &dst->features,
+                                       &dst->no_path_retry,
+                                       &dst->retain_hwhandler);
        return 0;
 }
 
@@ -425,6 +420,7 @@ store_hwe (vector hwtable, struct hwentry * dhwe)
        hwe->retain_hwhandler = dhwe->retain_hwhandler;
        hwe->detect_prio = dhwe->detect_prio;
        hwe->detect_checker = dhwe->detect_checker;
+       hwe->ghost_delay = dhwe->ghost_delay;
 
        if (dhwe->bl_product && !(hwe->bl_product = set_param_str(dhwe->bl_product)))
                goto out;
@@ -451,6 +447,13 @@ restart:
                        break;
                j = n;
                vector_foreach_slot_after(hw, hwe2, j) {
+                       /* drop invalid device configs */
+                       if (!hwe2->vendor || !hwe2->product) {
+                               condlog(0, "device config missing vendor or product parameter");
+                               vector_del_slot(hw, j--);
+                               free_hwe(hwe2);
+                               continue;
+                       }
                        if (hwe_regmatch(hwe1, hwe2))
                                continue;
                        /* dup */
@@ -493,6 +496,9 @@ free_config (struct config * conf)
        if (conf->uid_attribute)
                FREE(conf->uid_attribute);
 
+       if (conf->uid_attrs)
+               FREE(conf->uid_attrs);
+
        if (conf->getuid)
                FREE(conf->getuid);
 
@@ -508,6 +514,9 @@ free_config (struct config * conf)
        if (conf->wwids_file)
                FREE(conf->wwids_file);
 
+       if (conf->prkeys_file)
+               FREE(conf->prkeys_file);
+
        if (conf->prio_name)
                FREE(conf->prio_name);
 
@@ -525,9 +534,6 @@ free_config (struct config * conf)
        if (conf->config_dir)
                FREE(conf->config_dir);
 
-       if (conf->reservation_key)
-               FREE(conf->reservation_key);
-
        free_blacklist(conf->blist_devnode);
        free_blacklist(conf->blist_wwid);
        free_blacklist(conf->blist_property);
@@ -596,40 +602,26 @@ load_config (char * file)
        if (!conf->verbosity)
                conf->verbosity = DEFAULT_VERBOSITY;
 
-       conf->minio = DEFAULT_MINIO;
-       conf->minio_rq = DEFAULT_MINIO_RQ;
        get_sys_max_fds(&conf->max_fds);
        conf->bindings_file = set_default(DEFAULT_BINDINGS_FILE);
        conf->wwids_file = set_default(DEFAULT_WWIDS_FILE);
+       conf->prkeys_file = set_default(DEFAULT_PRKEYS_FILE);
        conf->multipath_dir = set_default(DEFAULT_MULTIPATHDIR);
-       conf->features = set_default(DEFAULT_FEATURES);
-       conf->flush_on_last_del = DEFAULT_FLUSH;
        conf->attribute_flags = 0;
        conf->reassign_maps = DEFAULT_REASSIGN_MAPS;
        conf->checkint = DEFAULT_CHECKINT;
        conf->max_checkint = 0;
-       conf->pgfailback = DEFAULT_FAILBACK;
-       conf->fast_io_fail = DEFAULT_FAST_IO_FAIL;
-       conf->retain_hwhandler = DEFAULT_RETAIN_HWHANDLER;
-       conf->detect_prio = DEFAULT_DETECT_PRIO;
-       conf->detect_checker = DEFAULT_DETECT_CHECKER;
        conf->force_sync = DEFAULT_FORCE_SYNC;
        conf->partition_delim = DEFAULT_PARTITION_DELIM;
        conf->processed_main_config = 0;
        conf->find_multipaths = DEFAULT_FIND_MULTIPATHS;
        conf->uxsock_timeout = DEFAULT_REPLY_TIMEOUT;
-       conf->uid_attribute = set_default(DEFAULT_UID_ATTRIBUTE);
        conf->retrigger_tries = DEFAULT_RETRIGGER_TRIES;
        conf->retrigger_delay = DEFAULT_RETRIGGER_DELAY;
        conf->uev_wait_timeout = DEFAULT_UEV_WAIT_TIMEOUT;
-       conf->deferred_remove = DEFAULT_DEFERRED_REMOVE;
-       conf->skip_kpartx = DEFAULT_SKIP_KPARTX;
        conf->disable_changed_wwids = DEFAULT_DISABLE_CHANGED_WWIDS;
        conf->remove_retries = 0;
-       conf->max_sectors_kb = DEFAULT_MAX_SECTORS_KB;
-       conf->san_path_err_threshold = DEFAULT_ERR_CHECKS;
-       conf->san_path_err_forget_rate = DEFAULT_ERR_CHECKS;
-       conf->san_path_err_recovery_time = DEFAULT_ERR_CHECKS;
+       conf->ghost_delay = DEFAULT_GHOST_DELAY;
 
        /*
         * preload default hwtable
@@ -740,7 +732,7 @@ load_config (char * file)
                conf->bindings_file = set_default(DEFAULT_BINDINGS_FILE);
 
        if (!conf->multipath_dir || !conf->bindings_file ||
-           !conf->wwids_file)
+           !conf->wwids_file || !conf->prkeys_file)
                goto out;
 
        return conf;