From patchwork Thu Jan 30 14:20:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Sorenson X-Patchwork-Id: 13954642 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 1FE8B1BDA95 for ; Thu, 30 Jan 2025 14:20:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246846; cv=none; b=S8ZO/wwAsg3cd2R62XH/kgDFoEiy3XARU2+IZpQDq1CQyzE5vNRY5r4kmL1eQDA0waFyKqxC7yogVkvExFBbns9a+iM26Q91YOLPe3/y5LDALVfffhl7N2qt8TA7KptkfwJefBSdyn/HJmrd/rKgGRSj/Q2HNvwHOj+o3YrDJgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246846; c=relaxed/simple; bh=/7U6Syn/HatUzDoNCZXf4vT8AgAt23c1D8lVPVK1duk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sHLg5FSIaHdlCkUSEbt0eczxxK46OyfC/nE2W7vepkS8O6E4YQZeeUTb9E7ggGTIAiFrCLddWnKBkN79sueZRDeiob4hYWfY+Mz1mJZD4BYDI+Q10o0vzmG4EEI1fy0BbKTyJf+BMfLPGXjdelj6sMnuSwgjGef1EwijU+c2MHI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=c6IzT0Jh; arc=none smtp.client-ip=170.10.129.124 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="c6IzT0Jh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738246844; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TuyS+yMqL8dThfY+PMAntJW4ZMfNaFMiOS4pg+12NBw=; b=c6IzT0JhWWmV9dxxysZbS4Y2V1trfvgn07ujynFxgJeFHhwaeQmQjC1Wz5pCiS5UfaasyG 9PWoRkRObDLtQHUQG+e795gqj7u6ZsOUhO1OBtxOK2GrM8CxCrq2QrfxJ65pupnp2EA4x9 P40wlQH2LkcfMCd5wIG8RFmbq6INiZM= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-59-gsEJcvDHNxmJrI3CnTk23A-1; Thu, 30 Jan 2025 09:20:42 -0500 X-MC-Unique: gsEJcvDHNxmJrI3CnTk23A-1 X-Mimecast-MFC-AGG-ID: gsEJcvDHNxmJrI3CnTk23A Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-7b6ee0af16dso131018385a.3 for ; Thu, 30 Jan 2025 06:20:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738246841; x=1738851641; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TuyS+yMqL8dThfY+PMAntJW4ZMfNaFMiOS4pg+12NBw=; b=j3cMTQhfewgHZKSjVDbyJIokoDdTCwd2T64muBr1Tf92u/F8c/QuNIc9y2DP0QjNLQ rlGv6Pe9rrHP5fdpG3TaJOxxbM6weQm9xWnnmBFEYy5cudUpHtdpmQFv6+JOa+Gg1apS Sgq8s5LIZ1EBgYoG0LS+nQjyT2dqQ3cY5wafF8LCngQ0Uo8Q5dLqxwOvKEK6fsT4yOf5 ADjUFPE2aJy8hHPGrLGBh0aK3Ys5uRvBosg/fXZoP/2VZ51nM+XrXSqJCLeHMtgp9JdZ +gWl5kpYqcdIiofefcMx1liAP9w+M4T+CPi82Uwj3SRW4qljzRBAp4quD6S2caQx+8Aa 9R6Q== X-Gm-Message-State: AOJu0YwW/y3XYpa+Hj6kmAWBA7A30/9Ht4ovxgFIfondCmt34CNImwzC Ng11lLcRVC3ZLKytI1uw+JJQP12uaycBu4SbuUQ1lTQoOXtQ8ZNNZXyBBqs/phPkaLDIBVAn/5X w7bO2HCMPkwUa7O+BrIszjjJM4W53CGZMPMAB6FXhwzMAgBsfe44vRy6DVbTKUYExtUTK63zs+E H/PaXe8tOW2qqwaY7BcxL2FlzUkV+tWQe5ah3yqSRx0w== X-Gm-Gg: ASbGncvRF2eG76/eAo1LNU0LIyHKTvWJ0v64s2eFO2jeQt3YbJVtRb6OSvfN4h63i+M cY1ejSMC2nSJ/YIysraDXtOtAarPJlURRHAL9RvAPeW2yqIUgvn2xSZGQE1/6n+caA6ulRmJdzX SNtZ6oQFe6qP3kOG9CBB7rEStFLupMFJtm+nU8WkDNmkLmSQeE0a1GUpuJ4fY5DJ7nRn30Rc6q6 6B6qNlqjHJtus2We/qVGO22/xazE9YgqIxz48aWVTKegJ2cQ/+9u0WEUy3R2rK/LLq98HgcX1Rn DgMcmEzNu0Y1PU8NtuHyp6sCpLdXn7UogvlaWC2CFz5wcmZgJZ/NgDxbJ7VuD/BR X-Received: by 2002:a05:620a:2694:b0:7bc:db11:495c with SMTP id af79cd13be357-7bffcd9d416mr1185244385a.51.1738246840918; Thu, 30 Jan 2025 06:20:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFoN6SRry2Xh+tzw/L1U45ecTXFMCLzFVtDgxeALdvINpYJa4BqrfNN7theN9v1o/S22G/irQ== X-Received: by 2002:a05:620a:2694:b0:7bc:db11:495c with SMTP id af79cd13be357-7bffcd9d416mr1185240585a.51.1738246840474; Thu, 30 Jan 2025 06:20:40 -0800 (PST) Received: from bearskin.sorenson.redhat.com (c-98-227-24-213.hsd1.il.comcast.net. [98.227.24.213]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7c00a9205f4sm77449285a.114.2025.01.30.06.20.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2025 06:20:40 -0800 (PST) From: Frank Sorenson To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, chuck.lever@oracle.com Subject: [nfs-utils PATCH 1/8] mountstats/nfsiostat: add a function to return the fstype Date: Thu, 30 Jan 2025 08:20:00 -0600 Message-ID: <20250130142008.3600334-2-sorenson@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250130142008.3600334-1-sorenson@redhat.com> References: <20250130142008.3600334-1-sorenson@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We'll need to get the DeviceData fstype when printing iostats with multiple iterations, so we can verify that old and new mountpoints are the same. Signed-off-by: Frank Sorenson --- tools/mountstats/mountstats.py | 5 +++++ tools/nfs-iostat/nfs-iostat.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py index 8e129c83..00d1ac7e 100755 --- a/tools/mountstats/mountstats.py +++ b/tools/mountstats/mountstats.py @@ -333,6 +333,11 @@ class DeviceData: found = True self.__parse_rpc_line(words) + def fstype(self): + """Return the fstype for the mountpoint + """ + return self.__nfs_data['fstype'] + def is_nfs_mountpoint(self): """Return True if this is an NFS or NFSv4 mountpoint, otherwise return False diff --git a/tools/nfs-iostat/nfs-iostat.py b/tools/nfs-iostat/nfs-iostat.py index 31587370..95176a4b 100755 --- a/tools/nfs-iostat/nfs-iostat.py +++ b/tools/nfs-iostat/nfs-iostat.py @@ -187,6 +187,11 @@ class DeviceData: found = True self.__parse_rpc_line(words) + def fstype(self): + """Return the fstype for the mountpoint + """ + return self.__nfs_data['fstype'] + def is_nfs_mountpoint(self): """Return True if this is an NFS or NFSv4 mountpoint, otherwise return False From patchwork Thu Jan 30 14:20:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Sorenson X-Patchwork-Id: 13954643 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 2CD5C1E98F1 for ; Thu, 30 Jan 2025 14:20:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246848; cv=none; b=Fzat1IdvsW+inPpTTRxpuik+Abi2/uj7As+iucoIh6h1+RNe+seU2ouBl1u7tqsO95ExJgFPYGXCXbhURiszg/7aL9FL90prIQVHZT2Er0fVMzPBsZlXgp06r17aMaskzxZeMr6WLuDsqIlBJERu9fQyaW4E80CHp/O9xmy5DgU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246848; c=relaxed/simple; bh=JLkFAVPMb5tHRj5wrQBX6nt0kYk7IOJ7LltpYOnt6o8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DMbFHoq1fvf71luJsOzDYTWDgEGbhvVL+5uYzQIx+KXJHBPTVu/4H2OFZXE4zX7ShhQaDaM3xGZxNEB46/ekMH4FCFVFdxnotO+0CUYlgPVn3ZGeN7kPFMXTtw/hzpMsCpVQDT8bmfOcP7bKCIRk635NKPpbQeBbLe/zgD5Hwlg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=REkkYqBp; arc=none smtp.client-ip=170.10.133.124 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="REkkYqBp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738246846; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i7ympnvOtakgFKVBVaKy6+PYwdzP3Ome7vSw6Hqx41o=; b=REkkYqBp5+IIm8CZ8NSI+8VddDizzDQo4cuHf/xG4IUDJN/OgCjRd9atiJXHG6GLp7N+qF 6VJhvrG2A7Ve5I0eyaP5QFRqUM67wTTK9dNTONVWV9HfrkwYFe62dBQtvwYmDo2oA6T6F9 RbBApsYkZw6uoTdhF7j5QT+XedczUIQ= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-644-Y-V-DIMQP7699tOH2FxQww-1; Thu, 30 Jan 2025 09:20:43 -0500 X-MC-Unique: Y-V-DIMQP7699tOH2FxQww-1 X-Mimecast-MFC-AGG-ID: Y-V-DIMQP7699tOH2FxQww Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-7b7477f005eso198573385a.0 for ; Thu, 30 Jan 2025 06:20:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738246843; x=1738851643; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i7ympnvOtakgFKVBVaKy6+PYwdzP3Ome7vSw6Hqx41o=; b=XVBT+MJ/9cVxommZRjSvdoL6s9AXab0Y0CgNT4sKkVp9rUnmStANWaE1ARpNTSieFB 5YyEhunyJRiR2LDJ2iYaqAANAc7ddUvM4INojGrvu0epiCJdfpdp1KtRp2ajAoDa89cK hj7TWrgO2VY0tFp+JjJWtTfEZ6jc80Fs3bvYPKtljD1M5BmSQvrUtS/mzShdj8u7OTfN XXZzs5xURgO+C86F12oEVKyU1dzceZkV+qrrsy1fuZw7HJiog1uJK7grn+t3uVPg4v1S sUnY0wJmcy1W9Ejje2Q2wyYOyjjmK6AzDD1imOxDTrYk+hM2N1zzCn2dKaG214NwfP+L y2xw== X-Gm-Message-State: AOJu0YwyKr1LNGZAoQ6VUH6SGCZRq5tiSkLTj10QEgxFU1WVwijVLCTj UzPIST9KsPeDRKIpLQa3cd6xJu3a2WIzihejUVTmA3nJMRoAQ3ptqwRm3KlxwLTiWVKavTTOSty U1FHy7lFHJOEM54l9XWmgXVNFTe+VflLbmZtBvzNNqEJjgN26/PipvWMBhm8rpQnBe02+GAd60P yZAnE7MCe4BN+kJCCxh05rwnl9xbtOT51z6n6o4TN6AA== X-Gm-Gg: ASbGncu8enIc8U60gCl5PJ0hkcEN04IZnLqP+J9pj3zVWtQlbiw4dDi79hm6fp9ly17 5+I8Fr5m+xoWxdOvNBGC/atU+ZaL0YldmGTCIkYasISxHNU96RMpwo2PQM2hXBes4X2gwnGI3XZ p21cz7DNqKMwsC4yv9hlIov5VTCnBs9Rn9iZNhG/C7rB88kr67zL0rxcxd/c8uJ1ZssvTUBBuyw xLCpatQ4UySMXlMiNA27haGnaY8dFytjQe6B/MitX3d/PVHnarupY7u1fMdlmiEyq0pP+1koS39 SnOxR1xjnKJgXOfhyEX9YPrOW9HtrkiGdQy4soadGBkyRCaf5oic2wF8rsYIyHxU X-Received: by 2002:a05:620a:1906:b0:7b6:cbc6:c87c with SMTP id af79cd13be357-7bffcd0f2c6mr997063785a.30.1738246842822; Thu, 30 Jan 2025 06:20:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFc384QfZJeolVxbZcYPU0Icyd43/AXkPB5shEEfwPFtLYFxVlGM7/nUG/2GSNrKIwZimUNTA== X-Received: by 2002:a05:620a:1906:b0:7b6:cbc6:c87c with SMTP id af79cd13be357-7bffcd0f2c6mr997059285a.30.1738246842238; Thu, 30 Jan 2025 06:20:42 -0800 (PST) Received: from bearskin.sorenson.redhat.com (c-98-227-24-213.hsd1.il.comcast.net. [98.227.24.213]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7c00a9205f4sm77449285a.114.2025.01.30.06.20.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2025 06:20:40 -0800 (PST) From: Frank Sorenson To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, chuck.lever@oracle.com Subject: [nfs-utils PATCH 2/8] mountstats: when printing iostats, verify that old and new types are the same Date: Thu, 30 Jan 2025 08:20:01 -0600 Message-ID: <20250130142008.3600334-3-sorenson@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250130142008.3600334-1-sorenson@redhat.com> References: <20250130142008.3600334-1-sorenson@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It's not sufficient to verify that old and new are not autofs; both should be the same fstype, in order to cover other potential mismatches. This prevents crashes when a path is a mountpoint, but not nfs or autofs. Signed-off-by: Frank Sorenson --- tools/mountstats/mountstats.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py index 00d1ac7e..59139ccc 100755 --- a/tools/mountstats/mountstats.py +++ b/tools/mountstats/mountstats.py @@ -961,14 +961,15 @@ def print_iostat_summary(old, new, devices, time): for device in devices: stats = DeviceData() stats.parse_stats(new[device]) - if not old or device not in old: + if old and device in old: + old_stats = DeviceData() + old_stats.parse_stats(old[device]) + if stats.fstype() == old_stats.fstype(): + stats.compare_iostats(old_stats).display_iostats(time) + else: # device is in old, but fstypes are different + stats.display_iostats(time) + else: # device is only in new stats.display_iostats(time) - else: - if ("fstype autofs" not in str(old[device])) and ("fstype autofs" not in str(new[device])): - old_stats = DeviceData() - old_stats.parse_stats(old[device]) - diff_stats = stats.compare_iostats(old_stats) - diff_stats.display_iostats(time) def iostat_command(args): """iostat-like command for NFS mount points From patchwork Thu Jan 30 14:20:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Sorenson X-Patchwork-Id: 13954644 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 D89DD1E7C08 for ; Thu, 30 Jan 2025 14:20:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246849; cv=none; b=hKB8cK/speYChAPxCTymCkziz8FjxpViVQ8YbamKiaDFFbQpjCAMSb/9NnnOwNDgcWoHbBC0m7+z1OMO1KbMQp8rfgJK2NOoXNBWnZcXhthdRGD5PVx9/bsbytoBl7Qtg8MT6Z+Axu72+7YhANUg9bDviCd+VpC/j5hQvkA/WOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246849; c=relaxed/simple; bh=o9GH7584folDNBRVMHVFD6f/c2IOQFst1XYgylgPaI8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TIzfrjdBAxQbEGzfdNjMlVvMSBwtBNPlu8lxs16PzUvTQNEvfNP0b9nmqBslX2Ny2AJOoqNrkbo7lJulfGOM3OpTyeHIFs/aRzghERu3Nv9IaC6qHQTir6ghgG+TvXumIIxQWFHT/xpzebFSMNxaKgXnX+fKMqqn1AaUj280+PU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=UOtZDC2d; arc=none smtp.client-ip=170.10.133.124 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="UOtZDC2d" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738246846; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2U7G4Rk5TXX4t5vQvkhWSV5ubPXuuVRQwuOW6RiiruI=; b=UOtZDC2duhpSoWMwbWFQMcQwQvs+jd57pDZTZS29a3z/sFnYf6NJm5/0ZFvXS6gu86wuIn xfS7PYzGdMDCHqX0Fn7Kg6735kBW7z5tnIwl8lyFZmeL6778qvPcyxGb2qgYHji0nUDg2G Oikb3WhSwfCyJcrAsuPKJLTbkdr6lEQ= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-648-IuEVS5C6PZuinBBI53nlvA-1; Thu, 30 Jan 2025 09:20:44 -0500 X-MC-Unique: IuEVS5C6PZuinBBI53nlvA-1 X-Mimecast-MFC-AGG-ID: IuEVS5C6PZuinBBI53nlvA Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-7b6f943f59dso141533985a.2 for ; Thu, 30 Jan 2025 06:20:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738246844; x=1738851644; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2U7G4Rk5TXX4t5vQvkhWSV5ubPXuuVRQwuOW6RiiruI=; b=xIzUABaNg4UX9ZmBMHGies+HC7DFG1hq7JQuU842lE5rGuaBGT0FFBCEioBM4lZB/K oKE9ktHvK+YfFTxs6jN2JQ7tV/K7/Hbover5iqCD3Jf47rgaVRJvlAdBFR+K7gpTdCnJ j3JypRsREA79i3UOBJzXOSus5KFNoLaWHpB6pJAY41OW8hizp1Sdbkuo7akqll/1cr1m jVbEOAKO2vodZkA3qNuRM/pYq6iMiMrvy9LC2lPldUjznLMYr9T7CvkIBMVzRhrjx+Gl 8PIcl621KHHVdfGsKHvTu0zHLuUL8Pf0j9qk3We3SV/M3KSYm2OEDt50Wu8XNUmdy2Cz 3mPA== X-Gm-Message-State: AOJu0YyGqSLNXBuO4H+tvK9ypclqrhBUDlmk2RcjU1KqgUwn1Idy/Mtu cgawHYSAYMwHpVbhYIKSJhAaxyCP5ckmHi0rs2GMkn45xFn62gWbpFt5nFkJHECcql+He1DW3O8 JVOE2/1/oKB4rbIBjR1DFI4PLjGWT9Iv093wVPHSvzAXAeOL68aMXRszRNcpLanJGRU3H1roqya 7gsmpw3cZCUkTzJ/vtXp1ndGcJH9ZfzPoHCMw7g6wsjQ== X-Gm-Gg: ASbGnctvECWwSWJ3IhlxSY4CiWcs798aivR7oIUeLbp+93yBXWiRSjyHuTzDuk6zApo Mlx5VALtmtHQ7fI5fVMPkzTbpxUUx47MtggC1T3RCYvkSojvkY31aIkwgbTQdCQnvJsKjW9iRWu lS8nhqFEl9jqZA2opHlX0qFZI3GyA8YTFO9ZiQy+4iaHlVdlMO2x7ec+Zt2NT8/xhrCCtN+bU+c 9ReSGCKSqoS0x4X3H8Kfe0OhbicLnx6f4Y+/uR2tXPV66EzmeHiBG3Dv+4yUJyA9HiRA+F2hNIq HTogkn9vI0HAxwTJrLwLDNygylwLbqynjCNEANBQ1+JkQ2FOCTd49R9Sb9b7Jsij X-Received: by 2002:a05:620a:178b:b0:7b6:c462:6b82 with SMTP id af79cd13be357-7bffcd9d397mr1360267185a.54.1738246843768; Thu, 30 Jan 2025 06:20:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IG+C1a6xhyDBXkN0iMx/EfVtr7w6zH+pxxpdq7ExNWvK+h8jDRLGGZfn+sYjPZz/UD9C6vSrg== X-Received: by 2002:a05:620a:178b:b0:7b6:c462:6b82 with SMTP id af79cd13be357-7bffcd9d397mr1360262185a.54.1738246843257; Thu, 30 Jan 2025 06:20:43 -0800 (PST) Received: from bearskin.sorenson.redhat.com (c-98-227-24-213.hsd1.il.comcast.net. [98.227.24.213]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7c00a9205f4sm77449285a.114.2025.01.30.06.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2025 06:20:42 -0800 (PST) From: Frank Sorenson To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, chuck.lever@oracle.com Subject: [nfs-utils PATCH 3/8] nfsiostat: mirror how mountstats iostat prints the stats Date: Thu, 30 Jan 2025 08:20:02 -0600 Message-ID: <20250130142008.3600334-4-sorenson@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250130142008.3600334-1-sorenson@redhat.com> References: <20250130142008.3600334-1-sorenson@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently, nfsiostat assumes that if old mountstats are provided, then 'old' will contain all the new devices as well, and will therefore crash if outputting multiple iterations and a new nfs mount occurs between iterations. 'mountstats iostat' covers the new-nfs-mount situation by checking that the old mountstats contains the device before referencing it. It also verifies both old and new mountpoints are the same type. Therefore, make the nfsiostat output function like mountstats. However nfsiostat also has to allow sorting, so we can't just output the full/diff stats as we go. Instead, put the stats to output into a list to display, sort the list if necessary, then output the stats at the end. Signed-off-by: Frank Sorenson --- tools/nfs-iostat/nfs-iostat.py | 42 ++++++++++++---------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/tools/nfs-iostat/nfs-iostat.py b/tools/nfs-iostat/nfs-iostat.py index 95176a4b..bf5eead9 100755 --- a/tools/nfs-iostat/nfs-iostat.py +++ b/tools/nfs-iostat/nfs-iostat.py @@ -476,41 +476,27 @@ def parse_stats_file(filename): return ms_dict def print_iostat_summary(old, new, devices, time, options): - stats = {} - diff_stats = {} - devicelist = [] - if old: - # Trim device list to only include intersection of old and new data, - # this addresses umounts due to autofs mountpoints - for device in devices: - if "fstype autofs" not in str(old[device]): - devicelist.append(device) - else: - devicelist = devices + display_stats = {} - for device in devicelist: - stats[device] = DeviceData() - stats[device].parse_stats(new[device]) - if old: + for device in devices: + stats = DeviceData() + stats.parse_stats(new[device]) + if old and device in old: old_stats = DeviceData() old_stats.parse_stats(old[device]) - diff_stats[device] = stats[device].compare_iostats(old_stats) + if stats.fstype() == old_stats.fstype(): + display_stats[device] = stats.compare_iostats(old_stats) + else: # device is in old, but fstypes are different + display_stats[device] = stats + else: # device is only in new + display_stats[device] = stats if options.sort: - if old: - # We now have compared data and can print a comparison - # ordered by mountpoint ops per second - devicelist.sort(key=lambda x: diff_stats[x].ops(time), reverse=True) - else: - # First iteration, just sort by newly parsed ops/s - devicelist.sort(key=lambda x: stats[x].ops(time), reverse=True) + devices.sort(key=lambda x: display_stats[x].ops(time), reverse=True) count = 1 - for device in devicelist: - if old: - diff_stats[device].display_iostats(time, options.which) - else: - stats[device].display_iostats(time, options.which) + for device in devices: + display_stats[device].display_iostats(time, options.which) count += 1 if (count > options.list): From patchwork Thu Jan 30 14:20:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Sorenson X-Patchwork-Id: 13954645 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 16EE01E8823 for ; Thu, 30 Jan 2025 14:20:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246849; cv=none; b=puMEQkStnxuyoWtMqE12mDfvMP2yr1PWWKJvkq4069TRa8mrcnxjVtr1T/Jy1HPg/tKdazNRuxebmDQm47jNLCKQu19dtiijm1QsDH9rmgKypzhgWxkuyNMIDX7jNjyZL3epUkky/acLK7ZvRJ5wLo5b0lPQ2+QxEwJFb8iRq8U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246849; c=relaxed/simple; bh=VJ2pH26Wnp/bJW+vKPe2uDfNAJ3LkjeDIQHMW5wGkeU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UamGrkoj7apnsP/FMa8zTLhJSMUV/TAnPrEo6ghg6sGDI1Rb1gfgKz1EEhovHCpsHb7Y3IIj8dYdgFVB49RWTZ4AYSTJ1vzM5HdP+RtVZD81S5vEnYciAVV8+Rf/fY3JI9CDiyBm/Z7sLyJPS2nuPMppDbM6n0rlHgelhXDXhLk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CvsdkxRU; arc=none smtp.client-ip=170.10.133.124 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="CvsdkxRU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738246847; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D6s4uioLKzdoeSnVuIIR8qNUDReFPfpWvoPugWeF0XE=; b=CvsdkxRUgIM+iP831FnmAuKP2Gp/gwytGG6AQMeLgTBZvnXNl6xA+2IivP1UG9iql8SBgU VOEdfFmadGxK7YFTj4Y/MtZrDaaw8GYjeLltU98bjZXaqX5CB9AuIqkrI9fcU8CRK/lzJ9 v8UzkNNmKvEDedleQm4RbsfvDC/ADKI= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-384-iwz04zbTPU6Qgljg8XqwgA-1; Thu, 30 Jan 2025 09:20:45 -0500 X-MC-Unique: iwz04zbTPU6Qgljg8XqwgA-1 X-Mimecast-MFC-AGG-ID: iwz04zbTPU6Qgljg8XqwgA Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7b6f2515eb3so80183685a.0 for ; Thu, 30 Jan 2025 06:20:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738246845; x=1738851645; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D6s4uioLKzdoeSnVuIIR8qNUDReFPfpWvoPugWeF0XE=; b=bE5QIR5ozT5bdFYi019y2KwC4GAqQL1w8lw9+eCti4F0GuTPxzmBfpbaRwHXbuo7cK hLaTcBWerIBp4noJ9m9P1vPG5GTIEWbVwpW3WBIJICs+wmDSkXLplCQ+Lk1TNEB5ahyQ gj+9k39/n6Fi9Pv/rs8gjvwvq7/IWVjT2QFY3359PGs3uH+IosY3StfhRZgbhSntHwND 2m2b1D8zRQXvTindteC5bmbpOb+pH2Axx6y6qmiNIMVMWke4Ganz0aR+Y35nbWvXY7mE 3B2AaMURadgmJ16bW50RN8/SpHzvuUc5WyvMJH9E/qOeMvAXggJKKNjz6Y8Ob2u1OSFB qvKw== X-Gm-Message-State: AOJu0YwXWx//blyureMLaaPDoWhyrzhEL02+h9lHwLW3cHnKHnuCJ+LU LEZLnDWtrqTkmlQyhs+BKHvOwrD7yjiTfVLttNy9JnfStY3HsqH4NNph4XCufo0klBbmq3mkbP5 /MASkR1IXtycv9s2IjW9QkuEXhpfSitHm1frRva5uYEq7fWKS4DYBuQ/GcZtsRbBIEtBCiZO7PT E1JqcPWhYfyuevdwy9YsNEcY21pjnGTgzKB5ci0bcTmA== X-Gm-Gg: ASbGncuN1L/wWe+sGrnV0h7J2O6RZYFlM6hvvciBK+fTOfMkwv4kPHqrzm7kSiWAv+m /4nAUHX/pn71GiLp2dlSBq8dkhXbmZ+r5ktJ3/MZwWZNRWZBfCGTeRMlIjzpw6bjLF9TWfOit8U WUKPVOGIXtK7f5l57rzIxJ+lOmpFDQiIr6UJrKeBUBHa35bSzh2aIvNUVF/cWCHDGhL9d3+uRZ+ MZ2OYf7Djm15+Y0rITaL9CGAUJvSLiisX08P7f+1wzOrWEkvUr/1Cxtdk8A/Ymz6L6kS4ihThcJ HTy0u1NcMHASY/0vZcoH6fp1kDO01GpPczy96omsyMdwZL/JbxW4U5+v6EHnMluw X-Received: by 2002:a05:620a:6084:b0:7b6:d631:266f with SMTP id af79cd13be357-7bffcce5266mr984149485a.14.1738246844615; Thu, 30 Jan 2025 06:20:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUmvOBxXduqoDce9fgNN3Wevb+GlU1S9th2a1NZM2U7CwCPzcwttl5oTCxs86JRUEno6naPQ== X-Received: by 2002:a05:620a:6084:b0:7b6:d631:266f with SMTP id af79cd13be357-7bffcce5266mr984145185a.14.1738246844183; Thu, 30 Jan 2025 06:20:44 -0800 (PST) Received: from bearskin.sorenson.redhat.com (c-98-227-24-213.hsd1.il.comcast.net. [98.227.24.213]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7c00a9205f4sm77449285a.114.2025.01.30.06.20.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2025 06:20:43 -0800 (PST) From: Frank Sorenson To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, chuck.lever@oracle.com Subject: [nfs-utils PATCH 4/8] nfsiostat: fix crash when filtering mountstats after unmount Date: Thu, 30 Jan 2025 08:20:03 -0600 Message-ID: <20250130142008.3600334-5-sorenson@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250130142008.3600334-1-sorenson@redhat.com> References: <20250130142008.3600334-1-sorenson@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If an unmount occurs between iterations, the filter function will crash when referencing the 'device' in the new mountstats. Verify it exists before trying to access it. Signed-off-by: Frank Sorenson --- tools/nfs-iostat/nfs-iostat.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/nfs-iostat/nfs-iostat.py b/tools/nfs-iostat/nfs-iostat.py index bf5eead9..08b827c0 100755 --- a/tools/nfs-iostat/nfs-iostat.py +++ b/tools/nfs-iostat/nfs-iostat.py @@ -511,10 +511,11 @@ def list_nfs_mounts(givenlist, mountstats): devicelist = [] if len(givenlist) > 0: for device in givenlist: - stats = DeviceData() - stats.parse_stats(mountstats[device]) - if stats.is_nfs_mountpoint(): - devicelist += [device] + if device in mountstats: + stats = DeviceData() + stats.parse_stats(mountstats[device]) + if stats.is_nfs_mountpoint(): + devicelist += [device] else: for device, descr in mountstats.items(): stats = DeviceData() From patchwork Thu Jan 30 14:20:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Sorenson X-Patchwork-Id: 13954646 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 5B6401E98F1 for ; Thu, 30 Jan 2025 14:20:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246851; cv=none; b=EZH6Gvi8ipnNZoraRdPrT9cZHfyW9W7fsDOjN7wvMDdwhDJ7iMxIT9BkYjYmLHEp2oVT6TT7c+kyQQDCXpHOtA3LAgvvlaZOQsKdllun/yg/KZNuljDVdORo7xLEuZmnqF6fvpes7yuOye+mZdxDnuhVrp+T4XSQzl8+eveEsIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246851; c=relaxed/simple; bh=SoweczzTORvFTurLVDnrfc81FFcqs5gJiXUftnjHPAI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jijPm8P6d+bbB9E6ueMz9Ymxcl9ATXlj1jl2TpAgra97QjzWy/ZmQKF4/sqhraE6T7MqfspF2Kg+subcPBFZEd5k9U4OWWzv0UhEdSdcv88Uk/aCRqlXOy5pQEzN7IRH2ZIqwNoYybqC6VTd5wO2cuiQ+gHDO7434Yw6XDEnI40= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=g8mWLiA0; arc=none smtp.client-ip=170.10.129.124 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="g8mWLiA0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738246848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nHk7o2CyA9nsZVViydmZdU55KVJBsJebmKxG4HW9Xxo=; b=g8mWLiA04hzHMGaA744DKyg8uFfNekA7skRPq6xSkV9RIG1NxDsSarlnnOE1Ou6pR7+2zE Ft1nMahUhpy2OzXdN1oV9s1UMtP+vtAmVecROvzubPqjTRRPS1QjNFmx6Q2pNjVbuKWAqI d6xNfnN+frvFP1VrbN8JONGMdMErX4Y= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-9ju2i_nMMhWTb1_qHDDr8A-1; Thu, 30 Jan 2025 09:20:47 -0500 X-MC-Unique: 9ju2i_nMMhWTb1_qHDDr8A-1 X-Mimecast-MFC-AGG-ID: 9ju2i_nMMhWTb1_qHDDr8A Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-7bcf4d3c1c1so133885185a.2 for ; Thu, 30 Jan 2025 06:20:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738246846; x=1738851646; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nHk7o2CyA9nsZVViydmZdU55KVJBsJebmKxG4HW9Xxo=; b=G+nW9trq0POG8wB8qshwMFjl1mUidMdD1CtzsoNuJGgLaPH9ftI163JTyb7IaAJ+dA TgT9imGwyjHAtTFaK963q6JGXx2oNaQMNVTc2toevhmAYkQC9s0/rmOdLpvbyDvQvnAT GyacJl3jGKAAPvkihLs2ZTuV4uyIG0vXa04toRUNzu9p6Ac4c51wFmUZvZKHE11Y+Czh MH3SViJGBIgm80fVXmaO/90pyvI6f+rmJTVZOvTHOmTmT17YMqEIBwwE+5s7CGwGWDJ7 waVGUrNieoDGnIwI0rLRE8GQAS66sSrSUUX2KVCFaPAr1tKiBUpNGUGkX+O05BhQOdGj NL3g== X-Gm-Message-State: AOJu0Yxani3bbmVTtNT727dDVrz1uPHP+U58RDZWng7+3IX4PO9mdRQQ pU9qt4seFzRDxFBWHd/v4Z7EV8A5pkHv8OoREIlBMHyQCfZYyKImroQSdFtoLz/64WG2rKfheMa SS3QTRGM5pt8kM6dNQb9OqAR8YFNtqMtK1pzIyKV2WhtKFD2CnJbpdAL0CHaDX/Kb3tvk8LtrhB eHLi9Q/QiSZJ3nTtUg7zHMYisRlKRJw51iHCif/PZvUw== X-Gm-Gg: ASbGncuvpLcIXbhy++XISvM2pvnMBnargQJVbU29DQMj3AMntqgqF5A00dTmsjZmMei Nuol1klXlc1HHVY/pGHw/fwab3TK3WKTbhgQDGEcO73/0SUP1VlSjjcFFpKDoXF7BoY02XGG2RF 9MeBqds6uAHgMcqE2a0RSbtxShbfWrGRNexilfC7/T9T8GiEBrd+T555VrbBNidTsgElB3C4U29 UWybf/p/+5aiROyfJc+FsGShlbjQijmNt205t48w/Brz8mToRx0xgaXeaGlZAuxwvLWU1W0dmeK nJLOX24et/TAMba0PhN7I4ccp2gpnd9GVgzF6sI+XLHuNkFDU1QDWC5ogNQp9DcN X-Received: by 2002:a05:620a:4247:b0:7b6:d393:c213 with SMTP id af79cd13be357-7bffcccaf39mr1094302885a.8.1738246846091; Thu, 30 Jan 2025 06:20:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHE16Qv/tF77HUXqvX7oURmPOPYYnz2uqAdIqhunpWVF2es0s7ddmFu2plx1p3aliYa+f+H0w== X-Received: by 2002:a05:620a:4247:b0:7b6:d393:c213 with SMTP id af79cd13be357-7bffcccaf39mr1094297685a.8.1738246845646; Thu, 30 Jan 2025 06:20:45 -0800 (PST) Received: from bearskin.sorenson.redhat.com (c-98-227-24-213.hsd1.il.comcast.net. [98.227.24.213]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7c00a9205f4sm77449285a.114.2025.01.30.06.20.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2025 06:20:45 -0800 (PST) From: Frank Sorenson To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, chuck.lever@oracle.com Subject: [nfs-utils PATCH 5/8] nfsiostat: make comment explain mount/unmount more broadly Date: Thu, 30 Jan 2025 08:20:04 -0600 Message-ID: <20250130142008.3600334-6-sorenson@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250130142008.3600334-1-sorenson@redhat.com> References: <20250130142008.3600334-1-sorenson@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The comment explaining the need to recheck the devices list suggests that nfs mounts/unmounts may occur when automount is involved, but they can happen for other reasons as well. Make the comment explain the issue more broadly. Signed-off-by: Frank Sorenson --- tools/nfs-iostat/nfs-iostat.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/nfs-iostat/nfs-iostat.py b/tools/nfs-iostat/nfs-iostat.py index 08b827c0..1502b431 100755 --- a/tools/nfs-iostat/nfs-iostat.py +++ b/tools/nfs-iostat/nfs-iostat.py @@ -631,8 +631,8 @@ client are listed. time.sleep(interval) sample_time = interval mountstats = parse_stats_file('/proc/self/mountstats') - # automount mountpoints add and drop, if automount is involved - # we need to recheck the devices list when reparsing + # nfs mountpoints may appear or disappear, so we need to + # recheck the devices list each time we parse mountstats devices = list_nfs_mounts(origdevices,mountstats) if len(devices) == 0: print('No NFS mount points were found') @@ -645,8 +645,8 @@ client are listed. time.sleep(interval) sample_time = interval mountstats = parse_stats_file('/proc/self/mountstats') - # automount mountpoints add and drop, if automount is involved - # we need to recheck the devices list when reparsing + # nfs mountpoints may appear or disappear, so we need to + # recheck the devices list each time we parse mountstats devices = list_nfs_mounts(origdevices,mountstats) if len(devices) == 0: print('No NFS mount points were found') From patchwork Thu Jan 30 14:20:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Sorenson X-Patchwork-Id: 13954647 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 551041E8823 for ; Thu, 30 Jan 2025 14:20:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246852; cv=none; b=L9byic021P1mkJUEVHpYuJkgRrJ7GlNS6Ur30l9ilb20u0io+JYP1FSTiYQO2Ev1vKdfd2I383beBJ3u+Hv9sMFrrZBFMd6+Mjb1IQ3CBPnJAeVLLin8WBQf9+/KZIwZ0iEkGbtQGhcCMqDpQ6jS+atyqL6VOqOfJ2AV/57BJH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246852; c=relaxed/simple; bh=mmrba3hwT6r0qAYSNNaLQjcywuXvabGJqIUocgBUIVs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JGUYERTPTKDJ9vJT9xoezpj5EEJZcH0BfWngjCCtYLLmtqoh6QlAu6oFSL/XGRpzHFimhZBwF3c9kW0tWs75KCpoXCAkE0BapknuExtZw02EYy4nCSjHe82J1ewLFBJBD8jZabpiKRCN7GmBwk1y42KYesXM+XHFfj5M0tBArTY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=P0bafogT; arc=none smtp.client-ip=170.10.129.124 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="P0bafogT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738246849; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KwnF5vIKkyH8jTZi+6GZTx77ML4e1uTz/hF8YpNSqX0=; b=P0bafogToIPkAV4ZytVOf2DQGvCvlfiUmxTbCANeorH6iAPd5YO/D4XsjemTuHwZHe12kT ZFqLmGXLM60Vwg5UgBoIJL+ImnF6UoazBXrJGsc9ADTbmfnc3Nd1sWqWUMqKR4H/7fWgYp GalTzDbF82x2JIdXB+QDA0tzokMZHkQ= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-QgrE0bWSObOCGhyCpin0-Q-1; Thu, 30 Jan 2025 09:20:48 -0500 X-MC-Unique: QgrE0bWSObOCGhyCpin0-Q-1 X-Mimecast-MFC-AGG-ID: QgrE0bWSObOCGhyCpin0-Q Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-7b6eabd51cfso135364285a.0 for ; Thu, 30 Jan 2025 06:20:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738246847; x=1738851647; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KwnF5vIKkyH8jTZi+6GZTx77ML4e1uTz/hF8YpNSqX0=; b=fQubtadtit5PgmY+fLoued3ieoNyMJDGtVEu2jpVQKAsz9cyzOGYLzbF/CR4fB3pYp AWW8+22P3X/QqnnfEVhxY5dX2AjIuCHLP6iYgJr1CbwqKIIr59msNLKvuXer+HmbqF5N Dceq3uEnhShF7iMtM6Ykn5day95PGO4FvUMPiXyFL/CQZzf9pZfX3jZGhdh6jYnQMaUI hETnnCGczidM7tN++RxM8aJ7IWfelalluIpkOmP+1Lmy/SkgJB2kFlsu/Hl0zFivVxeU cJV2d2Y8vIeoBhlQKmYrHLDsUgr75eI0bwyoeeVh3+xrtQ2WMKbMNV2P47BETDkkxj3L iKUQ== X-Gm-Message-State: AOJu0YyldfXMLYyheOPRspkdAM7H87DQpj32jfm+Kp8viS4KsInMPjn3 Hrh2WpKa8m6cC2py4Awy3a/4Y+ZikeXJmm2BlQvbzCbBeofbGeo6tEQP5OlroBWajWADrKIjmh+ CI/o3QqYfGlZNvguoQxD3KSVfyG3l0CM3GDqlt2m6SU3lqC9bDD/UR1vmE5m6y0zEii9m9U/SZp OMtf42p01CEdG6eImYoyQI86o7N6kwVEHeRqAJekLgzA== X-Gm-Gg: ASbGncs5IbRj9GSDRo2/IvK1E7AiWdUrB7+iteKxIP38jPFWD7Tkv7GRwBn8wHpIyG9 fAwNCby4SegH3v7nuQI7XSWAIBcTYT6maTJP6VscjzPlONZ0JEf6X49R/LhmDzHKv6l8yiwyNNo A+uYIwta/H0vUL/yDvRU9cnZ93jv5ON6CQ1Eo9jfAoq6U78z19ooQ3+4v49eNOpsJbFW1uzlTrF tVULr5IEPJ1TvLakljGaYqCiE8sFC0z3FaaTfbAYTcpij8dOWqzwrHZxWUFvP/p9O/ZqWIqGHZw HmfGcvaqj+McBzDGcVkJGNkfaPsXkEOJDc28K0oYdlVikDF83rNvWYDcvTBJmQPB X-Received: by 2002:a05:620a:258e:b0:7b6:e9db:3b19 with SMTP id af79cd13be357-7bffcd9d19dmr974961385a.47.1738246846977; Thu, 30 Jan 2025 06:20:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFMNaEwqTUSAf2/FnKQ+P83n+70fkw/N89Uz98tMzMq+jLTtxLiBcA1vMS4fZURlP1/6r+CzA== X-Received: by 2002:a05:620a:258e:b0:7b6:e9db:3b19 with SMTP id af79cd13be357-7bffcd9d19dmr974956485a.47.1738246846465; Thu, 30 Jan 2025 06:20:46 -0800 (PST) Received: from bearskin.sorenson.redhat.com (c-98-227-24-213.hsd1.il.comcast.net. [98.227.24.213]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7c00a9205f4sm77449285a.114.2025.01.30.06.20.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2025 06:20:46 -0800 (PST) From: Frank Sorenson To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, chuck.lever@oracle.com Subject: [nfs-utils PATCH 6/8] mountstats: filter for nfs mounts in a function, each iostat iteration Date: Thu, 30 Jan 2025 08:20:05 -0600 Message-ID: <20250130142008.3600334-7-sorenson@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250130142008.3600334-1-sorenson@redhat.com> References: <20250130142008.3600334-1-sorenson@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently, 'mountstats iostat' filters for nfs mounts when first parsing mountstats, and never re-verifies the list when printing multiple iterations. As a result, new nfs mountpoints are never detected, and unmounts result in a crash. nfsiostat covers both new mounts and unmounts by filtering the list of devices in a function during each iteration. Align the scripts by copying the nfsiostat filtering function, and filter each iteration. Signed-off-by: Frank Sorenson --- tools/mountstats/mountstats.py | 53 ++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py index 59139ccc..e640642a 100755 --- a/tools/mountstats/mountstats.py +++ b/tools/mountstats/mountstats.py @@ -971,11 +971,32 @@ def print_iostat_summary(old, new, devices, time): else: # device is only in new stats.display_iostats(time) +def list_nfs_mounts(givenlist, mountstats): + """return a list of NFS mounts given a list to validate or + return a full list if the given list is empty - + may return an empty list if none found + """ + devicelist = [] + if len(givenlist) > 0: + for device in givenlist: + if device in mountstats: + stats = DeviceData() + stats.parse_stats(mountstats[device]) + if stats.is_nfs_mountpoint(): + devicelist += [device] + else: + for device, descr in mountstats.items(): + stats = DeviceData() + stats.parse_stats(descr) + if stats.is_nfs_mountpoint(): + devicelist += [device] + return devicelist + def iostat_command(args): """iostat-like command for NFS mount points """ mountstats = parse_stats_file(args.infile) - devices = [os.path.normpath(mp) for mp in args.mountpoints] + origdevices = [os.path.normpath(mp) for mp in args.mountpoints] if args.since: old_mountstats = parse_stats_file(args.since) @@ -983,23 +1004,7 @@ def iostat_command(args): old_mountstats = None # make certain devices contains only NFS mount points - if len(devices) > 0: - check = [] - for device in devices: - stats = DeviceData() - try: - stats.parse_stats(mountstats[device]) - if stats.is_nfs_mountpoint(): - check += [device] - except KeyError: - continue - devices = check - else: - for device, descr in mountstats.items(): - stats = DeviceData() - stats.parse_stats(descr) - if stats.is_nfs_mountpoint(): - devices += [device] + devices = list_nfs_mounts(origdevices, mountstats) if len(devices) == 0: print('No NFS mount points were found') return 1 @@ -1018,6 +1023,12 @@ def iostat_command(args): time.sleep(args.interval) sample_time = args.interval mountstats = parse_stats_file(args.infile) + # nfs mountpoints may appear or disappear, so we need to + # recheck the devices list each time we parse mountstats + devices = list_nfs_mounts(origdevices, mountstats) + if len(devices) == 0: + print('No NFS mount points were found') + return count -= 1 else: while True: @@ -1026,6 +1037,12 @@ def iostat_command(args): time.sleep(args.interval) sample_time = args.interval mountstats = parse_stats_file(args.infile) + # nfs mountpoints may appear or disappear, so we need to + # recheck the devices list each time we parse mountstats + devices = list_nfs_mounts(origdevices, mountstats) + if len(devices) == 0: + print('No NFS mount points were found') + return args.infile.close() if args.since: From patchwork Thu Jan 30 14:20:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Sorenson X-Patchwork-Id: 13954648 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 D21EB1E3772 for ; Thu, 30 Jan 2025 14:20:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246853; cv=none; b=T9rnEg7QfdVTxuz7tw0p30GVIEoxgARLfm3NtNzAWRlKof4hX35kAKG6ByX0Ai6yC5b1ux9OP3xQvdquESp+nHKItXRcdYK+lT2RKwlcx5jtrUyQR09utPfYoe9bF2Aa91HvXM162UVcP2raOSDWQCZEL1GvUoeZ0GOYlLHNhEs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246853; c=relaxed/simple; bh=Q7vHG0tNoJCPhFpV123pYZbTZpxZ+BWa/9tq/lOTiDY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dj5eqTAwV6UfLCc3Sb7oRKoj3vzUDKunZnM0+cBXbxwCNdLoQ37XHoE8MPRVZcx+n3q+EVG8N2CmEr3MrwK5lCvx+aOZf4rWxb1JuEl22Rya9UjQ7m27E6u2PbyG0scU/LW6VneVgIWUXYV5k13LlsdVQjw11Kqe3q8tbiP1dZQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=c0MY/+lY; arc=none smtp.client-ip=170.10.133.124 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="c0MY/+lY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738246850; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0C+dC3U+JUYgz5Cxn8LHNO3xmUdetsZk4Fsgzmrt9jM=; b=c0MY/+lYGa/CR2NKv/kC6EZZ8ywi9m+0z1E4/g7iFhOsK5dgnhKlbm4nQjjVH7yiwQZPlC AitUCrCtpjVKEXZD7bl/yxo9au1cBDFy0ICFLgbk2vdjrDOYT6ZjhIPwOWyI6AvBUdU+XB /XHYb6bg4pgx1ch4wNZEsQNziMo69e0= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-226-yG7pT4gpOfGMTM6lfVGcDg-1; Thu, 30 Jan 2025 09:20:49 -0500 X-MC-Unique: yG7pT4gpOfGMTM6lfVGcDg-1 X-Mimecast-MFC-AGG-ID: yG7pT4gpOfGMTM6lfVGcDg Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7b6ef813ed1so132100385a.3 for ; Thu, 30 Jan 2025 06:20:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738246849; x=1738851649; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0C+dC3U+JUYgz5Cxn8LHNO3xmUdetsZk4Fsgzmrt9jM=; b=YmnImSckGo/KWJnZQiW+CnY5T1NKlg5cLIycPSQHDH1eaYx1GImcAy9Uga6h7ws030 HpqCrb2RTP35k7lV/5vd98y5LNZb9iOGQu8X5MFrn9EM0j+t4WGPYFaXaI9aNTlqMyy3 SxsiwaY27Jpez4hQ5Jjlgts1ZgMmycE1QdRTD6rARz2AMqGTK5OSxHXmGFTdmLHu8Dty +y6E6fueAbLzSsyWD6UxRNwlV4KNV5OJGJYau0fj4PYvk9NHsLuqAyE1yRm+/Xup6bxS JGNBhmy9hRI9Cuj4+p0PUJGm1oA6oIrxUK9ZqsUfs+Redv7ifrFdmnsjoe1DeC+fCZeF +5OA== X-Gm-Message-State: AOJu0YzQ+e3P3DJQ2HodZw0uRFqOvOcAPhyLkRP8KIc0ALP8VKbn/0gc rBRqF+HUsgn+ni3iYUqANoZpCf2gD110NsmX6KxaBupBEpqbRtyQrBA78yG270LwYfSUTbEhUCg 1Ad5zeUppQpjIM5BeDfsotEVAMyoQ/q6Kdn4sFkVhFroXo5IbfTATtgOV34dPnqgRG2he4IIdkk J91xVeO4wEHJIkQU54u8MuMnp7+2hSwWC2QNz15+9jbA== X-Gm-Gg: ASbGncs18XNymDGqW/NIg/Ik817ls5OnAsr7ijGJ7CsmWstJorBftCGDg8TsXxVufMP pPVucHTf7bft5csJJfvJlU+0/RYoWnK2pBnuwocT8siArR9w0IBEDRnM37QyfpWLf8ZQPuCSTsH q8mTPP/oPaXaGiJYyWL++LqLgxoQZaqiPJVFNM6JrvazRJTnEa49tVKQtLP85tc3ehjsnT9BwpW tHXiYnN8iGJfiWMCYVC9LBoFb/xtU48NFzZ/OBl8MFqw8gkWU6XMXaBhEtZvyMuXz+JtM6WuPQ4 LHMcTJ7PXmQXpz3/vFLqx3b37AQ00EWv5D8ErNSvgxA+rkE9L5ev3W6UdDhjjFKs X-Received: by 2002:a05:620a:1d0a:b0:7b1:48ff:6b56 with SMTP id af79cd13be357-7bffcd957c2mr1113109485a.43.1738246848690; Thu, 30 Jan 2025 06:20:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IH8LvuP73BrEcVKJ4waEcA5dNjnfj9FBKi9/IFFs6FMIoOFdimCzdbDlpye2gzx/mnfEgwcVg== X-Received: by 2002:a05:620a:1d0a:b0:7b1:48ff:6b56 with SMTP id af79cd13be357-7bffcd957c2mr1113105385a.43.1738246848318; Thu, 30 Jan 2025 06:20:48 -0800 (PST) Received: from bearskin.sorenson.redhat.com (c-98-227-24-213.hsd1.il.comcast.net. [98.227.24.213]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7c00a9205f4sm77449285a.114.2025.01.30.06.20.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2025 06:20:47 -0800 (PST) From: Frank Sorenson To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, chuck.lever@oracle.com Subject: [nfs-utils PATCH 7/8] mountstats/nfsiostat: Move the checks for empty mountpoint list into the print function Date: Thu, 30 Jan 2025 08:20:06 -0600 Message-ID: <20250130142008.3600334-8-sorenson@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250130142008.3600334-1-sorenson@redhat.com> References: <20250130142008.3600334-1-sorenson@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The test for empty device list and 'No NFS mount points found' message terminate the program immediately if no nfs mounts are present during a particular iteration. However, if multiple iterations are specified, it makes more sense to simply output the message and sleep for the next iteration, since there may be nfs mounts next time through. If we move the test and message into the print function, we still get the message when appropriate, don't terminate on an empty list, and also eliminate two extra copies of the same test and message. Signed-off-by: Frank Sorenson --- tools/mountstats/mountstats.py | 13 ++++--------- tools/nfs-iostat/nfs-iostat.py | 14 ++++---------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py index e640642a..fbd57f51 100755 --- a/tools/mountstats/mountstats.py +++ b/tools/mountstats/mountstats.py @@ -958,6 +958,10 @@ def nfsstat_command(args): return 0 def print_iostat_summary(old, new, devices, time): + if len(devices) == 0: + print('No NFS mount points were found') + return + for device in devices: stats = DeviceData() stats.parse_stats(new[device]) @@ -1005,9 +1009,6 @@ def iostat_command(args): # make certain devices contains only NFS mount points devices = list_nfs_mounts(origdevices, mountstats) - if len(devices) == 0: - print('No NFS mount points were found') - return 1 sample_time = 0 @@ -1026,9 +1027,6 @@ def iostat_command(args): # nfs mountpoints may appear or disappear, so we need to # recheck the devices list each time we parse mountstats devices = list_nfs_mounts(origdevices, mountstats) - if len(devices) == 0: - print('No NFS mount points were found') - return count -= 1 else: while True: @@ -1040,9 +1038,6 @@ def iostat_command(args): # nfs mountpoints may appear or disappear, so we need to # recheck the devices list each time we parse mountstats devices = list_nfs_mounts(origdevices, mountstats) - if len(devices) == 0: - print('No NFS mount points were found') - return args.infile.close() if args.since: diff --git a/tools/nfs-iostat/nfs-iostat.py b/tools/nfs-iostat/nfs-iostat.py index 1502b431..f69ffb0e 100755 --- a/tools/nfs-iostat/nfs-iostat.py +++ b/tools/nfs-iostat/nfs-iostat.py @@ -478,6 +478,10 @@ def parse_stats_file(filename): def print_iostat_summary(old, new, devices, time, options): display_stats = {} + if len(devices) == 0: + print('No NFS mount points were found') + return + for device in devices: stats = DeviceData() stats.parse_stats(new[device]) @@ -612,10 +616,6 @@ client are listed. # make certain devices contains only NFS mount points devices = list_nfs_mounts(origdevices, mountstats) - if len(devices) == 0: - print('No NFS mount points were found') - return - old_mountstats = None sample_time = 0.0 @@ -634,9 +634,6 @@ client are listed. # nfs mountpoints may appear or disappear, so we need to # recheck the devices list each time we parse mountstats devices = list_nfs_mounts(origdevices,mountstats) - if len(devices) == 0: - print('No NFS mount points were found') - return count -= 1 else: while True: @@ -648,9 +645,6 @@ client are listed. # nfs mountpoints may appear or disappear, so we need to # recheck the devices list each time we parse mountstats devices = list_nfs_mounts(origdevices,mountstats) - if len(devices) == 0: - print('No NFS mount points were found') - return # # Main From patchwork Thu Jan 30 14:20:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Sorenson X-Patchwork-Id: 13954649 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 A96F81E3DC8 for ; Thu, 30 Jan 2025 14:20:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246854; cv=none; b=B+vf/QtUuTYJXdh4x+eZ7IqxOuA/YBU5S6CrCSRpqf5aGyygdroI7RECLNAb4KLXO+bDcbZeWQuwz0IjGDiZMzFklCmYe4kIlyKr19wyMrDrFYRfTRE7WFr2/jBNwoTK9NxDzozPjfS9U0Kfjr1KRILlMT37rc52qqupd0PYSi4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738246854; c=relaxed/simple; bh=OI5/0ERKTgkWaq8YkOkWCdfESyjZ2p1uCTlwVwfuBC0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j9IyqqP7YvzroSmfz0AwrgB3vP2YSaurVVMS9oZ2gQe3hpsYajijciFYT98baJyeMb/2bJ3isyH2jQHn2EcQoTFTKh6W8VwslO2gNZF6X+5krhMM7Jz6UFlJG+6G+MpHhUH2NdrSJ8J0ekM96GAM+7vuLe80lv2vwvvVxjEm40k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BeRnpGLw; arc=none smtp.client-ip=170.10.133.124 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="BeRnpGLw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738246851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mhaqrh4lZDuWplsQ0AhOqQlJ1/OA1lhGzx0eRmkWYp0=; b=BeRnpGLwgwCqevUecRw7qzcJYrVc1k/P/JHD095uzFjwDDcbYyg8ZICk06HAkSK1O7ATYp Q2cLdd5jd49GvaolUNaH2NJjjdNQMdHtwqyw2FXqtxIJJZTyXk6JDtGkC9CFjVT7BDad0k vpV3fGUQUiYeN66BWvOJ0ENoaGlv8ew= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-122-AJQx7af3N56-lBx2OW4hFA-1; Thu, 30 Jan 2025 09:20:50 -0500 X-MC-Unique: AJQx7af3N56-lBx2OW4hFA-1 X-Mimecast-MFC-AGG-ID: AJQx7af3N56-lBx2OW4hFA Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-7b6ecd22efbso133066985a.0 for ; Thu, 30 Jan 2025 06:20:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738246850; x=1738851650; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mhaqrh4lZDuWplsQ0AhOqQlJ1/OA1lhGzx0eRmkWYp0=; b=p1sHc0m0yWJV6lbMeXgDEdtDetV0lFJLIC+1gYTlA//mLhAw4KEAZC9DGJrnvWjzl9 gFZWTHN2ENxO+SD1w+hBdp+wWovW0uVMauNvhiMU81cNcpSJUI4NmX/lBh0oCSCqguqG GMwuKcjrtpn2w1qiiVp49KYzRBf6lE6cjx4Cuzgow0hcJ3WKVaQc3hK5ZrWQIcQdXX25 u6epk6guAQ/urgCT4wmFnUet+NlpmoH5kOMM7suG7QtUReoijNaB7kf5pt1FG/I/hB4L 3S0df6i6bYb5GWgnEIPTlGQLQxkTH1D2GetJsuYcGXipYibJgElUnk83OQ7iYhvQX27D l6UQ== X-Gm-Message-State: AOJu0YxDGrB5C/sKNLG67RAh86RIqAsBwjxOkEtZ23j1iE2bjZJPPLY7 r5PlUuy2fmmOQQE8uXism8PcqkX1ojC2aKPr0RmoTJ3Dz7DGPaOes3s2IL7pD4F0J97GZqUsuY8 RITrp5KhXq9xrz5qxSMNlBmJ1MX66oJQeGPC141naFsTCwlKAvQOmZbD378JUykFWxl6MAjP6+J jqlZ9o2+V7U+D8W+HhwxzuDE++z4ICA/EzK+MVL3Li4w== X-Gm-Gg: ASbGnctYZD1eNa3bSfkymDDpWvGR4p+6C/XBKZdPcQSVLI8y0E3sFdkqVeqo/YsDv8w 9JRnkcyIdKzdGWUa1tkPksYeq1HCyC/mVXRhsundLV2rMsfmxiJzgUaXikygk/z4fQn9HHAPyYG U+FwT5okVnZD/2J8RwegZPxR/Z0etVR7gqw1JAA7EO3FlsGy5k3owIyd7K8uxnRCrMQyb6WVTI1 1JKCTF0xlkJ3lnbUao9dbbtJTtuAn9jtzuxmgDd4wnkXuemjiswWbZGW1JeqHdl4P0YolXczfAB opCpxbbCbhYjfOC+/jNHQdKTZHZjS33/Vb+OepehAGhOeOONOUOl1s1tQNW8RFgF X-Received: by 2002:a05:620a:2b83:b0:7b6:dd89:d86f with SMTP id af79cd13be357-7c0097b8e76mr467289685a.24.1738246849984; Thu, 30 Jan 2025 06:20:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IG9CquF8IlRKMCtbW59ECjrgO03yQNxQvVrHuU25eJ5trOO2Mix/wsNAh1GcBmwM0hO0bVCKQ== X-Received: by 2002:a05:620a:2b83:b0:7b6:dd89:d86f with SMTP id af79cd13be357-7c0097b8e76mr467286285a.24.1738246849625; Thu, 30 Jan 2025 06:20:49 -0800 (PST) Received: from bearskin.sorenson.redhat.com (c-98-227-24-213.hsd1.il.comcast.net. [98.227.24.213]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7c00a9205f4sm77449285a.114.2025.01.30.06.20.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2025 06:20:48 -0800 (PST) From: Frank Sorenson To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, chuck.lever@oracle.com Subject: [nfs-utils PATCH 8/8] mountstats/nfsiostat: merge and rework the infinite and counted loops Date: Thu, 30 Jan 2025 08:20:07 -0600 Message-ID: <20250130142008.3600334-9-sorenson@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250130142008.3600334-1-sorenson@redhat.com> References: <20250130142008.3600334-1-sorenson@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We always want to print at least once, so move the first print before the interval/count tests. The infinite loop and counted loop are nearly identical, so we merge them, and break out of the loop if necessary. By decrementing the count and checking at the beginning of the loop, we also fix a bug where we sleep and parse the mountstats file one extra time after count iterations. Signed-off-by: Frank Sorenson --- tools/mountstats/mountstats.py | 40 ++++++++++++++-------------------- tools/nfs-iostat/nfs-iostat.py | 40 ++++++++++++++-------------------- 2 files changed, 32 insertions(+), 48 deletions(-) diff --git a/tools/mountstats/mountstats.py b/tools/mountstats/mountstats.py index fbd57f51..d488f9e1 100755 --- a/tools/mountstats/mountstats.py +++ b/tools/mountstats/mountstats.py @@ -1007,37 +1007,29 @@ def iostat_command(args): else: old_mountstats = None + sample_time = 0 + # make certain devices contains only NFS mount points devices = list_nfs_mounts(origdevices, mountstats) - - sample_time = 0 + print_iostat_summary(old_mountstats, mountstats, devices, sample_time) if args.interval is None: - print_iostat_summary(old_mountstats, mountstats, devices, sample_time) return - if args.count is not None: - count = args.count - while count != 0: - print_iostat_summary(old_mountstats, mountstats, devices, sample_time) - old_mountstats = mountstats - time.sleep(args.interval) - sample_time = args.interval - mountstats = parse_stats_file(args.infile) - # nfs mountpoints may appear or disappear, so we need to - # recheck the devices list each time we parse mountstats - devices = list_nfs_mounts(origdevices, mountstats) + count = args.count + while True: + if count is not None: count -= 1 - else: - while True: - print_iostat_summary(old_mountstats, mountstats, devices, sample_time) - old_mountstats = mountstats - time.sleep(args.interval) - sample_time = args.interval - mountstats = parse_stats_file(args.infile) - # nfs mountpoints may appear or disappear, so we need to - # recheck the devices list each time we parse mountstats - devices = list_nfs_mounts(origdevices, mountstats) + if count == 0: + break + time.sleep(args.interval) + old_mountstats = mountstats + sample_time = args.interval + mountstats = parse_stats_file(args.infile) + # nfs mountpoints may appear or disappear, so we need to + # recheck the devices list each time we parse mountstats + devices = list_nfs_mounts(origdevices, mountstats) + print_iostat_summary(old_mountstats, mountstats, devices, sample_time) args.infile.close() if args.since: diff --git a/tools/nfs-iostat/nfs-iostat.py b/tools/nfs-iostat/nfs-iostat.py index f69ffb0e..e46b1a83 100755 --- a/tools/nfs-iostat/nfs-iostat.py +++ b/tools/nfs-iostat/nfs-iostat.py @@ -614,37 +614,29 @@ client are listed. print('Illegal value %s' % arg) return - # make certain devices contains only NFS mount points - devices = list_nfs_mounts(origdevices, mountstats) - old_mountstats = None sample_time = 0.0 + # make certain devices contains only NFS mount points + devices = list_nfs_mounts(origdevices, mountstats) + print_iostat_summary(old_mountstats, mountstats, devices, sample_time, options) + if not interval_seen: - print_iostat_summary(old_mountstats, mountstats, devices, sample_time, options) return - if count_seen: - while count != 0: - print_iostat_summary(old_mountstats, mountstats, devices, sample_time, options) - old_mountstats = mountstats - time.sleep(interval) - sample_time = interval - mountstats = parse_stats_file('/proc/self/mountstats') - # nfs mountpoints may appear or disappear, so we need to - # recheck the devices list each time we parse mountstats - devices = list_nfs_mounts(origdevices,mountstats) + while True: + if count_seen: count -= 1 - else: - while True: - print_iostat_summary(old_mountstats, mountstats, devices, sample_time, options) - old_mountstats = mountstats - time.sleep(interval) - sample_time = interval - mountstats = parse_stats_file('/proc/self/mountstats') - # nfs mountpoints may appear or disappear, so we need to - # recheck the devices list each time we parse mountstats - devices = list_nfs_mounts(origdevices,mountstats) + if count == 0: + break + time.sleep(interval) + old_mountstats = mountstats + sample_time = interval + mountstats = parse_stats_file('/proc/self/mountstats') + # nfs mountpoints may appear or disappear, so we need to + # recheck the devices list each time we parse mountstats + devices = list_nfs_mounts(origdevices, mountstats) + print_iostat_summary(old_mountstats, mountstats, devices, sample_time, options) # # Main