From patchwork Wed Feb 15 02:16:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 9573219 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 26F2E6045F for ; Wed, 15 Feb 2017 02:18:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1616A2844E for ; Wed, 15 Feb 2017 02:18:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0528828448; Wed, 15 Feb 2017 02:18:43 +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 mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) (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 93D0E28448 for ; Wed, 15 Feb 2017 02:18:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1F2HfmR047102; Tue, 14 Feb 2017 21:17:41 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1F2H913009919 for ; Tue, 14 Feb 2017 21:17:09 -0500 Received: from redhat.com (octiron.msp.redhat.com [10.15.80.209]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id v1F2H8aL024343; Tue, 14 Feb 2017 21:17:08 -0500 Received: by redhat.com (sSMTP sendmail emulation); Tue, 14 Feb 2017 20:17:07 -0600 From: "Benjamin Marzinski" To: device-mapper development Date: Tue, 14 Feb 2017 20:16:56 -0600 Message-Id: <1487125017-22049-7-git-send-email-bmarzins@redhat.com> In-Reply-To: <1487125017-22049-1-git-send-email-bmarzins@redhat.com> References: <1487125017-22049-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 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);