From patchwork Mon Jun 30 05:14:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 4445601 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3E67F9F37C for ; Mon, 30 Jun 2014 05:18:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5201E202FE for ; Mon, 30 Jun 2014 05:18:20 +0000 (UTC) Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mail.kernel.org (Postfix) with ESMTP id 3FFEA20221 for ; Mon, 30 Jun 2014 05:18:19 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s5U5FO7H013232; Mon, 30 Jun 2014 01:15:25 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s5U5ERvJ026148 for ; Mon, 30 Jun 2014 01:14:27 -0400 Received: from dhcp80-209.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5U5EQMb023421 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 30 Jun 2014 01:14:27 -0400 Received: from dhcp80-209.msp.redhat.com (localhost [127.0.0.1]) by dhcp80-209.msp.redhat.com (8.14.7/8.14.7) with ESMTP id s5U5EPA1005154; Mon, 30 Jun 2014 00:14:26 -0500 Received: (from bmarzins@localhost) by dhcp80-209.msp.redhat.com (8.14.7/8.14.7/Submit) id s5U5EPVG005153; Mon, 30 Jun 2014 00:14:25 -0500 From: Benjamin Marzinski To: device-mapper development Date: Mon, 30 Jun 2014 00:14:03 -0500 Message-Id: <1404105243-5071-13-git-send-email-bmarzins@redhat.com> In-Reply-To: <1404105243-5071-1-git-send-email-bmarzins@redhat.com> References: <1404105243-5071-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: dm-devel@redhat.com Cc: Christophe Varoqui Subject: [dm-devel] [PATCH 12/12] Add multipath.conf force_sync option X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Normally multipathd runs the path checkers asynchronously. However if there are a lot of paths, this can cause large CPU spikes (for instance, in cases where they are all competing for the Big Kernel Lock). In these situations, overall machine performance is better if multipath doesn't have hundreds or even thousands of path checkers running at the same time. This patch lets users turn off the asynchronous mode of these checks if they see this problem. Signed-off-by: Benjamin Marzinski --- libmultipath/config.c | 1 + libmultipath/config.h | 1 + libmultipath/dict.c | 33 +++++++++++++++++++++++++++++++++ libmultipath/discovery.c | 8 ++++++-- multipath.conf.annotated | 11 +++++++++++ multipath/multipath.conf.5 | 9 +++++++++ 6 files changed, 61 insertions(+), 2 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index e13c307..39963b4 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -561,6 +561,7 @@ load_config (char * file, struct udev *udev) conf->fast_io_fail = DEFAULT_FAST_IO_FAIL; conf->retain_hwhandler = DEFAULT_RETAIN_HWHANDLER; conf->detect_prio = DEFAULT_DETECT_PRIO; + conf->force_sync = 0; /* * preload default hwtable diff --git a/libmultipath/config.h b/libmultipath/config.h index ac7c58e..1a23e4b 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -124,6 +124,7 @@ struct config { int reassign_maps; int retain_hwhandler; int detect_prio; + int force_sync; unsigned int version[3]; char * dev; diff --git a/libmultipath/dict.c b/libmultipath/dict.c index 91d9b83..7de7a67 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -685,6 +685,29 @@ def_detect_prio_handler(vector strvec) return 0; } +static int +def_force_sync_handler(vector strvec) +{ + char * buff; + + buff = set_value(strvec); + + if (!buff) + return 1; + + if ((strlen(buff) == 2 && !strcmp(buff, "no")) || + (strlen(buff) == 1 && !strcmp(buff, "0"))) + conf->force_sync = 0; + else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) || + (strlen(buff) == 1 && !strcmp(buff, "1"))) + conf->force_sync = 1; + else + conf->force_sync = 0; + + FREE(buff); + return 0; +} + /* * blacklist block handlers */ @@ -2783,6 +2806,15 @@ snprint_def_detect_prio(char * buff, int len, void * data) } static int +snprint_def_force_sync(char * buff, int len, void * data) +{ + if (conf->force_sync) + return snprintf(buff, len, "yes"); + else + return snprintf(buff, len, "no"); +} + +static int snprint_ble_simple (char * buff, int len, void * data) { struct blentry * ble = (struct blentry *)data; @@ -2849,6 +2881,7 @@ init_keywords(void) install_keyword("reservation_key", &def_reservation_key_handler, &snprint_def_reservation_key); install_keyword("retain_attached_hw_handler", &def_retain_hwhandler_handler, &snprint_def_retain_hwhandler_handler); install_keyword("detect_prio", &def_detect_prio_handler, &snprint_def_detect_prio); + install_keyword("force_sync", &def_force_sync_handler, &snprint_def_force_sync); __deprecated install_keyword("default_selector", &def_selector_handler, NULL); __deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL); __deprecated install_keyword("default_uid_attribute", &def_uid_attribute_handler, NULL); diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index b62a59c..a5f5a20 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -1053,8 +1053,12 @@ get_state (struct path * pp, int daemon) } } checker_clear_message(c); - if (daemon) - checker_set_async(c); + if (daemon) { + if (conf->force_sync == 0) + checker_set_async(c); + else + checker_set_sync(c); + } if (!conf->checker_timeout && sysfs_get_timeout(pp, &(c->timeout)) <= 0) c->timeout = DEF_TIMEOUT; diff --git a/multipath.conf.annotated b/multipath.conf.annotated index f158746..0af1d4c 100644 --- a/multipath.conf.annotated +++ b/multipath.conf.annotated @@ -270,6 +270,7 @@ # # default : determined by the OS # dev_loss_tmo 600 # +# # # # name : bindings_file # # scope : multipath # # desc : The location of the bindings file that is used with @@ -278,6 +279,7 @@ # # default : "/var/lib/multipath/bindings" # bindings_file "/etc/multipath/bindings" # +# # # # name : wwids_file # # scope : multipath # # desc : The location of the wwids file multipath uses to @@ -286,6 +288,7 @@ # # default : "/var/lib/multipath/wwids" # wwids_file "/etc/multipath/wwids" # +# # # # name : reservation_key # # scope : multipath # # desc : Service action reservation key used by mpathpersist. @@ -293,6 +296,14 @@ # # default : (null) # reservation_key "mpathkey" # +# # +# # name : force_sync +# # scope : multipathd +# # desc : If set to yes, multipath will run all of the checkers in +# # sync mode, even if the checker has an async mode. +# # values : yes|no +# # default : no +# force_sync yes #} # ## diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5 index 195e663..cadb34d 100644 --- a/multipath/multipath.conf.5 +++ b/multipath/multipath.conf.5 @@ -409,6 +409,15 @@ will automatically use the .I alua prioritizer. If not, the prioritizer will be selected as usual. Default is .I no +.TP +.B force_sync +If set to +.I yes +, multipathd will call the path checkers in sync mode only. This means that +only one checker will run at a time. This is useful in the case where many +multipathd checkers running in parallel causes significant CPU pressure. The +Default is +.I no . .SH "blacklist section" The