Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3814293pxy; Mon, 26 Apr 2021 10:21:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwN6Ttc7/8szWYptfqfgVQsELHbZFVtIAU4AScWeL72P5KJ3JDXyQgmu+3tDvaZDcdK2lge X-Received: by 2002:a17:907:9607:: with SMTP id gb7mr18928890ejc.380.1619457667846; Mon, 26 Apr 2021 10:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619457667; cv=none; d=google.com; s=arc-20160816; b=yrnhFIDtSFkm1EX8CAFEwzVBn85Y4MTHMlJsAkXspzV9hiYNFoP5V1778Yg7veFmS+ kVr4wMuVaUQ+xHQTzlrKoMDqJIk8E3MP/EtHMjA9HFe/v2cfY9kZmyvzr9SBHpNiW3Ci gHKay2ecW4/hKsgeoid8iOREbq5odMn2XHChbKNT9V9poFESlHhsoEYJnXhetDl/cN8p NMqh3S3/vJA3J4ujLKIEl8+rF4Vih82NlP9tf57wqT1QmdSUGi3BZ146yvUGFy3a+RCL 79iBtU8SEId2sHuaUn+Z4ptJmIflAjf6q+N8BQwK1ITbYK1NGORu3f+b0EcDlPFtu0ja hvxQ== 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=G0zi+heu8E83aReBPxZ9EasqAnPbQehN+00ecDk1Hp8=; b=QLeNiWqwyBnrnnQgmcN7j8TO3bAP8q3JVh8apupV3sfR7YCF8ad/B0+uAybgZGXRSP eMs1wg10wpcdpd14X474tyX23eQTYFGFaNG8myA6lRFwAT/x7LElfb7QE45HZSBXp+T0 zsx0DfrLvmYMitAWS/mZU4uCidqX6GySVyZELK4QtBe045kFvBnec3x8ihU2VHkUhbiC XhCL9meVtXWlYI74SpWA8zKyahdLzbDtoAsgfipWH3HZa5qLvNRutu3IgDaR1UmF+Kpq gO5NeI6DKmnIqNxllWVnHUeYxjy5Nif5oSHt1yoP1/sypINmlXxnTA30y15rBfpRSZmS W4pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="UlgFH/el"; 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 bt1si361780edb.12.2021.04.26.10.20.45; Mon, 26 Apr 2021 10:21:07 -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="UlgFH/el"; 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 S237061AbhDZRU4 (ORCPT + 99 others); Mon, 26 Apr 2021 13:20:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236658AbhDZRUp (ORCPT ); Mon, 26 Apr 2021 13:20:45 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3DF1C061344 for ; Mon, 26 Apr 2021 10:20:03 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id r5so7031475ilb.2 for ; Mon, 26 Apr 2021 10:20:03 -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=G0zi+heu8E83aReBPxZ9EasqAnPbQehN+00ecDk1Hp8=; b=UlgFH/elLK5IXBICKd9Ubp6cc65wa+gRH01Af6r1Jhyf+ZFDqJe3IXd1F3ndDCg3SR Rqm5nMJ0+3ShKuECW13v0LHZ44gzmFQXDiJCIAosQyo9TPQcIpKesfPz+0xUSZzajT+4 WhbF2oOzNMoOKA3nCufa5IEYD7Sh44QcP6KujIyLbUWeZ0HnFZgjPtBPzg4/Pjffo9VN HUaxtLZ78WUj7+zLD4mRLHdI1+7qWayGR2Q3KCQcpBH/WEAkIQl+teK0X6K89a+4yLM3 rAWWig6M4QCA9sYsWVwjrx6MK8Mr002eaBS1S3hopdkhGb4Ee/I4PCaCE95TsmGdG2Jo yNXw== 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=G0zi+heu8E83aReBPxZ9EasqAnPbQehN+00ecDk1Hp8=; b=LHbcaoxtu3S1fQO7Qe62LprwEJ6d9+BC1xkxWxi0EvSUdeLjSczURZuWgWRUdI5tzM aszxDM2SWnhR4vLcxAmycslvlzcQptpj3QjyJcGudZCcOnKU7QMqL0MqXIqv0YBRQroY UVygbQZBVyORq12cugZgpdJqc7Q0CBenhGGFs2jj9BybSQrOmP1BAxYcx0nRphqdUqkI BJ60tevxQ10V80vLywDR0XB7usrE8oCbwMYU+hRN8/kczGmC9kzLwqBrCGOKP0ILPBOT Fvn+9K5m9BYv6zSFwsHp1T2ny0i1ljyYWZYaJug8f9FdM3qMHbffnrwAvuORSxIGIpFY XtBQ== X-Gm-Message-State: AOAM530ktjD4q7emBSESc9kUwdDUmtgP+WVMYuStLOSnrt4E19lBA/cM zPiZBD45t5FnLutuBC3ScYw= X-Received: by 2002:a92:d383:: with SMTP id o3mr14501636ilo.131.1619457603305; Mon, 26 Apr 2021 10:20:03 -0700 (PDT) Received: from kolga-mac-1.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id x13sm207297ilq.85.2021.04.26.10.20.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Apr 2021 10:20:02 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v3 12/13] sunrpc: provide transport info in the sysfs directory Date: Mon, 26 Apr 2021 13:19:46 -0400 Message-Id: <20210426171947.99233-13-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210426171947.99233-1-olga.kornievskaia@gmail.com> References: <20210426171947.99233-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 076f777db3cd..93d4111f6ee3 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