From patchwork Thu Nov 2 22:15:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13444221 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43B9722314 for ; Thu, 2 Nov 2023 22:15:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="R5Nhbprd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698963313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BpKgINVMTKy9vo4g+jpsOQB6JjueO19KLwPqwoXDtNw=; b=R5NhbprdE5tdEh2UNgpfi/dhfrcOF5sc6zFOHT0KQg7T08FHc+LsRlgo+bPdkMVPpK1I+l 6i4HfE2o061RdKG1v/eipiKsZO04fcOueoesNxgZ1Uyw6nxEV4AWmkGKeZkbNwJlhgqbjC 5V5LYZ4DavM+B8/FrPS2dxhzUA3EM+Y= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-96-Wt7gP8boOgaNw9lpvHqZog-1; Thu, 02 Nov 2023 18:15:08 -0400 X-MC-Unique: Wt7gP8boOgaNw9lpvHqZog-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F35D91C113F5; Thu, 2 Nov 2023 22:15:07 +0000 (UTC) Received: from bmarzins-01.fast.rdu2.eng.redhat.com (bmarzins-01.fast.rdu2.eng.redhat.com [10.6.23.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EBF7F1C060BA; Thu, 2 Nov 2023 22:15:07 +0000 (UTC) Received: from bmarzins-01.fast.rdu2.eng.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.rdu2.eng.redhat.com (8.17.1/8.17.1) with ESMTPS id 3A2MF7Fv105381 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 2 Nov 2023 18:15:07 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.rdu2.eng.redhat.com (8.17.1/8.17.1/Submit) id 3A2MF7aL105380; Thu, 2 Nov 2023 18:15:07 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 1/7] libmultipath: Add max_retries config option Date: Thu, 2 Nov 2023 18:15:01 -0400 Message-ID: <20231102221507.105371-2-bmarzins@redhat.com> In-Reply-To: <20231102221507.105371-1-bmarzins@redhat.com> References: <20231102221507.105371-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This option lets multipath set a scsi disk's max_retries sysfs value. Setting this can be helpful for cases where the path checker succeeds, but IO commands hang and timeout. By default, the SCSI layer will retry IOs 5 times. Reducing this value will allow multipath to retry the IO down another path sooner. Signed-off-by: Benjamin Marzinski --- libmultipath/config.c | 3 +++ libmultipath/config.h | 3 +++ libmultipath/dict.c | 34 ++++++++++++++++++++++++++++ libmultipath/discovery.c | 42 ++++++++++++++++++++++++++++++++++- libmultipath/propsel.c | 18 +++++++++++++++ libmultipath/propsel.h | 1 + libmultipath/structs.h | 7 ++++++ multipath/multipath.conf.5.in | 22 ++++++++++++++++++ 8 files changed, 129 insertions(+), 1 deletion(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index b7dbc6f5..9d90f512 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -420,6 +420,7 @@ merge_pce(struct pcentry *dst, struct pcentry *src) merge_num(fast_io_fail); merge_num(dev_loss); merge_num(eh_deadline); + merge_num(max_retries); } static void @@ -448,6 +449,7 @@ merge_hwe (struct hwentry * dst, struct hwentry * src) merge_num(fast_io_fail); merge_num(dev_loss); merge_num(eh_deadline); + merge_num(max_retries); merge_num(user_friendly_names); merge_num(retain_hwhandler); merge_num(detect_prio); @@ -615,6 +617,7 @@ store_hwe (vector hwtable, struct hwentry * dhwe) hwe->fast_io_fail = dhwe->fast_io_fail; hwe->dev_loss = dhwe->dev_loss; hwe->eh_deadline = dhwe->eh_deadline; + hwe->max_retries = dhwe->max_retries; hwe->user_friendly_names = dhwe->user_friendly_names; hwe->retain_hwhandler = dhwe->retain_hwhandler; hwe->detect_prio = dhwe->detect_prio; diff --git a/libmultipath/config.h b/libmultipath/config.h index 8c22ce75..197a567f 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -47,6 +47,7 @@ struct pcentry { int fast_io_fail; unsigned int dev_loss; int eh_deadline; + int max_retries; }; struct hwentry { @@ -72,6 +73,7 @@ struct hwentry { int fast_io_fail; unsigned int dev_loss; int eh_deadline; + int max_retries; int user_friendly_names; int retain_hwhandler; int detect_prio; @@ -162,6 +164,7 @@ struct config { int fast_io_fail; unsigned int dev_loss; int eh_deadline; + int max_retries; int log_checker_err; int allow_queueing; int allow_usb_devices; diff --git a/libmultipath/dict.c b/libmultipath/dict.c index 044067af..fc438947 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -1152,6 +1152,36 @@ declare_hw_snprint(eh_deadline, print_undef_off_zero) declare_pc_handler(eh_deadline, set_undef_off_zero) declare_pc_snprint(eh_deadline, print_undef_off_zero) +static int +set_max_retries(vector strvec, void *ptr, const char *file, int line_nr) +{ + char * buff; + int *int_ptr = (int *)ptr; + + buff = set_value(strvec); + if (!buff) + return 1; + + if (strcmp(buff, "off") == 0) + *int_ptr = UOZ_OFF; + else if (strcmp(buff, "0") == 0) + *int_ptr = UOZ_ZERO; + else + do_set_int(strvec, int_ptr, 1, 5, file, line_nr, buff); + + free(buff); + return 0; +} + +declare_def_handler(max_retries, set_max_retries) +declare_def_snprint(max_retries, print_undef_off_zero) +declare_ovr_handler(max_retries, set_max_retries) +declare_ovr_snprint(max_retries, print_undef_off_zero) +declare_hw_handler(max_retries, set_max_retries) +declare_hw_snprint(max_retries, print_undef_off_zero) +declare_pc_handler(max_retries, set_max_retries) +declare_pc_snprint(max_retries, print_undef_off_zero) + static int set_pgpolicy(vector strvec, void *ptr, const char *file, int line_nr) { @@ -2079,6 +2109,7 @@ init_keywords(vector keywords) install_keyword("fast_io_fail_tmo", &def_fast_io_fail_handler, &snprint_def_fast_io_fail); install_keyword("dev_loss_tmo", &def_dev_loss_handler, &snprint_def_dev_loss); install_keyword("eh_deadline", &def_eh_deadline_handler, &snprint_def_eh_deadline); + install_keyword("max_retries", &def_max_retries_handler, &snprint_def_max_retries); install_keyword("bindings_file", &deprecated_bindings_file_handler, &snprint_deprecated); install_keyword("wwids_file", &deprecated_wwids_file_handler, &snprint_deprecated); install_keyword("prkeys_file", &deprecated_prkeys_file_handler, &snprint_deprecated); @@ -2176,6 +2207,7 @@ init_keywords(vector keywords) install_keyword("fast_io_fail_tmo", &hw_fast_io_fail_handler, &snprint_hw_fast_io_fail); install_keyword("dev_loss_tmo", &hw_dev_loss_handler, &snprint_hw_dev_loss); install_keyword("eh_deadline", &hw_eh_deadline_handler, &snprint_hw_eh_deadline); + install_keyword("max_retries", &hw_max_retries_handler, &snprint_hw_max_retries); install_keyword("user_friendly_names", &hw_user_friendly_names_handler, &snprint_hw_user_friendly_names); install_keyword("retain_attached_hw_handler", &hw_retain_hwhandler_handler, &snprint_hw_retain_hwhandler); install_keyword("detect_prio", &hw_detect_prio_handler, &snprint_hw_detect_prio); @@ -2220,6 +2252,7 @@ init_keywords(vector keywords) install_keyword("fast_io_fail_tmo", &ovr_fast_io_fail_handler, &snprint_ovr_fast_io_fail); install_keyword("dev_loss_tmo", &ovr_dev_loss_handler, &snprint_ovr_dev_loss); install_keyword("eh_deadline", &ovr_eh_deadline_handler, &snprint_ovr_eh_deadline); + install_keyword("max_retries", &ovr_max_retries_handler, &snprint_ovr_max_retries); install_keyword("user_friendly_names", &ovr_user_friendly_names_handler, &snprint_ovr_user_friendly_names); install_keyword("retain_attached_hw_handler", &ovr_retain_hwhandler_handler, &snprint_ovr_retain_hwhandler); install_keyword("detect_prio", &ovr_detect_prio_handler, &snprint_ovr_detect_prio); @@ -2248,6 +2281,7 @@ init_keywords(vector keywords) install_keyword("fast_io_fail_tmo", &pc_fast_io_fail_handler, &snprint_pc_fast_io_fail); install_keyword("dev_loss_tmo", &pc_dev_loss_handler, &snprint_pc_dev_loss); install_keyword("eh_deadline", &pc_eh_deadline_handler, &snprint_pc_eh_deadline); + install_keyword("max_retries", &pc_max_retries_handler, &snprint_pc_max_retries); install_sublevel_end(); install_keyword_root("multipaths", &multipaths_handler); diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 84ce5fe7..ee261d90 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -614,6 +614,43 @@ sysfs_set_eh_deadline(struct path *pp) return (ret <= 0); } +static int +sysfs_set_max_retries(struct path *pp) +{ + struct udev_device *parent; + char value[16]; + STRBUF_ON_STACK(buf); + int ret, len; + + if (pp->max_retries == MAX_RETRIES_UNSET) + return 0; + + if (!pp->udev || pp->sg_id.host_no < 0) + return 1; + + len = sprintf(value, "%d", (pp->max_retries == MAX_RETRIES_OFF)? -1 : + (pp->max_retries == MAX_RETRIES_ZERO)? 0 : + pp->max_retries); + + parent = udev_device_get_parent_with_subsystem_devtype(pp->udev, + "scsi", "scsi_device"); + if (!parent) + return 1; + + if (print_strbuf(&buf, "scsi_disk/%i:%i:%i:%" PRIu64 "/max_retries", + pp->sg_id.host_no, pp->sg_id.channel, + pp->sg_id.scsi_id, pp->sg_id.lun) < 0) + return 1; + + ret = sysfs_attr_set_value(parent, get_strbuf_str(&buf), value, len); + if (len != ret) + log_sysfs_attr_set_value(3, ret, + "%s/%s: failed to set value to %s", + udev_device_get_sysname(parent), + get_strbuf_str(&buf), value); + return (len != ret); +} + static void sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp) { @@ -875,10 +912,12 @@ sysfs_set_scsi_tmo (struct config *conf, struct multipath *mpp) select_fast_io_fail(conf, pp); select_dev_loss(conf, pp); select_eh_deadline(conf, pp); + select_max_retries(conf, pp); if (pp->dev_loss == DEV_LOSS_TMO_UNSET && pp->fast_io_fail == MP_FAST_IO_FAIL_UNSET && - pp->eh_deadline == EH_DEADLINE_UNSET) + pp->eh_deadline == EH_DEADLINE_UNSET && + pp->max_retries == MAX_RETRIES_UNSET) continue; if (pp->bus != SYSFS_BUS_SCSI) { @@ -886,6 +925,7 @@ sysfs_set_scsi_tmo (struct config *conf, struct multipath *mpp) continue; } sysfs_set_eh_deadline(pp); + sysfs_set_max_retries(pp); if (pp->dev_loss == DEV_LOSS_TMO_UNSET && pp->fast_io_fail == MP_FAST_IO_FAIL_UNSET) diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index 44241e2a..15abb9e5 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -960,6 +960,24 @@ out: return 0; } +int select_max_retries(struct config *conf, struct path *pp) +{ + const char *origin; + STRBUF_ON_STACK(buff); + + pp_set_ovr_pce(max_retries); + pp_set_hwe(max_retries); + pp_set_conf(max_retries); + pp->max_retries = MAX_RETRIES_UNSET; + /* not changing sysfs in default cause, so don't print anything */ + return 0; +out: + print_undef_off_zero(&buff, pp->max_retries); + condlog(3, "%s: max_retries = %s %s", pp->dev, + get_strbuf_str(&buff), origin); + return 0; +} + int select_flush_on_last_del(struct config *conf, struct multipath *mp) { const char *origin; diff --git a/libmultipath/propsel.h b/libmultipath/propsel.h index 73615c2f..7203509e 100644 --- a/libmultipath/propsel.h +++ b/libmultipath/propsel.h @@ -21,6 +21,7 @@ int select_gid(struct config *conf, struct multipath *mp); int select_fast_io_fail(struct config *conf, struct path *pp); int select_dev_loss(struct config *conf, struct path *pp); int select_eh_deadline(struct config *conf, struct path *pp); +int select_max_retries(struct config *conf, struct path *pp); int select_reservation_key(struct config *conf, struct multipath *mp); int select_retain_hwhandler (struct config *conf, struct multipath * mp); int select_detect_prio(struct config *conf, struct path * pp); diff --git a/libmultipath/structs.h b/libmultipath/structs.h index 17e13ee7..c20e99ce 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -295,6 +295,12 @@ enum eh_deadline_states { EH_DEADLINE_ZERO = UOZ_ZERO, }; +enum max_retries_states { + MAX_RETRIES_UNSET = UOZ_UNDEF, + MAX_RETRIES_OFF = UOZ_OFF, + MAX_RETRIES_ZERO = UOZ_ZERO, +}; + enum recheck_wwid_states { RECHECK_WWID_UNDEF = YNU_UNDEF, RECHECK_WWID_OFF = YNU_NO, @@ -381,6 +387,7 @@ struct path { int fast_io_fail; unsigned int dev_loss; int eh_deadline; + int max_retries; bool is_checked; bool can_use_env_uid; unsigned int checker_timeout; diff --git a/multipath/multipath.conf.5.in b/multipath/multipath.conf.5.in index 226d0019..41f3927e 100644 --- a/multipath/multipath.conf.5.in +++ b/multipath/multipath.conf.5.in @@ -793,6 +793,22 @@ The default is: \fB\fR . . .TP +.B max_retries +Specify the maximum number of times the SCSI layer will retry IO commands +before returning failure. Setting this can be helpful for cases where the path +checker succeeds, but IO commands hang and timeout. By default, the SCSI layer +will retry IOs 5 times. Reducing this value will allow multipath to retry the IO +down another path sooner. \fBNote:\fR If it is necessary to set this value, it +is also recommended to set up shaky paths detection. See "Shaky paths detection" +below. Valid values are +\fB0\fR through \fB5\fR. +.RS +.TP +The default is: \fB\fR +.RE +. +. +.TP .B bindings_file (Deprecated) This option is not supported any more, and will be ignored. .RS @@ -1687,6 +1703,8 @@ section: .TP .B eh_deadline .TP +.B max_retries +.TP .B flush_on_last_del .TP .B user_friendly_names @@ -1773,6 +1791,8 @@ the values are taken from the \fIdevices\fR or \fIdefaults\fR sections: .TP .B eh_deadline .TP +.B max_retries +.TP .B user_friendly_names .TP .B retain_attached_hw_handler @@ -1844,6 +1864,8 @@ from the \fIoverrides\fR, \fIdevices\fR, or \fIdefaults\fR section: .B dev_loss_tmo .TP .B eh_deadline +.TP +.B max_retries .PD . . From patchwork Thu Nov 2 22:15:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13444214 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E810722305 for ; Thu, 2 Nov 2023 22:15:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DDRONkuE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698963310; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5ZAliMUydK520JzF6o3wXCzSMwEO0o+8lW6N/5W4hxM=; b=DDRONkuElhfmo1JYefuECbyEQsTkxeY9+LTFsgbluQmM3UZWnJqnDYhHrVi4ZZ70pBnwdE 4ZnyEe8X5lKuOwOlwiPFgRBkOaijWjo5dpObzTRNl89rfv9rN3pED+k3yI7K7BvQtTF4Rp JdpwkaFOjkialtoNL3gT2Q16l1hFnzA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-586-Yra5K17IMMiOUR-9tPGiHQ-1; Thu, 02 Nov 2023 18:15:08 -0400 X-MC-Unique: Yra5K17IMMiOUR-9tPGiHQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2576C811E86; Thu, 2 Nov 2023 22:15:08 +0000 (UTC) Received: from bmarzins-01.fast.rdu2.eng.redhat.com (bmarzins-01.fast.rdu2.eng.redhat.com [10.6.23.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1EB151121308; Thu, 2 Nov 2023 22:15:08 +0000 (UTC) Received: from bmarzins-01.fast.rdu2.eng.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.rdu2.eng.redhat.com (8.17.1/8.17.1) with ESMTPS id 3A2MF7gj105385 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 2 Nov 2023 18:15:07 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.rdu2.eng.redhat.com (8.17.1/8.17.1/Submit) id 3A2MF76h105384; Thu, 2 Nov 2023 18:15:07 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 2/7] libmutipath: Retain device size if sysfs_get_size fails. Date: Thu, 2 Nov 2023 18:15:02 -0400 Message-ID: <20231102221507.105371-3-bmarzins@redhat.com> In-Reply-To: <20231102221507.105371-1-bmarzins@redhat.com> References: <20231102221507.105371-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com When paths are allocated their size is initialized to 0. If they've already set a size, and a future call to sysfs_get_size() fails during the parsing, assume that the size hasn't changed, instead of setting it to 0. All other failures in sysfs_get_size() already retain the existing size. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/sysfs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c index c45296af..ad3d6612 100644 --- a/libmultipath/sysfs.c +++ b/libmultipath/sysfs.c @@ -175,7 +175,6 @@ sysfs_get_size (struct path *pp, unsigned long long * size) if (r != 1) { condlog(3, "%s: Cannot parse size attribute", pp->dev); - *size = 0; return 1; } From patchwork Thu Nov 2 22:15:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13444215 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D940522307 for ; Thu, 2 Nov 2023 22:15:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JpIAxWvF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698963311; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CkE5qHycvo1QgorBkeB/8Mndk/HBQ4J9v9qUjmpEX9I=; b=JpIAxWvFWm90d+ts2Ufa1/xKx1Er1Qq87LAwURNpgCZUDwm8EITT476lRlhR82LcJoU/e6 ITUruXm0QgNFBvcUlCEfLMnQtDa7rao9W2jZlu1IcE6rzHGh/95KLsVHILnq3GQWIlrEkP ooi/ef1KQPgZ549Dv9yB5jcRkQQlU04= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-PGA1jCHXP2C-oA0od6Of8g-1; Thu, 02 Nov 2023 18:15:08 -0400 X-MC-Unique: PGA1jCHXP2C-oA0od6Of8g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 49F8C811E88; Thu, 2 Nov 2023 22:15:08 +0000 (UTC) Received: from bmarzins-01.fast.rdu2.eng.redhat.com (bmarzins-01.fast.rdu2.eng.redhat.com [10.6.23.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 438AD1121308; Thu, 2 Nov 2023 22:15:08 +0000 (UTC) Received: from bmarzins-01.fast.rdu2.eng.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.rdu2.eng.redhat.com (8.17.1/8.17.1) with ESMTPS id 3A2MF8LR105389 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 2 Nov 2023 18:15:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.rdu2.eng.redhat.com (8.17.1/8.17.1/Submit) id 3A2MF8NF105388; Thu, 2 Nov 2023 18:15:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 3/7] multipathd: check and update all paths when in cli_resize Date: Thu, 2 Nov 2023 18:15:03 -0400 Message-ID: <20231102221507.105371-4-bmarzins@redhat.com> In-Reply-To: <20231102221507.105371-1-bmarzins@redhat.com> References: <20231102221507.105371-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com When resizing a multipath device, make sure that all the paths have been updated to the new size first. Signed-off-by: Benjamin Marzinski --- multipathd/cli_handlers.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index c9addfbb..ffea193d 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -845,9 +845,11 @@ cli_resize(void *v, struct strbuf *reply, void *data) char * mapname = get_keyparam(v, KEY_MAP); struct multipath *mpp; int minor; - unsigned long long size; + unsigned long long size = 0; struct pathgroup *pgp; struct path *pp; + unsigned int i, j; + bool mismatch = false; mapname = convert_dev(mapname, 0); condlog(2, "%s: resize map (operator)", mapname); @@ -867,21 +869,23 @@ cli_resize(void *v, struct strbuf *reply, void *data) return 1; } - pgp = VECTOR_SLOT(mpp->pg, 0); - - if (!pgp){ - condlog(0, "%s: couldn't get path group. cannot resize", - mapname); - return 1; + vector_foreach_slot(mpp->pg, pgp, i) { + vector_foreach_slot (pgp->paths, pp, j) { + if (sysfs_get_size(pp, &pp->size) != 0) + continue; + if (!size) + size = pp->size; + else if (pp->size != size) + mismatch = true; + } } - pp = VECTOR_SLOT(pgp->paths, 0); - - if (!pp){ - condlog(0, "%s: couldn't get path. cannot resize", mapname); + if (!size) { + condlog(0, "%s: couldn't get size from sysfs. cannot resize", + mapname); return 1; } - if (!pp->udev || sysfs_get_size(pp, &size)) { - condlog(0, "%s: couldn't get size for sysfs. cannot resize", + if (mismatch) { + condlog(0, "%s: path size not consistent. cannot resize", mapname); return 1; } From patchwork Thu Nov 2 22:15:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13444216 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1A352230A for ; Thu, 2 Nov 2023 22:15:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QqRfWsVL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698963312; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x+Z2QL9SRYaf1MtcoKgr57YoB5TE//TigmXP9oIgwu4=; b=QqRfWsVLOQA1711ibyehG8Cb8xWOIDU7j78ygLwfnRsD6oBxcJmJOOwjIlExYFj/HOVD+m Kzjf2IbBK9JoK4M7aH7jKVJ9xzieUnX5uXbpwZBB6B7iZucq0yQQetxgCdUvmh1sGJqxxC Quyor1I5byoud+MJfYvvSBrV19EdFoA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-592-DzQUhMr9O2G1s11K10CEog-1; Thu, 02 Nov 2023 18:15:08 -0400 X-MC-Unique: DzQUhMr9O2G1s11K10CEog-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6E5B8185A784; Thu, 2 Nov 2023 22:15:08 +0000 (UTC) Received: from bmarzins-01.fast.rdu2.eng.redhat.com (bmarzins-01.fast.rdu2.eng.redhat.com [10.6.23.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 68324C1290F; Thu, 2 Nov 2023 22:15:08 +0000 (UTC) Received: from bmarzins-01.fast.rdu2.eng.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.rdu2.eng.redhat.com (8.17.1/8.17.1) with ESMTPS id 3A2MF8ra105393 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 2 Nov 2023 18:15:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.rdu2.eng.redhat.com (8.17.1/8.17.1/Submit) id 3A2MF8pP105392; Thu, 2 Nov 2023 18:15:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 4/7] multipathd: move post-reloading commands into resize_map() Date: Thu, 2 Nov 2023 18:15:04 -0400 Message-ID: <20231102221507.105371-5-bmarzins@redhat.com> In-Reply-To: <20231102221507.105371-1-bmarzins@redhat.com> References: <20231102221507.105371-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com In preparation for reusing resize_map() in other code, move all code necessary to resize the map to the resize_map() function. Also track if map was removed in the function. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- multipathd/cli_handlers.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index ffea193d..8eb19fdf 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -835,6 +835,10 @@ static int resize_map(struct multipath *mpp, unsigned long long size, mpp->size = orig_size; return 1; } + if (setup_multipath(vecs, mpp) != 0) + return 2; + sync_map_state(mpp); + return 0; } @@ -848,7 +852,7 @@ cli_resize(void *v, struct strbuf *reply, void *data) unsigned long long size = 0; struct pathgroup *pgp; struct path *pp; - unsigned int i, j; + unsigned int i, j, ret; bool mismatch = false; mapname = convert_dev(mapname, 0); @@ -897,14 +901,12 @@ cli_resize(void *v, struct strbuf *reply, void *data) condlog(3, "%s old size is %llu, new size is %llu", mapname, mpp->size, size); - if (resize_map(mpp, size, vecs) != 0) - return 1; + ret = resize_map(mpp, size, vecs); - if (setup_multipath(vecs, mpp) != 0) - return 1; - sync_map_state(mpp); + if (ret == 2) + condlog(0, "%s: map removed while trying to resize", mapname); - return 0; + return (ret != 0); } static int From patchwork Thu Nov 2 22:15:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13444217 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49EF322309 for ; Thu, 2 Nov 2023 22:15:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Yvz1XcbP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698963312; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NzvmRDlJ0zcD26J0/dx4kKp3gsLLhD59vghkJ7iFSiA=; b=Yvz1XcbPiZ9Y+JRkfXxyUMULwRvBWWxMsyWoVZZ+8NzsjkuJUVW1ae0TRsmYVo9dDToiYV G0wIyUTCFgJHP8c/WrIU3I4MSh6d+betJlvVTSajqmkZU9LjlKMBLAr3w7EKAvIugJSBBg m21nYrfSjIkUTdZq4nrAHEhYF6knJn0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-592-1gDORuSkMr2CEL314yLvwg-1; Thu, 02 Nov 2023 18:15:08 -0400 X-MC-Unique: 1gDORuSkMr2CEL314yLvwg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9238C85A58A; Thu, 2 Nov 2023 22:15:08 +0000 (UTC) Received: from bmarzins-01.fast.rdu2.eng.redhat.com (bmarzins-01.fast.rdu2.eng.redhat.com [10.6.23.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C1DE10E65; Thu, 2 Nov 2023 22:15:08 +0000 (UTC) Received: from bmarzins-01.fast.rdu2.eng.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.rdu2.eng.redhat.com (8.17.1/8.17.1) with ESMTPS id 3A2MF8QW105397 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 2 Nov 2023 18:15:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.rdu2.eng.redhat.com (8.17.1/8.17.1/Submit) id 3A2MF8US105396; Thu, 2 Nov 2023 18:15:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 5/7] multipathd: move resize_map() to multipathd/main.c Date: Thu, 2 Nov 2023 18:15:05 -0400 Message-ID: <20231102221507.105371-6-bmarzins@redhat.com> In-Reply-To: <20231102221507.105371-1-bmarzins@redhat.com> References: <20231102221507.105371-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com No functional changes. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- multipathd/cli_handlers.c | 29 ----------------------------- multipathd/main.c | 29 +++++++++++++++++++++++++++++ multipathd/main.h | 2 ++ 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 8eb19fdf..a4ed2031 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -813,35 +813,6 @@ cli_reload(void *v, struct strbuf *reply, void *data) return reload_and_sync_map(mpp, vecs); } -static int resize_map(struct multipath *mpp, unsigned long long size, - struct vectors * vecs) -{ - char *params __attribute__((cleanup(cleanup_charp))) = NULL; - unsigned long long orig_size = mpp->size; - - mpp->size = size; - update_mpp_paths(mpp, vecs->pathvec); - if (setup_map(mpp, ¶ms, vecs) != 0) { - condlog(0, "%s: failed to setup map for resize : %s", - mpp->alias, strerror(errno)); - mpp->size = orig_size; - return 1; - } - mpp->action = ACT_RESIZE; - mpp->force_udev_reload = 1; - if (domap(mpp, params, 1) == DOMAP_FAIL) { - condlog(0, "%s: failed to resize map : %s", mpp->alias, - strerror(errno)); - mpp->size = orig_size; - return 1; - } - if (setup_multipath(vecs, mpp) != 0) - return 2; - sync_map_state(mpp); - - return 0; -} - static int cli_resize(void *v, struct strbuf *reply, void *data) { diff --git a/multipathd/main.c b/multipathd/main.c index 214ed4ae..3b4c5b09 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1530,6 +1530,35 @@ needs_ro_update(struct multipath *mpp, int ro) return true; } +int resize_map(struct multipath *mpp, unsigned long long size, + struct vectors * vecs) +{ + char *params __attribute__((cleanup(cleanup_charp))) = NULL; + unsigned long long orig_size = mpp->size; + + mpp->size = size; + update_mpp_paths(mpp, vecs->pathvec); + if (setup_map(mpp, ¶ms, vecs) != 0) { + condlog(0, "%s: failed to setup map for resize : %s", + mpp->alias, strerror(errno)); + mpp->size = orig_size; + return 1; + } + mpp->action = ACT_RESIZE; + mpp->force_udev_reload = 1; + if (domap(mpp, params, 1) == DOMAP_FAIL) { + condlog(0, "%s: failed to resize map : %s", mpp->alias, + strerror(errno)); + mpp->size = orig_size; + return 1; + } + if (setup_multipath(vecs, mpp) != 0) + return 2; + sync_map_state(mpp); + + return 0; +} + static int uev_update_path (struct uevent *uev, struct vectors * vecs) { diff --git a/multipathd/main.h b/multipathd/main.h index a253d186..8a178c0b 100644 --- a/multipathd/main.h +++ b/multipathd/main.h @@ -52,4 +52,6 @@ int reload_and_sync_map(struct multipath *mpp, struct vectors *vecs); void handle_path_wwid_change(struct path *pp, struct vectors *vecs); bool check_path_wwid_change(struct path *pp); int finish_path_init(struct path *pp, struct vectors * vecs); +int resize_map(struct multipath *mpp, unsigned long long size, + struct vectors *vecs); #endif /* MAIN_H */ From patchwork Thu Nov 2 22:15:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13444219 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6C8422306 for ; Thu, 2 Nov 2023 22:15:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YzKfdBNb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698963311; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5klUfv0qZ7Syso87DLDp0l1eHcgKTNuw9FeoBJXq094=; b=YzKfdBNbCycUGxVXpfqNYeT+9zEcbgVMp4AFAUht2/QBq4/UxCi6G0t1cq7M+USePsi07Y 2xysNMoh+Hsbj48RznsFxL2X6wlqHEATDHP+dZytOBco51OKS29N/PDTVrOPU+117fIN7F /GF8/ur4Qsy2YyoWrFgB+6YyDbWKa68= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-146-2HzPPQ7fM0i1HjHjYDD8AQ-1; Thu, 02 Nov 2023 18:15:09 -0400 X-MC-Unique: 2HzPPQ7fM0i1HjHjYDD8AQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B914D1C113F8; Thu, 2 Nov 2023 22:15:08 +0000 (UTC) Received: from bmarzins-01.fast.rdu2.eng.redhat.com (bmarzins-01.fast.rdu2.eng.redhat.com [10.6.23.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B1DC725C0; Thu, 2 Nov 2023 22:15:08 +0000 (UTC) Received: from bmarzins-01.fast.rdu2.eng.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.rdu2.eng.redhat.com (8.17.1/8.17.1) with ESMTPS id 3A2MF8rb105401 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 2 Nov 2023 18:15:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.rdu2.eng.redhat.com (8.17.1/8.17.1/Submit) id 3A2MF8NX105400; Thu, 2 Nov 2023 18:15:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 6/7] multipathd: Add auto_resize config option Date: Thu, 2 Nov 2023 18:15:06 -0400 Message-ID: <20231102221507.105371-7-bmarzins@redhat.com> In-Reply-To: <20231102221507.105371-1-bmarzins@redhat.com> References: <20231102221507.105371-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This option gives multipathd the ability to automatically resize a device when it detects that all of the path devices have changed. By default it is set to never, and multipathd will continue to work like it always has, where a users must manually resize a multipath device. Signed-off-by: Benjamin Marzinski --- libmultipath/config.c | 2 ++ libmultipath/config.h | 3 +++ libmultipath/configure.c | 1 + libmultipath/defaults.h | 1 + libmultipath/dict.c | 48 +++++++++++++++++++++++++++++++++++ libmultipath/dict.h | 1 + libmultipath/hwtable.c | 1 + libmultipath/propsel.c | 17 +++++++++++++ libmultipath/propsel.h | 1 + libmultipath/structs.h | 8 ++++++ multipath/multipath.conf.5.in | 16 ++++++++++++ multipathd/main.c | 24 +++++++++++++++++- 12 files changed, 122 insertions(+), 1 deletion(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index 9d90f512..e6024955 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -464,6 +464,7 @@ merge_hwe (struct hwentry * dst, struct hwentry * src) merge_num(ghost_delay); merge_num(all_tg_pt); merge_num(recheck_wwid); + merge_num(auto_resize); merge_num(vpd_vendor_id); merge_num(san_path_err_threshold); merge_num(san_path_err_forget_rate); @@ -519,6 +520,7 @@ merge_mpe(struct mpentry *dst, struct mpentry *src) merge_num(skip_kpartx); merge_num(max_sectors_kb); merge_num(ghost_delay); + merge_num(auto_resize); merge_num(uid); merge_num(gid); merge_num(mode); diff --git a/libmultipath/config.h b/libmultipath/config.h index 197a567f..3be8e507 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -96,6 +96,7 @@ struct hwentry { int all_tg_pt; int vpd_vendor_id; int recheck_wwid; + int auto_resize; char * bl_product; vector pctable; @@ -135,6 +136,7 @@ struct mpentry { int skip_kpartx; int max_sectors_kb; int ghost_delay; + int auto_resize; uid_t uid; gid_t gid; mode_t mode; @@ -204,6 +206,7 @@ struct config { int skip_delegate; unsigned int sequence_nr; int recheck_wwid; + int auto_resize; char * selector; struct _vector uid_attrs; diff --git a/libmultipath/configure.c b/libmultipath/configure.c index d8094903..592761b2 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -355,6 +355,7 @@ int setup_map(struct multipath *mpp, char **params, struct vectors *vecs) select_max_sectors_kb(conf, mpp); select_ghost_delay(conf, mpp); select_flush_on_last_del(conf, mpp); + select_auto_resize(conf, mpp); sysfs_set_scsi_tmo(conf, mpp); marginal_pathgroups = conf->marginal_pathgroups; diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h index d01f9712..64b633f2 100644 --- a/libmultipath/defaults.h +++ b/libmultipath/defaults.h @@ -56,6 +56,7 @@ #define DEFAULT_UNKNOWN_FIND_MULTIPATHS_TIMEOUT 1 #define DEFAULT_ALL_TG_PT ALL_TG_PT_OFF #define DEFAULT_RECHECK_WWID RECHECK_WWID_OFF +#define DEFAULT_AUTO_RESIZE AUTO_RESIZE_NEVER /* Enable no foreign libraries by default */ #define DEFAULT_ENABLE_FOREIGN "NONE" diff --git a/libmultipath/dict.c b/libmultipath/dict.c index fc438947..037d717c 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -1670,6 +1670,50 @@ declare_hw_snprint(recheck_wwid, print_yes_no_undef) declare_def_range_handler(uxsock_timeout, DEFAULT_REPLY_TIMEOUT, INT_MAX) +static int +set_auto_resize(vector strvec, void *ptr, const char *file, int line_nr) +{ + char * buff; + int *int_ptr = (int *)ptr; + + buff = set_value(strvec); + if (!buff) + return 1; + + if (strcmp(buff, "never") == 0) + *int_ptr = AUTO_RESIZE_NEVER; + else if (strcmp(buff, "grow_only") == 0) + *int_ptr = AUTO_RESIZE_GROW_ONLY; + else if (strcmp(buff, "grow_shrink") == 0) + *int_ptr = AUTO_RESIZE_GROW_SHRINK; + else + condlog(1, "%s line %d, invalid value for %s: \"%s\"", + file, line_nr, (char*)VECTOR_SLOT(strvec, 0), buff); + + free(buff); + return 0; +} + +int +print_auto_resize(struct strbuf *buff, long v) +{ + if (!v) + return 0; + return append_strbuf_quoted(buff, + v == AUTO_RESIZE_GROW_ONLY ? "grow_only" : + v == AUTO_RESIZE_GROW_SHRINK ? "grow_shrink" : + "never"); +} + +declare_def_handler(auto_resize, set_auto_resize) +declare_def_snprint(auto_resize, print_auto_resize) +declare_ovr_handler(auto_resize, set_auto_resize) +declare_ovr_snprint(auto_resize, print_auto_resize) +declare_hw_handler(auto_resize, set_auto_resize) +declare_hw_snprint(auto_resize, print_auto_resize) +declare_mp_handler(auto_resize, set_auto_resize) +declare_mp_snprint(auto_resize, print_auto_resize) + static int hw_vpd_vendor_handler(struct config *conf, vector strvec, const char *file, int line_nr) @@ -2146,6 +2190,7 @@ init_keywords(vector keywords) install_keyword("remove_retries", &def_remove_retries_handler, &snprint_def_remove_retries); install_keyword("max_sectors_kb", &def_max_sectors_kb_handler, &snprint_def_max_sectors_kb); install_keyword("ghost_delay", &def_ghost_delay_handler, &snprint_def_ghost_delay); + install_keyword("auto_resize", &def_auto_resize_handler, &snprint_def_auto_resize); install_keyword("find_multipaths_timeout", &def_find_multipaths_timeout_handler, &snprint_def_find_multipaths_timeout); @@ -2227,6 +2272,7 @@ init_keywords(vector keywords) install_keyword("skip_kpartx", &hw_skip_kpartx_handler, &snprint_hw_skip_kpartx); install_keyword("max_sectors_kb", &hw_max_sectors_kb_handler, &snprint_hw_max_sectors_kb); install_keyword("ghost_delay", &hw_ghost_delay_handler, &snprint_hw_ghost_delay); + install_keyword("auto_resize", &hw_auto_resize_handler, &snprint_hw_auto_resize); install_keyword("all_tg_pt", &hw_all_tg_pt_handler, &snprint_hw_all_tg_pt); install_keyword("vpd_vendor", &hw_vpd_vendor_handler, &snprint_hw_vpd_vendor); install_keyword("recheck_wwid", &hw_recheck_wwid_handler, &snprint_hw_recheck_wwid); @@ -2273,6 +2319,7 @@ init_keywords(vector keywords) install_keyword("skip_kpartx", &ovr_skip_kpartx_handler, &snprint_ovr_skip_kpartx); install_keyword("max_sectors_kb", &ovr_max_sectors_kb_handler, &snprint_ovr_max_sectors_kb); install_keyword("ghost_delay", &ovr_ghost_delay_handler, &snprint_ovr_ghost_delay); + install_keyword("auto_resize", &ovr_auto_resize_handler, &snprint_ovr_auto_resize); install_keyword("all_tg_pt", &ovr_all_tg_pt_handler, &snprint_ovr_all_tg_pt); install_keyword("recheck_wwid", &ovr_recheck_wwid_handler, &snprint_ovr_recheck_wwid); install_keyword_multi("protocol", &protocol_handler, NULL); @@ -2319,5 +2366,6 @@ init_keywords(vector keywords) install_keyword("skip_kpartx", &mp_skip_kpartx_handler, &snprint_mp_skip_kpartx); install_keyword("max_sectors_kb", &mp_max_sectors_kb_handler, &snprint_mp_max_sectors_kb); install_keyword("ghost_delay", &mp_ghost_delay_handler, &snprint_mp_ghost_delay); + install_keyword("auto_resize", &mp_auto_resize_handler, &snprint_mp_auto_resize); install_sublevel_end(); } diff --git a/libmultipath/dict.h b/libmultipath/dict.h index 15d9cbac..7e2dfbe0 100644 --- a/libmultipath/dict.h +++ b/libmultipath/dict.h @@ -17,4 +17,5 @@ int print_no_path_retry(struct strbuf *buff, long v); int print_undef_off_zero(struct strbuf *buff, long v); int print_dev_loss(struct strbuf *buff, unsigned long v); int print_off_int_undef(struct strbuf *buff, long v); +int print_auto_resize(struct strbuf *buff, long v); #endif /* _DICT_H */ diff --git a/libmultipath/hwtable.c b/libmultipath/hwtable.c index ae6aac79..27a8c9b4 100644 --- a/libmultipath/hwtable.c +++ b/libmultipath/hwtable.c @@ -75,6 +75,7 @@ .skip_kpartx = SKIP_KPARTX_OFF, .max_sectors_kb = MAX_SECTORS_KB_UNDEF, .ghost_delay = GHOST_DELAY_OFF, + .auto_resize = AUTO_RESIZE_NEVER, }, #endif diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index 15abb9e5..2489c00c 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -1423,6 +1423,23 @@ out: return 0; } +int select_auto_resize (struct config *conf, struct multipath * mp) +{ + const char *origin; + STRBUF_ON_STACK(buff); + + mp_set_mpe(auto_resize); + mp_set_ovr(auto_resize); + mp_set_hwe(auto_resize); + mp_set_conf(auto_resize); + mp_set_default(auto_resize, DEFAULT_AUTO_RESIZE); +out: + if (print_auto_resize(&buff, mp->auto_resize) != 0) + condlog(3, "%s: auto_resize = %s %s", mp->alias, + get_strbuf_str(&buff), origin); + return 0; +} + int select_find_multipaths_timeout(struct config *conf, struct path *pp) { const char *origin; diff --git a/libmultipath/propsel.h b/libmultipath/propsel.h index 7203509e..e6941190 100644 --- a/libmultipath/propsel.h +++ b/libmultipath/propsel.h @@ -38,6 +38,7 @@ int select_marginal_path_err_rate_threshold(struct config *conf, struct multipat int select_marginal_path_err_recheck_gap_time(struct config *conf, struct multipath *mp); int select_marginal_path_double_failed_time(struct config *conf, struct multipath *mp); int select_ghost_delay(struct config *conf, struct multipath * mp); +int select_auto_resize(struct config *conf, struct multipath * mp); void reconcile_features_with_options(const char *id, char **features, int* no_path_retry, int *retain_hwhandler); diff --git a/libmultipath/structs.h b/libmultipath/structs.h index c20e99ce..b75e7778 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -179,6 +179,13 @@ enum queue_mode_states { QUEUE_MODE_RQ, }; +enum auto_resize_state { + AUTO_RESIZE_UNDEF = 0, + AUTO_RESIZE_NEVER, + AUTO_RESIZE_GROW_ONLY, + AUTO_RESIZE_GROW_SHRINK, +}; + #define PROTOCOL_UNSET -1 enum scsi_protocol { @@ -447,6 +454,7 @@ struct multipath { int ghost_delay; int ghost_delay_tick; int queue_mode; + int auto_resize; uid_t uid; gid_t gid; mode_t mode; diff --git a/multipath/multipath.conf.5.in b/multipath/multipath.conf.5.in index 41f3927e..c90383cf 100644 --- a/multipath/multipath.conf.5.in +++ b/multipath/multipath.conf.5.in @@ -1333,6 +1333,22 @@ The default is: \fBno\fR . . .TP +.B auto_resize +Controls when multipathd will automatically resize a multipath device. If set +to \fInever\fR, multipath devices must always be manually resized by either +running \fBmultipathd resize map \fR or \fRmultipath -r \fR. If +set to \fIgrow_only\fR, when multipathd detects that all of a multipath +device's paths have increased in size, it will automatically grow the multipath +device to the new size. If set to \fIgrow_shrink\fR, multipathd will also +automatically shrink the device once it detects all of its paths have decreased +in size. +.RS +.TP +The default is: \fBnever\fR +.RE +. +. +.TP .B enable_foreign Enables or disables foreign libraries (see section .I FOREIGN MULTIPATH SUPPORT diff --git a/multipathd/main.c b/multipathd/main.c index 3b4c5b09..ac733491 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1633,7 +1633,6 @@ uev_update_path (struct uevent *uev, struct vectors * vecs) ro = uevent_get_disk_ro(uev); if (needs_ro_update(mpp, ro)) { condlog(2, "%s: update path write_protect to '%d' (uevent)", uev->kernel, ro); - if (mpp->wait_for_udev) mpp->wait_for_udev = 2; else { @@ -1648,6 +1647,29 @@ uev_update_path (struct uevent *uev, struct vectors * vecs) } } } + if (mpp->auto_resize != AUTO_RESIZE_NEVER && + !mpp->wait_for_udev) { + struct pathgroup *pgp; + struct path *pp2; + unsigned int i, j; + unsigned long long orig_size = mpp->size; + + if (!pp->size || pp->size == mpp->size || + (pp->size < mpp->size && + mpp->auto_resize == AUTO_RESIZE_GROW_ONLY)) + goto out; + + vector_foreach_slot(mpp->pg, pgp, i) + vector_foreach_slot (pgp->paths, pp2, j) + if (pp2->size && pp2->size != pp->size) + goto out; + retval = resize_map(mpp, pp->size, vecs); + if (retval == 2) + condlog(2, "%s: map removed during resize", pp->dev); + else if (retval == 0) + condlog(2, "%s: resized map from %llu to %llu", + mpp->alias, orig_size, pp->size); + } } out: lock_cleanup_pop(vecs->lock); From patchwork Thu Nov 2 22:15:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13444218 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88E1722305 for ; Thu, 2 Nov 2023 22:15:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jSSYVEg4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698963314; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Seo/YsF0CJGI92mirzPVWa+4LAPtuI2nxMPtCSmH7wQ=; b=jSSYVEg4z6tq0guPN3/AQKoEq4JOXYAywQt1sdO6zAuxDjNsgISR3c79lSqvcfkpxvS0Bg tEOb6rTQ0Q3oEBXjEVSUhmfNSfAGMI1BW0vc9sfcdkvjHEkRvdNiiWwcGg7p4iFMzPGWTm 3La1N+EghwHPVnlr2xP0is5lhKWQZGg= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-154-t99GOLncOxWxLRZfC0l1TQ-1; Thu, 02 Nov 2023 18:15:09 -0400 X-MC-Unique: t99GOLncOxWxLRZfC0l1TQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E0720280226C; Thu, 2 Nov 2023 22:15:08 +0000 (UTC) Received: from bmarzins-01.fast.rdu2.eng.redhat.com (bmarzins-01.fast.rdu2.eng.redhat.com [10.6.23.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D8960492BFA; Thu, 2 Nov 2023 22:15:08 +0000 (UTC) Received: from bmarzins-01.fast.rdu2.eng.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.rdu2.eng.redhat.com (8.17.1/8.17.1) with ESMTPS id 3A2MF8dN105405 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 2 Nov 2023 18:15:08 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.rdu2.eng.redhat.com (8.17.1/8.17.1/Submit) id 3A2MF8ap105404; Thu, 2 Nov 2023 18:15:08 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH 7/7] libmultipath.version: bump ABI version to 22.0.0 Date: Thu, 2 Nov 2023 18:15:07 -0400 Message-ID: <20231102221507.105371-8-bmarzins@redhat.com> In-Reply-To: <20231102221507.105371-1-bmarzins@redhat.com> References: <20231102221507.105371-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Commits ("libmultipath: Add max_retries config option") and ("multipathd: Add auto_resize config option") changed the size and member offsets of multiple structs. Signed-off-by: Benjamin Marzinski --- libmultipath/libmultipath.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version index 8368ef7a..8ab7c802 100644 --- a/libmultipath/libmultipath.version +++ b/libmultipath/libmultipath.version @@ -43,7 +43,7 @@ LIBMPATHCOMMON_1.0.0 { put_multipath_config; }; -LIBMULTIPATH_21.0.0 { +LIBMULTIPATH_22.0.0 { global: /* symbols referenced by multipath and multipathd */ add_foreign;