diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2022-01-14 13:50:17 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2022-01-14 13:50:17 +0900 |
commit | 28bc88e5da7ffd00fcdac1d23c729d19e646f3fd (patch) | |
tree | 6168d694321e5124e62bab14e1ab14a58ad26acf /libmultipath/propsel.c | |
parent | c0050816c16d25f8143a791d1bb74e16af67c272 (diff) | |
download | multipath-tools-28bc88e5da7ffd00fcdac1d23c729d19e646f3fd.tar.gz multipath-tools-28bc88e5da7ffd00fcdac1d23c729d19e646f3fd.tar.bz2 multipath-tools-28bc88e5da7ffd00fcdac1d23c729d19e646f3fd.zip |
Imported Upstream version 0.7.2upstream/0.7.2
Diffstat (limited to 'libmultipath/propsel.c')
-rw-r--r-- | libmultipath/propsel.c | 95 |
1 files changed, 74 insertions, 21 deletions
diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index 09fe728..175fbe1 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -269,6 +269,60 @@ out: return mp->alias ? 0 : 1; } +void reconcile_features_with_options(const char *id, char **features, int* no_path_retry, + int *retain_hwhandler) +{ + static const char q_i_n_p[] = "queue_if_no_path"; + static const char r_a_h_h[] = "retain_attached_hw_handler"; + char buff[12]; + + if (*features == NULL) + return; + if (id == NULL) + id = "UNKNOWN"; + + /* + * We only use no_path_retry internally. The "queue_if_no_path" + * device-mapper feature is derived from it when the map is loaded. + * For consistency, "queue_if_no_path" is removed from the + * internal libmultipath features string. + * For backward compatibility we allow 'features "1 queue_if_no_path"'; + * it's translated into "no_path_retry queue" here. + */ + if (strstr(*features, q_i_n_p)) { + condlog(0, "%s: option 'features \"1 %s\"' is deprecated, " + "please use 'no_path_retry queue' instead", + id, q_i_n_p); + if (*no_path_retry == NO_PATH_RETRY_UNDEF) { + *no_path_retry = NO_PATH_RETRY_QUEUE; + print_no_path_retry(buff, sizeof(buff), + no_path_retry); + condlog(3, "%s: no_path_retry = %s (inherited setting from feature '%s')", + id, buff, q_i_n_p); + }; + /* Warn only if features string is overridden */ + if (*no_path_retry != NO_PATH_RETRY_QUEUE) { + print_no_path_retry(buff, sizeof(buff), + no_path_retry); + condlog(2, "%s: ignoring feature '%s' because no_path_retry is set to '%s'", + id, q_i_n_p, buff); + } + remove_feature(features, q_i_n_p); + } + if (strstr(*features, r_a_h_h)) { + condlog(0, "%s: option 'features \"1 %s\"' is deprecated", + id, r_a_h_h); + if (*retain_hwhandler == RETAIN_HWHANDLER_UNDEF) { + condlog(3, "%s: %s = on (inherited setting from feature '%s')", + id, r_a_h_h, r_a_h_h); + *retain_hwhandler = RETAIN_HWHANDLER_ON; + } else if (*retain_hwhandler == RETAIN_HWHANDLER_OFF) + condlog(2, "%s: ignoring feature '%s' because %s is set to 'off'", + id, r_a_h_h, r_a_h_h); + remove_feature(features, r_a_h_h); + } +} + int select_features(struct config *conf, struct multipath *mp) { char *origin; @@ -280,19 +334,11 @@ int select_features(struct config *conf, struct multipath *mp) mp_set_default(features, DEFAULT_FEATURES); out: mp->features = STRDUP(mp->features); - condlog(3, "%s: features = \"%s\" %s", mp->alias, mp->features, origin); - if (strstr(mp->features, "queue_if_no_path")) { - if (mp->no_path_retry == NO_PATH_RETRY_UNDEF) - mp->no_path_retry = NO_PATH_RETRY_QUEUE; - else if (mp->no_path_retry == NO_PATH_RETRY_FAIL) { - condlog(1, "%s: config error, overriding 'no_path_retry' value", - mp->alias); - mp->no_path_retry = NO_PATH_RETRY_QUEUE; - } else if (mp->no_path_retry != NO_PATH_RETRY_QUEUE) - condlog(1, "%s: config error, ignoring 'queue_if_no_path' because no_path_retry=%d", - mp->alias, mp->no_path_retry); - } + reconcile_features_with_options(mp->alias, &mp->features, + &mp->no_path_retry, + &mp->retain_hwhandler); + condlog(3, "%s: features = \"%s\" %s", mp->alias, mp->features, origin); return 0; } @@ -333,11 +379,11 @@ out: pp->dev, c->timeout); } else if (sysfs_get_timeout(pp, &c->timeout) > 0) - condlog(3, "%s: checker timeout = %u ms (setting: kernel sysfs)", + condlog(3, "%s: checker timeout = %u s (setting: kernel sysfs)", pp->dev, c->timeout); else { c->timeout = DEF_TIMEOUT; - condlog(3, "%s: checker timeout = %u ms (setting: multipath internal)", + condlog(3, "%s: checker timeout = %u s (setting: multipath internal)", pp->dev, c->timeout); } return 0; @@ -456,7 +502,7 @@ int select_no_path_retry(struct config *conf, struct multipath *mp) char buff[12]; if (mp->flush_on_last_del == FLUSH_IN_PROGRESS) { - condlog(0, "flush_on_last_del in progress"); + condlog(0, "%s: flush_on_last_del in progress", mp->alias); mp->no_path_retry = NO_PATH_RETRY_FAIL; return 0; } @@ -469,9 +515,6 @@ out: if (origin) condlog(3, "%s: no_path_retry = %s %s", mp->alias, buff, origin); - else if (mp->no_path_retry != NO_PATH_RETRY_UNDEF) - condlog(3, "%s: no_path_retry = %s (inherited setting)", - mp->alias, buff); else condlog(3, "%s: no_path_retry = undef (setting: multipath internal)", mp->alias); @@ -585,7 +628,12 @@ int select_retain_hwhandler(struct config *conf, struct multipath *mp) if (!VERSION_GE(conf->version, minv_dm_retain)) { mp->retain_hwhandler = RETAIN_HWHANDLER_OFF; - origin = "(setting: WARNING, requires kernel version >= 1.5.0)"; + origin = "(setting: WARNING, requires kernel dm-mpath version >= 1.5.0)"; + goto out; + } + if (get_linux_version_code() >= KERNEL_VERSION(4, 3, 0)) { + mp->retain_hwhandler = RETAIN_HWHANDLER_ON; + origin = "(setting: implied in kernel >= 4.3.0)"; goto out; } mp_set_ovr(retain_hwhandler); @@ -744,8 +792,7 @@ out: return 0; } -extern int -select_max_sectors_kb (struct config *conf, struct multipath * mp) +int select_max_sectors_kb(struct config *conf, struct multipath * mp) { char *origin; @@ -753,6 +800,12 @@ select_max_sectors_kb (struct config *conf, struct multipath * mp) mp_set_ovr(max_sectors_kb); mp_set_hwe(max_sectors_kb); mp_set_conf(max_sectors_kb); + mp_set_default(max_sectors_kb, DEFAULT_MAX_SECTORS_KB); + /* + * In the default case, we will not modify max_sectors_kb in sysfs + * (see sysfs_set_max_sectors_kb()). + * Don't print a log message here to avoid user confusion. + */ return 0; out: condlog(3, "%s: max_sectors_kb = %i %s", mp->alias, mp->max_sectors_kb, |