Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1956222pxb; Fri, 25 Mar 2022 08:35:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylPv3ole0QPDBibgi+7v1xB8LFmfB+r5MNvBtRK3tOBoJJ3I1VoWQp0zHnVUQuRT9FItYE X-Received: by 2002:a17:906:b155:b0:6c9:ea2d:3363 with SMTP id bt21-20020a170906b15500b006c9ea2d3363mr11979549ejb.729.1648222539650; Fri, 25 Mar 2022 08:35:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648222539; cv=none; d=google.com; s=arc-20160816; b=Z+p4VgWohMuD7ZmWSPk0TchXyFxUn9EKJbEfUyE+9K47Hrzjr1fhMA9siypPN8P09p 3ipWkQ99WBLLt1TLau+tyRDXDkRlIblS8PpmZL2VGzJ4nV9MZU+K+r+Zfz+X4tgbF5xi owHbpstLdr14rMOulFHo/uw2YyyD8zzu1rINF279tuXyF1qF7y3CzOoiHixvzaOUc3PF ckA7Fm/whOxcdqK+n25W/RQwlzHhPCZ7gOU5UikHPReWkknblB+9zRblZq4BKIz1+UWK zV5S+p14xvJClqK35AcRthSuxOwafE1gCgEYTHpU3W+JzYd5j60QFLYX8Dc6+VFxnekN wxBg== 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:to:from :dkim-signature; bh=C2qehWtr/gA8I2CfPwg4uFDk7w8XqFRkI6nmDW9gIp0=; b=b4N++jGaDQBUcWcdN+Il6b+EhH1RFZc0Y0Y3eEyuaYnq4BAOnRFe00zoW0YWrT06VI 5gpFez/ARqzG9EGnWWQHDCCv9rvs9zGNMcf3cZWqnuj0GmFqTIl9UwrZeopSe5+c8Y59 iJXGhbbBwT7GDjHOyWcjGFDwCyrcWuF6949AbPZWrrCTxh7/kqOiD7xwro3xeTioXdTq Zce5XCj54vrb6aB7Mh4PguXhaf5uXZEjq8UXXfTNUtOH4FT76IdC+uIQFgfN1cRtn007 1VwU6ozcr88RoP50DPUMEKqf9VHhcQ9bKx0zyjqBmM2urMmWYT9e1m39zCi/AXoakarh h5QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XvF7Yfi5; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oq20-20020a170906cc9400b006df76385bc8si2826833ejb.104.2022.03.25.08.35.11; Fri, 25 Mar 2022 08:35:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XvF7Yfi5; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352361AbiCXVl0 (ORCPT + 99 others); Thu, 24 Mar 2022 17:41:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349593AbiCXVlZ (ORCPT ); Thu, 24 Mar 2022 17:41:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 039446473C for ; Thu, 24 Mar 2022 14:39:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 914436139D for ; Thu, 24 Mar 2022 21:39:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE47EC340EE for ; Thu, 24 Mar 2022 21:39:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648157992; bh=KuIxCCcIK5THBRyx1gYe+BY1fxdHeSRRZ1i3INheoJI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XvF7Yfi5EOxzOfLstsznYSX/sJbKOGL8edozo0+akPwiw29IjAfWQh2l4rxaGqOhM vQuHXJMGH+2lJIMC5lf+ogN5fiGF98qCpbNFQ7c4mxfIE6Xu3f5JHwvkFQlv6cuCwd U33kbADOzE/SQep1Fa33zsi5ImxrSDv0zCatKrFOnQZi349MaLvOXqfxaFIbrr3eip JPkJfEoS2YLUlkIU5vf/yrMuiDpAO9I3Laze1wWjr3hTizEO/Htt7qkY8OUtm4hfPP Jdxg/F+CaDFZdUErVIX2yrskBA9zao4kRp/GwytgV3C3rJedbA82gbDC0PnfH3QIXG 3bH4Ciams0T1Q== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH 2/2] SUNRPC: Don't return error values in sysfs read of closed files Date: Thu, 24 Mar 2022 17:33:45 -0400 Message-Id: <20220324213345.5833-2-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220324213345.5833-1-trondmy@kernel.org> References: <20220324213345.5833-1-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust Instead of returning an error value, which ends up being the return value for the read() system call, it is more elegant to simply return the error as a string value. Signed-off-by: Trond Myklebust --- net/sunrpc/sysfs.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 8ce053f84421..796e0f141282 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -93,10 +93,13 @@ static ssize_t rpc_sysfs_xprt_dstaddr_show(struct kobject *kobj, struct rpc_xprt *xprt = rpc_sysfs_xprt_kobj_get_xprt(kobj); ssize_t ret; - if (!xprt) - return 0; + if (!xprt) { + ret = sprintf(buf, "\n"); + goto out; + } ret = sprintf(buf, "%s\n", xprt->address_strings[RPC_DISPLAY_ADDR]); xprt_put(xprt); +out: return ret + 1; } @@ -147,8 +150,8 @@ static ssize_t rpc_sysfs_xprt_info_show(struct kobject *kobj, ssize_t ret; if (!xprt || !xprt_connected(xprt)) { - xprt_put(xprt); - return -ENOTCONN; + ret = sprintf(buf, "\n"); + goto out; } ret = sprintf(buf, "last_used=%lu\ncur_cong=%lu\ncong_win=%lu\n" @@ -165,6 +168,7 @@ static ssize_t rpc_sysfs_xprt_info_show(struct kobject *kobj, atomic_long_read(&xprt->queuelen), (xprt->xprt_class->ident == XPRT_TRANSPORT_TCP) ? xprt->address_strings[RPC_DISPLAY_PORT] : "0"); +out: xprt_put(xprt); return ret + 1; } @@ -178,10 +182,7 @@ static ssize_t rpc_sysfs_xprt_state_show(struct kobject *kobj, int locked, connected, connecting, close_wait, bound, binding, closing, congested, cwnd_wait, write_space, offline, remove; - if (!xprt) - return 0; - - if (!xprt->state) { + if (!(xprt && xprt->state)) { ret = sprintf(buf, "state=CLOSED\n"); } else { locked = test_bit(XPRT_LOCKED, &xprt->state); -- 2.35.1