]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nfsd: use threads array as-is in netlink interface
authorJeff Layton <jlayton@kernel.org>
Wed, 28 May 2025 00:12:47 +0000 (20:12 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Thu, 19 Jun 2025 13:35:38 +0000 (09:35 -0400)
The old nfsdfs interface for starting a server with multiple pools
handles the special case of a single entry array passed down from
userland by distributing the threads over every NUMA node.

The netlink control interface however constructs an array of length
nfsd_nrpools() and fills any unprovided slots with 0's. This behavior
defeats the special casing that the old interface relies on.

Change nfsd_nl_threads_set_doit() to pass down the array from userland
as-is.

Fixes: 7f5c330b2620 ("nfsd: allow passing in array of thread counts via netlink")
Cc: stable@vger.kernel.org
Reported-by: Mike Snitzer <snitzer@kernel.org>
Closes: https://lore.kernel.org/linux-nfs/aDC-ftnzhJAlwqwh@kernel.org/
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfsctl.c

index 3f3e9f6c425018d043492a824b0bf1d4513308a0..6a42cc7a845a144baf3e84d17e415d5380ccdc57 100644 (file)
@@ -1611,7 +1611,7 @@ out_unlock:
  */
 int nfsd_nl_threads_set_doit(struct sk_buff *skb, struct genl_info *info)
 {
-       int *nthreads, count = 0, nrpools, i, ret = -EOPNOTSUPP, rem;
+       int *nthreads, nrpools = 0, i, ret = -EOPNOTSUPP, rem;
        struct net *net = genl_info_net(info);
        struct nfsd_net *nn = net_generic(net, nfsd_net_id);
        const struct nlattr *attr;
@@ -1623,12 +1623,11 @@ int nfsd_nl_threads_set_doit(struct sk_buff *skb, struct genl_info *info)
        /* count number of SERVER_THREADS values */
        nlmsg_for_each_attr(attr, info->nlhdr, GENL_HDRLEN, rem) {
                if (nla_type(attr) == NFSD_A_SERVER_THREADS)
-                       count++;
+                       nrpools++;
        }
 
        mutex_lock(&nfsd_mutex);
 
-       nrpools = max(count, nfsd_nrpools(net));
        nthreads = kcalloc(nrpools, sizeof(int), GFP_KERNEL);
        if (!nthreads) {
                ret = -ENOMEM;