public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: Jeff Layton <jlayton@kernel.org>, NeilBrown <neil@brown.name>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: Trond Myklebust <trondmy@kernel.org>,
	Anna Schumaker <anna@kernel.org>,
	linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 09/14] sunrpc: add netlink upcall for the auth.unix.gid cache
Date: Fri, 20 Mar 2026 10:32:08 -0400	[thread overview]
Message-ID: <47cd2355-04b1-4719-8d91-421d2a9fbcd3@oracle.com> (raw)
In-Reply-To: <20260316-exportd-netlink-v1-9-6125dc62b955@kernel.org>

On 3/16/26 11:14 AM, Jeff Layton wrote:

> diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
> index e4b196742877bd3abf199f2bf815b90615a2be04..b84511ff726c1836f777c802943f6d8e112a0998 100644
> --- a/net/sunrpc/svcauth_unix.c
> +++ b/net/sunrpc/svcauth_unix.c
> @@ -585,12 +585,241 @@ static int unix_gid_show(struct seq_file *m,
>  	return 0;
>  }
>  
> +static int unix_gid_notify(struct cache_detail *cd, struct cache_head *h)
> +{
> +	return sunrpc_cache_notify(cd, h, SUNRPC_CACHE_TYPE_UNIX_GID);
> +}
> +
> +/**
> + * sunrpc_nl_unix_gid_get_reqs_dumpit - dump pending unix_gid requests
> + * @skb: reply buffer
> + * @cb: netlink metadata and command arguments
> + *
> + * Walk the unix_gid cache's pending request list and create a netlink
> + * message with a nested entry for each cache_request, containing the
> + * seqno and uid.
> + *
> + * Returns the size of the reply or a negative errno.
> + */
> +int sunrpc_nl_unix_gid_get_reqs_dumpit(struct sk_buff *skb,
> +					struct netlink_callback *cb)
> +{
> +	struct sunrpc_net *sn;
> +	struct cache_detail *cd;
> +	struct cache_head **items;
> +	u64 *seqnos;
> +	int cnt, i;
> +	void *hdr;
> +	int ret;
> +
> +	sn = net_generic(sock_net(skb->sk), sunrpc_net_id);
> +
> +	cd = sn->unix_gid_cache;
> +	if (!cd)
> +		return -ENODEV;
> +
> +	/* Second call means we've already dumped everything */
> +	if (cb->args[0])
> +		return 0;
> +
> +	cnt = sunrpc_cache_requests_count(cd);
> +	if (!cnt)
> +		return 0;
> +
> +	items = kcalloc(cnt, sizeof(*items), GFP_KERNEL);
> +	seqnos = kcalloc(cnt, sizeof(*seqnos), GFP_KERNEL);
> +	if (!items || !seqnos) {
> +		ret = -ENOMEM;
> +		goto out_alloc;
> +	}
> +
> +	cnt = sunrpc_cache_requests_snapshot(cd, items, seqnos, cnt);
> +
> +	hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid,
> +			  cb->nlh->nlmsg_seq, &sunrpc_nl_family,
> +			  NLM_F_MULTI, SUNRPC_CMD_UNIX_GID_GET_REQS);
> +	if (!hdr) {
> +		ret = -ENOBUFS;
> +		goto out_put;
> +	}
> +
> +	for (i = 0; i < cnt; i++) {
> +		struct unix_gid *ug;
> +		struct nlattr *nest;
> +
> +		ug = container_of(items[i], struct unix_gid, h);
> +
> +		nest = nla_nest_start(skb,
> +				      SUNRPC_A_UNIX_GID_REQS_REQUESTS);
> +		if (!nest) {
> +			ret = -ENOBUFS;
> +			goto out_cancel;
> +		}
> +
> +		if (nla_put_u64_64bit(skb, SUNRPC_A_UNIX_GID_SEQNO,
> +				      seqnos[i], 0) ||
> +		    nla_put_u32(skb, SUNRPC_A_UNIX_GID_UID,
> +				from_kuid(&init_user_ns, ug->uid))) {
> +			nla_nest_cancel(skb, nest);
> +			ret = -ENOBUFS;
> +			goto out_cancel;
> +		}
> +
> +		nla_nest_end(skb, nest);
> +	}
> +
> +	genlmsg_end(skb, hdr);
> +	cb->args[0] = 1;
> +	ret = skb->len;
> +	goto out_put;
> +
> +out_cancel:
> +	genlmsg_cancel(skb, hdr);
> +out_put:
> +	for (i = 0; i < cnt; i++)
> +		cache_put(items[i], cd);
> +out_alloc:
> +	kfree(seqnos);
> +	kfree(items);
> +	return ret;
> +}
sunrpc_nl_unix_gid_get_reqs_dumpit() packs its reply entries into a
single netlink message. The default SKB size is ~8 KiB, and each entry
encodes to ~24 bytes, so the buffer fills at roughly 340 entries. When
nla_put fails, the function returns -ENOBUFS but never sets

  cb->args[0] = 1;

causing the netlink subsystem to retry indefinitely. A big NFS server
can easily exceed 340 pending GID cache entries.

Should we implement proper netlink dump continuation: snapshot once
then emit entries across multiple dumpit calls using a cursor in
cb->args?

-- 
Chuck Lever

  reply	other threads:[~2026-03-20 14:32 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-16 15:14 [PATCH 00/14] nfsd/sunrpc: add support for netlink upcalls for mountd/exportd Jeff Layton
2026-03-16 15:14 ` [PATCH 01/14] nfsd: move struct nfsd_genl_rqstp to nfsctl.c Jeff Layton
2026-03-16 15:14 ` [PATCH 02/14] sunrpc: rename sunrpc_cache_pipe_upcall() to sunrpc_cache_upcall() Jeff Layton
2026-03-16 15:14 ` [PATCH 03/14] sunrpc: rename sunrpc_cache_pipe_upcall_timeout() Jeff Layton
2026-03-16 15:14 ` [PATCH 04/14] sunrpc: rename cache_pipe_upcall() to cache_do_upcall() Jeff Layton
2026-03-19 13:54   ` Chuck Lever
2026-03-16 15:14 ` [PATCH 05/14] sunrpc: add a cache_notify callback Jeff Layton
2026-03-19 15:13   ` Chuck Lever
2026-03-16 15:14 ` [PATCH 06/14] sunrpc: add helpers to count and snapshot pending cache requests Jeff Layton
2026-03-19 18:07   ` Chuck Lever
2026-03-19 18:22     ` Jeff Layton
2026-03-19 18:47       ` Chuck Lever
2026-03-16 15:14 ` [PATCH 07/14] sunrpc: add a generic netlink family for cache upcalls Jeff Layton
2026-03-19 18:44   ` Chuck Lever
2026-03-19 19:14   ` Chuck Lever
2026-03-19 19:19     ` Jeff Layton
2026-03-19 19:20       ` Chuck Lever
2026-03-19 19:31         ` Chuck Lever
2026-03-16 15:14 ` [PATCH 08/14] sunrpc: add netlink upcall for the auth.unix.ip cache Jeff Layton
2026-03-16 15:14 ` [PATCH 09/14] sunrpc: add netlink upcall for the auth.unix.gid cache Jeff Layton
2026-03-20 14:32   ` Chuck Lever [this message]
2026-03-16 15:14 ` [PATCH 10/14] nfsd: add new netlink spec for svc_export upcall Jeff Layton
2026-03-20 15:17   ` Chuck Lever
2026-03-23 20:00     ` Jeff Layton
2026-03-16 15:14 ` [PATCH 11/14] nfsd: add netlink upcall for the svc_export cache Jeff Layton
2026-03-16 15:14 ` [PATCH 12/14] nfsd: add netlink upcall for the nfsd.fh cache Jeff Layton
2026-03-16 15:14 ` [PATCH 13/14] sunrpc: add SUNRPC_CMD_CACHE_FLUSH netlink command Jeff Layton
2026-03-16 15:14 ` [PATCH 14/14] nfsd: add NFSD_CMD_CACHE_FLUSH " Jeff Layton

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=47cd2355-04b1-4719-8d91-421d2a9fbcd3@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=Dai.Ngo@oracle.com \
    --cc=anna@kernel.org \
    --cc=jlayton@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=tom@talpey.com \
    --cc=trondmy@kernel.org \
    /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