From patchwork Wed Jun 26 17:02:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wysochanski X-Patchwork-Id: 11018147 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D89D1398 for ; Wed, 26 Jun 2019 17:03:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51ABB28892 for ; Wed, 26 Jun 2019 17:03:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45D9F28895; Wed, 26 Jun 2019 17:03:08 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E00D628894 for ; Wed, 26 Jun 2019 17:03:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726006AbfFZRDC (ORCPT ); Wed, 26 Jun 2019 13:03:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33312 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726179AbfFZRDB (ORCPT ); Wed, 26 Jun 2019 13:03:01 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4091D308792E; Wed, 26 Jun 2019 17:03:01 +0000 (UTC) Received: from f29-node1.dwysocha.net (dhcp145-42.rdu.redhat.com [10.13.145.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE64B600CC; Wed, 26 Jun 2019 17:02:59 +0000 (UTC) From: Dave Wysochanski To: chuck.lever@oracle.com, SteveD@RedHat.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH] mountstats: Fix nfsstat command to handle RPC iostats version >= 1.1 Date: Wed, 26 Jun 2019 13:02:58 -0400 Message-Id: <20190626170259.8347-1-dwysocha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 26 Jun 2019 17:03:01 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Later kernels with RPC iostats version >= 1.1 have an additional errors count for each op. Lengthen the array of values created inside DeviceData and then in __parse_rpc_line just zero this value out for prior kernels where this count is not present. The count is not used for nfsstat, but this keeps DeviceData consistent with the new count as well as proper functioning of accumulate_iostats. Before this patch, nfsstat will backtrace on a kernel with RPC iostats version >= 1.1 due to the fixed array inside DeviceData. This patch fixes this backtrace and also allows nfsstat to work with these new kernels. Signed-off-by: Dave Wysochanski --- tools/mountstats/mountstats.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py index c5e8f506..6ac83ccb 100755 --- a/tools/mountstats/mountstats.py +++ b/tools/mountstats/mountstats.py @@ -308,6 +308,8 @@ class DeviceData: op = words[0][:-1] self.__rpc_data['ops'] += [op] self.__rpc_data[op] = [int(word) for word in words[1:]] + if len(self.__rpc_data[op]) < 9: + self.__rpc_data[op] += [0] def parse_stats(self, lines): """Turn a list of lines from a mount stat file into a @@ -582,7 +584,7 @@ class DeviceData: self.__nfs_data['fstype'] = 'nfs4' self.__rpc_data['ops'] = ops for op in ops: - self.__rpc_data[op] = [0 for i in range(8)] + self.__rpc_data[op] = [0 for i in range(9)] def accumulate_iostats(self, new_stats): """Accumulate counters from all RPC op buckets in new_stats. This is