Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5109663pxb; Mon, 15 Feb 2021 09:42:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2miJVUOu30s5w2naU/+kJkd+b6kfEYj3ZgB6Y+CZ2kUoDRF+gJ6N2Vzp+DQwpEAkv3E+d X-Received: by 2002:a17:906:3a10:: with SMTP id z16mr16786381eje.483.1613410930855; Mon, 15 Feb 2021 09:42:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613410930; cv=none; d=google.com; s=arc-20160816; b=ZCT197nY9usYJ6S3iEY8bn3mhQ77I4MVJN59JBpSY/tChtAz/brxv/4jTGNPXowQ2h hjkQdNjzT+2QkLqrI3k20d6WlQG3MedYK7d+So0nmshYTD6pA9dANY0yLjMMipHkH2pW H8KjroSxs4n0AnPYsWk8GCbp93B4MSoK7nmp4ZBE7WOXZz1e7fhUQZ3I37LEdmjTSQXv ZVN0ukkz6UORHOk2z4240QmJ15nv6q5UfAWxuW8PL04fVttY5es+5JXTaRlPcpbis+8S K0oJj3G2tq8UWVRRc+yDkfnyrQtkT8gxkbHsa8IQvd1WywyRlc3P6k/qAm5nB5sWOMkC Ky1Q== 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=8+mPZIGjaM6z+1A3zSLRNc6/eBHpbPT5IAsVWg1K64U=; b=e6I2TUsyNZZ7+mvX9NI7jYcO3jv1CJDBRiDLer7Og9ratvTmQJp25CIbt94Z9cTSu6 a8J2HDO1MFXF5aovES0kXk0tdWr9jfU8TmgyCSy37cAG6cuuzG5wSQME1bpjy5BgGqUd cPGtnDQPhkqKaEdk28FyX31e9YtaOU11A6xjfAx+Iq+cVtloniY3x6XDGgXLIpvh8OQf kIzQHUt6oXjZ+7SVpSeKXm5auGw7mFyfrI3InxBOUP8IZFI9xlImOEq9EracWSxYhHxe 5UUIOr0wsfuytQkBkDQtWHsM6dw7mY7ku7AAt5PpQEXAtPRKgcf5g5pn8pt+tGL3jW8G iWmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernelim-com.20150623.gappssmtp.com header.s=20150623 header.b=jfpHf66T; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i12si12255464ejr.344.2021.02.15.09.41.48; Mon, 15 Feb 2021 09:42:10 -0800 (PST) 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=@kernelim-com.20150623.gappssmtp.com header.s=20150623 header.b=jfpHf66T; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232082AbhBORlS (ORCPT + 99 others); Mon, 15 Feb 2021 12:41:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231740AbhBORkw (ORCPT ); Mon, 15 Feb 2021 12:40:52 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 749A6C061788 for ; Mon, 15 Feb 2021 09:40:11 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id y26so12462432eju.13 for ; Mon, 15 Feb 2021 09:40:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernelim-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8+mPZIGjaM6z+1A3zSLRNc6/eBHpbPT5IAsVWg1K64U=; b=jfpHf66T/7XIYphGMhf1IufHW+u5zu6HAX8mwLHh0zz14Ep/oHH3vHIXBYNbQWVhdK zWCJVovoPpvQuTTRVeKm5gawmb26C0HX5Fa/zPejUnrHrZzTjGcRLDhR88WmD7QnRlPb Wnh58x5xsd8WG2ISL3fbC9PNKEms9htYv5czeyWHIPryFxbhUU+oL4Uaf4gCULSDHLZQ 5WmdGHZkmtLxQWYfDVOfw0ZVtm3unxbflABycvjQco7/w+NCQ6lajgsTnephX5lMRrf+ gDfBHwvuDiZY+s4lqQ4bye+A4tygUf3khlcWiVIWzxAASp7DzMtxDLUcGpvbykEs7rql C1UQ== 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=8+mPZIGjaM6z+1A3zSLRNc6/eBHpbPT5IAsVWg1K64U=; b=oELnmZc42JXP5bQIVtMBlC+f3gL15slvcRMyK1mOpmJtRh8TRj6PrArKd1bNK0xPcq cuuf8HpB/2tpzOD6NubtXk5IHuJbjgKfZtiNlFVENX3gE0X/JoN3QAOvd7tKKc/BRiD1 HOrG5pY4gOUNzccVVD00IALDpZICdF43YOyePSXZvv7jI16YjNbFzglFP8b0i8uxteeb cn1uI/kzk6F2DmlSe6sAic4Ki7vR5Ye2duXQS55TC7J0JpvqEzALhWcGoZsIvu4qW0tT WT4iQqXcYyS4ge5PDyw+SZebNsQbtsuu2vQWHgnkDTAH2BzFYRi7nTLYoae6IS4TOu2L jXoQ== X-Gm-Message-State: AOAM531PXkSa78BzdNK7/SLe8uKQlZodUcgqJMaXmrnlS/iWUzh0fja6 Rdl9yWalqihI2RGNodceSoB6bcjxbdq/tg== X-Received: by 2002:a17:906:708e:: with SMTP id b14mr10042084ejk.325.1613410809913; Mon, 15 Feb 2021 09:40:09 -0800 (PST) Received: from jupiter.home.aloni.org ([77.124.84.167]) by smtp.gmail.com with ESMTPSA id e11sm11257485ejz.94.2021.02.15.09.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 09:40:09 -0800 (PST) From: Dan Aloni To: linux-nfs@vger.kernel.org, Anna Schumaker Cc: Trond Myklebust Subject: [PATCH v1 4/8] sunrpc: have client directory a symlink to the root transport Date: Mon, 15 Feb 2021 19:39:58 +0200 Message-Id: <20210215174002.2376333-5-dan@kernelim.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210215174002.2376333-1-dan@kernelim.com> References: <20210215174002.2376333-1-dan@kernelim.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Instead of duplicating `dstaddr` in client directory, we add a symlink to the relevant transport directory which now hosts a `dstaddr`. Signed-off-by: Dan Aloni --- net/sunrpc/sysfs.c | 44 ++++++-------------------------------------- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 687d4470b90d..ae608235d7e0 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -69,37 +69,6 @@ int rpc_sysfs_init(void) return -ENOMEM; } -static ssize_t rpc_netns_dstaddr_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) -{ - struct rpc_netns_client *c = container_of(kobj, - struct rpc_netns_client, kobject); - struct rpc_clnt *clnt = c->clnt; - struct rpc_xprt *xprt = rcu_dereference(clnt->cl_xprt); - - return rpc_ntop((struct sockaddr *)&xprt->addr, buf, PAGE_SIZE); -} - -static ssize_t rpc_netns_dstaddr_store(struct kobject *kobj, - struct kobj_attribute *attr, const char *buf, size_t count) -{ - struct rpc_netns_client *c = container_of(kobj, - struct rpc_netns_client, kobject); - struct rpc_clnt *clnt = c->clnt; - struct rpc_xprt *xprt = rcu_dereference(clnt->cl_xprt); - struct sockaddr *saddr = (struct sockaddr *)&xprt->addr; - int port = rpc_get_port(saddr); - - xprt->addrlen = rpc_pton(xprt->xprt_net, buf, count - 1, saddr, sizeof(*saddr)); - rpc_set_port(saddr, port); - - kfree(xprt->address_strings[RPC_DISPLAY_ADDR]); - xprt->address_strings[RPC_DISPLAY_ADDR] = kstrndup(buf, count - 1, GFP_KERNEL); - - xprt->ops->connect(xprt, NULL); - return count; -} - static void rpc_netns_client_release(struct kobject *kobj) { struct rpc_netns_client *c; @@ -113,11 +82,7 @@ static const void *rpc_netns_client_namespace(struct kobject *kobj) return container_of(kobj, struct rpc_netns_client, kobject)->net; } -static struct kobj_attribute rpc_netns_client_dstaddr = __ATTR(dstaddr, - 0644, rpc_netns_dstaddr_show, rpc_netns_dstaddr_store); - static struct attribute *rpc_netns_client_attrs[] = { - &rpc_netns_client_dstaddr.attr, NULL, }; @@ -156,12 +121,14 @@ void rpc_netns_client_sysfs_setup(struct rpc_clnt *clnt, struct net *net) { struct rpc_netns_client *rpc_client; struct rpc_xprt *xprt = rcu_dereference(clnt->cl_xprt); - - if (!(xprt->prot & (IPPROTO_TCP | XPRT_TRANSPORT_RDMA))) - return; + struct rpc_netns_xprt *rpc_xprt; + int ret; rpc_client = rpc_netns_client_alloc(rpc_client_kobj, net, clnt->cl_clid); if (rpc_client) { + rpc_xprt = xprt->sysfs; + ret = sysfs_create_link_nowarn(&rpc_client->kobject, + &rpc_xprt->kobject, "transport"); clnt->cl_sysfs = rpc_client; rpc_client->clnt = clnt; kobject_uevent(&rpc_client->kobject, KOBJ_ADD); @@ -173,6 +140,7 @@ void rpc_netns_client_sysfs_destroy(struct rpc_clnt *clnt) struct rpc_netns_client *rpc_client = clnt->cl_sysfs; if (rpc_client) { + sysfs_remove_link(&rpc_client->kobject, "transport"); kobject_uevent(&rpc_client->kobject, KOBJ_REMOVE); kobject_del(&rpc_client->kobject); kobject_put(&rpc_client->kobject); -- 2.26.2