From: Chuck Lever <cel@kernel.org>
To: NeilBrown <neil@brown.name>, Jeff Layton <jlayton@kernel.org>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: <linux-nfs@vger.kernel.org>
Subject: [PATCH 8/9] NFSD: Relocate nfsd4_set_netaddr()
Date: Sun, 12 Jul 2026 16:45:53 -0400 [thread overview]
Message-ID: <20260712204554.125308-9-cel@kernel.org> (raw)
In-Reply-To: <20260712204554.125308-1-cel@kernel.org>
Clean up: Common practice in the Linux kernel is to avoid the use of
static inline functions when there is only a single call site. The
30-line helper function is removed from a header pulled into ~25 .c
files, removing <linux/sunrpc/addr.h> from that header's transitive
include surface, dropping a now-redundant <linux/sunrpc/msg_prot.h>
include, and reducing the function's visibility to the one translation
unit that uses it.
Signed-off-by: Chuck Lever <cel@kernel.org>
---
fs/nfsd/nfs4proc.c | 31 +++++++++++++++++++++++++++++++
fs/nfsd/nfsd.h | 33 ---------------------------------
2 files changed, 31 insertions(+), 33 deletions(-)
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 669896be08b6..59889cdca109 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -2313,6 +2313,37 @@ nfsd4_offload_cancel(struct svc_rqst *rqstp,
return nfs_ok;
}
+static __be32
+nfsd4_set_netaddr(struct sockaddr *addr, struct nfs42_netaddr *netaddr)
+{
+ struct sockaddr_in *sin = (struct sockaddr_in *)addr;
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr;
+ unsigned int port;
+ size_t ret_addr, ret_port;
+
+ switch (addr->sa_family) {
+ case AF_INET:
+ port = ntohs(sin->sin_port);
+ sprintf(netaddr->netid, "tcp");
+ netaddr->netid_len = 3;
+ break;
+ case AF_INET6:
+ port = ntohs(sin6->sin6_port);
+ sprintf(netaddr->netid, "tcp6");
+ netaddr->netid_len = 4;
+ break;
+ default:
+ return nfserr_inval;
+ }
+ ret_addr = rpc_ntop(addr, netaddr->addr, sizeof(netaddr->addr));
+ ret_port = snprintf(netaddr->addr + ret_addr,
+ RPCBIND_MAXUADDRLEN + 1 - ret_addr,
+ ".%u.%u", port >> 8, port & 0xff);
+ WARN_ON(ret_port >= RPCBIND_MAXUADDRLEN + 1 - ret_addr);
+ netaddr->addr_len = ret_addr + ret_port;
+ return 0;
+}
+
static __be32
nfsd4_copy_notify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
union nfsd4_op_u *u)
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 81312b11b5c2..33015657b16f 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -18,8 +18,6 @@
#include <linux/nfs4.h>
#include <linux/sunrpc/svc.h>
#include <linux/sunrpc/svc_xprt.h>
-#include <linux/sunrpc/msg_prot.h>
-#include <linux/sunrpc/addr.h>
#include <uapi/linux/nfsd/debug.h>
@@ -450,37 +448,6 @@ enum {
extern const u32 nfsd_suppattrs[3][3];
-static inline __be32 nfsd4_set_netaddr(struct sockaddr *addr,
- struct nfs42_netaddr *netaddr)
-{
- struct sockaddr_in *sin = (struct sockaddr_in *)addr;
- struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr;
- unsigned int port;
- size_t ret_addr, ret_port;
-
- switch (addr->sa_family) {
- case AF_INET:
- port = ntohs(sin->sin_port);
- sprintf(netaddr->netid, "tcp");
- netaddr->netid_len = 3;
- break;
- case AF_INET6:
- port = ntohs(sin6->sin6_port);
- sprintf(netaddr->netid, "tcp6");
- netaddr->netid_len = 4;
- break;
- default:
- return nfserr_inval;
- }
- ret_addr = rpc_ntop(addr, netaddr->addr, sizeof(netaddr->addr));
- ret_port = snprintf(netaddr->addr + ret_addr,
- RPCBIND_MAXUADDRLEN + 1 - ret_addr,
- ".%u.%u", port >> 8, port & 0xff);
- WARN_ON(ret_port >= RPCBIND_MAXUADDRLEN + 1 - ret_addr);
- netaddr->addr_len = ret_addr + ret_port;
- return 0;
-}
-
static inline bool bmval_is_subset(const u32 *bm1, const u32 *bm2)
{
return !((bm1[0] & ~bm2[0]) ||
--
2.54.0
next prev parent reply other threads:[~2026-07-12 20:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-12 20:45 [PATCH 0/9] Start reorganizing fs/nfsd/nfsd.h Chuck Lever
2026-07-12 20:45 ` [PATCH 1/9] NFSD: Make "stats.h" self-contained Chuck Lever
2026-07-12 20:45 ` [PATCH 2/9] NFSD: Explicitly include "stats.h" Chuck Lever
2026-07-12 20:45 ` [PATCH 3/9] NFSD: include "netns.h" Chuck Lever
2026-07-12 20:45 ` [PATCH 4/9] NFSD: Remove '#include "nfsd.h"' from fs/nfsd/cache.h Chuck Lever
2026-07-12 20:45 ` [PATCH 5/9] NFSD: Move the export.h include from nfsd.h to auth.c Chuck Lever
2026-07-12 20:45 ` [PATCH 6/9] NFSD: Move struct readdir_cd Chuck Lever
2026-07-12 20:45 ` [PATCH 7/9] NFSD: Relocate nfsd_user_namespace() Chuck Lever
2026-07-12 20:45 ` Chuck Lever [this message]
2026-07-12 20:45 ` [PATCH 9/9] NFSD: Relocate NFSv4 "supported attributes" to new header Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260712204554.125308-9-cel@kernel.org \
--to=cel@kernel.org \
--cc=dai.ngo@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox