From patchwork Tue Feb 14 04:06:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 9571195 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 246F66045F for ; Tue, 14 Feb 2017 04:08:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14EA7252D5 for ; Tue, 14 Feb 2017 04:08:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A07127D5E; Tue, 14 Feb 2017 04:08:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A27DF27FA6 for ; Tue, 14 Feb 2017 04:08:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1E479cF040382; Mon, 13 Feb 2017 23:07:09 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1E47523006675 for ; Mon, 13 Feb 2017 23:07:05 -0500 Received: from redhat.com (octiron.msp.redhat.com [10.15.80.209]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id v1E4736f012835; Mon, 13 Feb 2017 23:07:03 -0500 Received: by redhat.com (sSMTP sendmail emulation); Mon, 13 Feb 2017 22:07:03 -0600 From: "Benjamin Marzinski" To: device-mapper development Date: Mon, 13 Feb 2017 22:06:52 -0600 Message-Id: <1487045213-15776-7-git-send-email-bmarzins@redhat.com> In-Reply-To: <1487045213-15776-1-git-send-email-bmarzins@redhat.com> References: <1487045213-15776-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH v2 6/7] multipathd: allow resetting stats X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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-Virus-Scanned: ClamAV using ClamSMTP This patch adds two multipathd interactive commands: multipathd reset maps stats and multipathd reset map stats to reset the statistics that are shown with the "show stats" commands. Signed-off-by: Benjamin Marzinski --- multipathd/cli.c | 2 ++ multipathd/cli_handlers.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ multipathd/cli_handlers.h | 2 ++ multipathd/main.c | 2 ++ 4 files changed, 50 insertions(+) diff --git a/multipathd/cli.c b/multipathd/cli.c index 50161be..32d4976 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -547,6 +547,8 @@ cli_init (void) { add_handler(LIST+BLACKLIST, NULL); add_handler(LIST+DEVICES, NULL); add_handler(LIST+WILDCARDS, NULL); + add_handler(RESET+MAPS+STATS, NULL); + add_handler(RESET+MAP+STATS, NULL); add_handler(ADD+PATH, NULL); add_handler(DEL+PATH, NULL); add_handler(ADD+MAP, NULL); diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index b0eeca6..b20b054 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -277,6 +277,17 @@ show_config (char ** r, int * len) return 0; } +void +reset_stats(struct multipath * mpp) +{ + mpp->stat_switchgroup = 0; + mpp->stat_path_failures = 0; + mpp->stat_map_loads = 0; + mpp->stat_total_queueing_time = 0; + mpp->stat_queueing_timeouts = 0; + mpp->stat_map_failures = 0; +} + int cli_list_config (void * v, char ** reply, int * len, void * data) { @@ -627,6 +638,39 @@ cli_list_daemon (void * v, char ** reply, int * len, void * data) } int +cli_reset_maps_stats (void * v, char ** reply, int * len, void * data) +{ + struct vectors * vecs = (struct vectors *)data; + int i; + struct multipath * mpp; + + condlog(3, "reset multipaths stats (operator)"); + + vector_foreach_slot(vecs->mpvec, mpp, i) { + reset_stats(mpp); + } + return 0; +} + +int +cli_reset_map_stats (void * v, char ** reply, int * len, void * data) +{ + struct vectors * vecs = (struct vectors *)data; + struct multipath * mpp; + char * param = get_keyparam(v, MAP); + + param = convert_dev(param, 0); + mpp = find_mp_by_str(vecs->mpvec, param); + + if (!mpp) + return 1; + + condlog(3, "reset multipath %s stats (operator)", param); + reset_stats(mpp); + return 0; +} + +int cli_add_path (void * v, char ** reply, int * len, void * data) { struct vectors * vecs = (struct vectors *)data; diff --git a/multipathd/cli_handlers.h b/multipathd/cli_handlers.h index 19e003d..f4d02cc 100644 --- a/multipathd/cli_handlers.h +++ b/multipathd/cli_handlers.h @@ -19,6 +19,8 @@ int cli_list_config (void * v, char ** reply, int * len, void * data); int cli_list_blacklist (void * v, char ** reply, int * len, void * data); int cli_list_devices (void * v, char ** reply, int * len, void * data); int cli_list_wildcards (void * v, char ** reply, int * len, void * data); +int cli_reset_maps_stats (void * v, char ** reply, int * len, void * data); +int cli_reset_map_stats (void * v, char ** reply, int * len, void * data); int cli_add_path (void * v, char ** reply, int * len, void * data); int cli_del_path (void * v, char ** reply, int * len, void * data); int cli_add_map (void * v, char ** reply, int * len, void * data); diff --git a/multipathd/main.c b/multipathd/main.c index 33b7ad6..aa6c72e 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1228,6 +1228,8 @@ uxlsnrloop (void * ap) set_handler_callback(LIST+BLACKLIST, cli_list_blacklist); set_handler_callback(LIST+DEVICES, cli_list_devices); set_handler_callback(LIST+WILDCARDS, cli_list_wildcards); + set_handler_callback(RESET+MAPS+STATS, cli_reset_maps_stats); + set_handler_callback(RESET+MAP+STATS, cli_reset_map_stats); set_handler_callback(ADD+PATH, cli_add_path); set_handler_callback(DEL+PATH, cli_del_path); set_handler_callback(ADD+MAP, cli_add_map);