Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp25850pxb; Thu, 15 Apr 2021 21:35:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBp3XvsvchPP5CgkBa8cJ1Nq3IU+oD9gQUD8ewg8/BETL2kBtXdcebwgtmXtw9nEow4poX X-Received: by 2002:aa7:cd52:: with SMTP id v18mr7786239edw.97.1618547711832; Thu, 15 Apr 2021 21:35:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618547711; cv=none; d=google.com; s=arc-20160816; b=prIKemnOeltBvtBdnnYr6PVCbKr/Oq7TcrjHk1I1RmX5/VwmsRIH1sssdWcN4w9kic 5LJQjPdmjkYWEQUL5vqc5ku7IiU7IWZ22PIEOgnL0wHlgLh9ejIM5TMG9ZYT5NAwC55J zNpnzyKsa7byLn38fdDjNxjUEAi183TGKH7f4W4XafW99bt5G5K3RjvVtMz2ZW2W0r5k shqvXGWkrNCPAdUhj6IYNoacLRf9KxCMOPUglkgL30RhS9nYJ9pOubF+QjjMasE2zFqL WYIenwYuhQs7QT80I5hnYWpUQmmq0kVDd/UqnKfsFVN/I/PIRzXJzUi4IaSz8/bQtaxl Ke6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IvIGbq9ssctXnwv6tZgOI2Y2lz7KazuLx7B7Qa8Jcx8=; b=uzKcvfW+mB7qwZ8Deuy5+GPrD/DcLNFcYk46Vf901twf0wSBQzioZwCEE5XLiVzhv8 JYKFmfosHCHFlZJmk4HKmn1elBzSkc5uCuiNYZqqNlmoSO6+DfqaqAAY01zkt0hMD+2m 4jFMqDBnI/utsLShxMAPfdyGhmA37ZXofSLT1lD5d/Bvpv5HpHi7FXSKnEI6E4bRu25/ htqK3obMh5asochs1Ci8E4kurIFBa9FdtRWlG0K79z+okOZp3vu9WNa7DDFlEJyzQdxK 2zcpTeeIZHbCDNKVQunZkeyejToYJtItWHR73U39DZfd0Lv2LEPsQOQjhiivkK4BpEF9 vh+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tBNVBFaE; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx23si4016351edb.466.2021.04.15.21.34.46; Thu, 15 Apr 2021 21:35:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tBNVBFaE; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236724AbhDPDxJ (ORCPT + 99 others); Thu, 15 Apr 2021 23:53:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238330AbhDPDxI (ORCPT ); Thu, 15 Apr 2021 23:53:08 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AE2DC061574 for ; Thu, 15 Apr 2021 20:52:43 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id 130so13399715qkm.4 for ; Thu, 15 Apr 2021 20:52:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IvIGbq9ssctXnwv6tZgOI2Y2lz7KazuLx7B7Qa8Jcx8=; b=tBNVBFaE+FZQpcjDaDkTNayUw9w0xrTrN12wq+zSLl+jwg0Dfmyw69xoZRfAapqJAa ddaOFbPhqO8ZMrqplSXRfIgwNpNR7gZEH08s0l+86fSgloPC3PcMj3C6kDwD+wzUtcyg cd7Tzw+GGWa4CzTqAt/ma7e/EtR8QMVjozfIlF3iDjwot4nfgPXx5tckWG6GQ1lbQyzX 2ukWMghxb4e5skCUzoS9UKSzb7xXvqkp4ViqbCKL5fYZVTN81jw3q7Vn7hfCxcmXbEVe VSiHI8TYFQDDRpeDu+Yo7IDSUgX+4x3hVNpxJN8vONNx1Rc4myoEx9iqanFIev43lDgQ qFcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IvIGbq9ssctXnwv6tZgOI2Y2lz7KazuLx7B7Qa8Jcx8=; b=oCD8FeAsh4VSd7AIAr7DpQJ8AyFuYVeDxa9OjZlD9qUqa2+SY5cAmEsbKRvqUkFZux cmPvtU/fcSsykAr3FQds2fZMFr8HTqfGJXP4b8pEPpe4Jb9ksPmWDfc0RQgnTgC/amfT NIgDA3Ck8ccwuMXfGoxr3kNhxCVyZCvHv+nnlYUT3JJluy2hX6rAgJOUvJhKSnXF/0UE b3KzUU977TKx0flZVDsfI93wR3Ad6+WG+Z7a+rvvy3bIt7DEi/1PsPSfq42pIS4mWEds bh2S+8NirvDva2HIVNzvWIVPA7h9nTKpofXfqrmOmqCNMifwZIHlO8ShDfUpExeGPpgM RjbA== X-Gm-Message-State: AOAM533ZAuE86O30T6GHpMTFHnfVkldrpWffWXoFKGNXYmu1O1ROQJxB 8N8W+FnsruLkzkUfAYCTaOob/v/2ur8= X-Received: by 2002:a37:6756:: with SMTP id b83mr6868145qkc.385.1618545162883; Thu, 15 Apr 2021 20:52:42 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-25.netapp.com. [216.240.30.25]) by smtp.gmail.com with ESMTPSA id x82sm3500913qkb.0.2021.04.15.20.52.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Apr 2021 20:52:42 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 12/13] sunrpc: provide transport info in the sysfs directory Date: Thu, 15 Apr 2021 23:52:25 -0400 Message-Id: <20210416035226.53588-13-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210416035226.53588-1-olga.kornievskaia@gmail.com> References: <20210416035226.53588-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Allow to query transport's attributes. Currently showing following fields of the rpc_xprt structure: state, last_used, cong, cwnd, max_reqs, min_reqs, num_reqs, sizes of queues binding, sending, pending, backlog. Signed-off-by: Olga Kornievskaia --- net/sunrpc/sysfs.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 20c622c3330e..e7a728da8e9c 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -72,6 +72,56 @@ static ssize_t rpc_sysfs_xprt_dstaddr_show(struct kobject *kobj, return ret + 1; } +static ssize_t rpc_sysfs_xprt_info_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) +{ + struct rpc_xprt *xprt = rpc_sysfs_xprt_kobj_get_xprt(kobj); + ssize_t ret; + int locked, connected, connecting, close_wait, bound, binding, + closing, congested, cwnd_wait, write_space; + + if (!xprt) + return 0; + + if (!xprt->state) { + ret = sprintf(buf, "state=CLOSED\n"); + } else { + locked = test_bit(XPRT_LOCKED, &xprt->state); + connected = test_bit(XPRT_CONNECTED, &xprt->state); + connecting = test_bit(XPRT_CONNECTING, &xprt->state); + close_wait = test_bit(XPRT_CLOSE_WAIT, &xprt->state); + bound = test_bit(XPRT_BOUND, &xprt->state); + binding = test_bit(XPRT_BINDING, &xprt->state); + closing = test_bit(XPRT_CLOSING, &xprt->state); + congested = test_bit(XPRT_CONGESTED, &xprt->state); + cwnd_wait = test_bit(XPRT_CWND_WAIT, &xprt->state); + write_space = test_bit(XPRT_WRITE_SPACE, &xprt->state); + + ret = sprintf(buf, "state=%s %s %s %s %s %s %s %s %s %s\n", + locked ? "LOCKED" : "", + connected ? "CONNECTED" : "", + connecting ? "CONNECTING" : "", + close_wait ? "CLOSE_WAIT" : "", + bound ? "BOUND" : "", + binding ? "BOUNDING" : "", + closing ? "CLOSING" : "", + congested ? "CONGESTED" : "", + cwnd_wait ? "CWND_WAIT" : "", + write_space ? "WRITE_SPACE" : ""); + } + ret += sprintf(buf + ret, "last_used=%lu\ncur_cong=%lu\ncong_win=%lu\n" + "max_num_slots=%u\nmin_num_slots=%u\nnum_reqs=%u\n" + "binding_q_len=%u\nsending_q_len=%u\npending_q_len=%u\n" + "backlog_q_len=%u", xprt->last_used, xprt->cong, + xprt->cwnd, xprt->max_reqs, xprt->min_reqs, + xprt->num_reqs, xprt->binding.qlen, xprt->sending.qlen, + xprt->pending.qlen, xprt->backlog.qlen); + buf[ret] = '\n'; + xprt_put(xprt); + return ret + 1; +} + static ssize_t rpc_sysfs_xprt_dstaddr_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) @@ -171,8 +221,12 @@ static const void *rpc_sysfs_xprt_switch_xprt_namespace(struct kobject *kobj) static struct kobj_attribute rpc_sysfs_xprt_dstaddr = __ATTR(dstaddr, 0644, rpc_sysfs_xprt_dstaddr_show, rpc_sysfs_xprt_dstaddr_store); +static struct kobj_attribute rpc_sysfs_xprt_info = __ATTR(xprt_info, + 0444, rpc_sysfs_xprt_info_show, NULL); + static struct attribute *rpc_sysfs_xprt_attrs[] = { &rpc_sysfs_xprt_dstaddr.attr, + &rpc_sysfs_xprt_info.attr, NULL, }; -- 2.27.0