Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2660723rdb; Tue, 12 Sep 2023 08:27:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFV9l361bQ9NQzcgUII3vTy6h1tJUUl+YqKxVhZupOkRTXSQe+swOHtYAUq8HQ4HXX17Dtq X-Received: by 2002:a05:6a20:918b:b0:14c:d0c0:dd27 with SMTP id v11-20020a056a20918b00b0014cd0c0dd27mr12610790pzd.44.1694532427597; Tue, 12 Sep 2023 08:27:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694532427; cv=none; d=google.com; s=arc-20160816; b=yumZzBrWIMeK8tNtTzJuaCMLo5xjeE8WlSEivDl9HFG22uIrUzc+XOfowBLhH3RtFO 7kaVDHhTBh9Ik+PkMpWmE/8Beji1PBeM2SWzqEPJJiY1IC8c0kzFQ8IJcz5QQrbr3vU+ mdzlQGiymUaq0lpC4mfWqEs/jooppy/FfinjzuOoGaJ4z5ER1NwOFIWKBQHISnZQ7ji1 e8QHFlsQn6WvmJe93NZoQL3h4CgKP22KBn4TN0QjXrQ9gI722F0SBp9VlNVcaGvxHRWy zidG7ZOLHlEdq9psEMJr/USDjc8CpVvRakSiTa6LfhBs2c/GYnBpupu0LumoPdTUM+sO fq2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rFRLN3hZTSiE+jWvmWu9vbVzRFMp6TcYQoUkpBLEI/w=; fh=VxY+Wmqg85qc13Ygd+I5uloGCvRHoxlqj05aFtiB4ak=; b=bhwzRyD7vV02Ayy+iPHSqrZA4bPt/alicNhMyXLm6wp/dFnv5A03o0R5zfbSmV0/yS MDV5d/wWO9AinsKtsdaqGmgzrdZrVuQltMbRgolxrqyPdouooTy3I1HIaCZfuipD9Ofm oiS5a+Ok6ayLoXOdaWfRB6ZRbvSPNyxd3Jqm3etyqkFY0DV3g78UlAcc/rVxSOKrgqPa FEmSga1pzfpgRS2t6lV2OOptrrAeCEBy84X6Fv+AE9jn92/EzaiiMXyFqIusreWFWlvP CAbQ/bM/zt2+8yL6BJ+94lHcWnx5GW0YwznMQ05oWVZZWtwI1I4arDQ3nfiEHrGMXdUN owWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dbRVB3Al; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id m9-20020a654389000000b00565bccfd025si7836075pgp.828.2023.09.12.08.27.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 08:27:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dbRVB3Al; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id C2C658295CDD; Tue, 12 Sep 2023 08:13:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236236AbjILPNv (ORCPT + 99 others); Tue, 12 Sep 2023 11:13:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235748AbjILPNu (ORCPT ); Tue, 12 Sep 2023 11:13:50 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67A6BCC3 for ; Tue, 12 Sep 2023 08:13:46 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 303E5C433C8; Tue, 12 Sep 2023 15:13:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694531626; bh=2L5Bh1G8YCmECxIJnsFzVig/S0IZ4CVAWBpDmSDebTs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dbRVB3AlRvUVWAQA6Dj1F2x7Rl9KDZaVcxb/+z8e2+/eSJegJltepUof0VPErIT2b tAAb3FOebHzyzMsb2l5hIqHaz4r5xTDtXzLos3H7hPahs3Ta2IBXoMPeE1tLNtkURd vZ664z3ZnZtRCTtdTLiLXCyD/0VaivqxnNNwi+w+0DW6k2+/OlR3XzEDUxFWvgPMkz FPfgtXqcfQIuCcrFFeHWRS4+E8e+0EuMVWPE7610CW9CYpkJwtEJVCa7WJgDPp58o6 hnITEQHCd65yfe6NVy7+0tTjDLI5QYuawgv8i2eGdHR9XNBZ0dLoSH49VWjtXJmzku 3MssGYna6kkjA== Date: Tue, 12 Sep 2023 17:13:40 +0200 From: Simon Horman To: Lorenzo Bianconi Cc: linux-nfs@vger.kernel.org, lorenzo.bianconi@redhat.com, chuck.lever@oracle.com, jlayton@kernel.org, neilb@suse.de, netdev@vger.kernel.org Subject: Re: [PATCH v8 3/3] NFSD: add rpc_status netlink support Message-ID: <20230912151340.GH401982@kernel.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 12 Sep 2023 08:13:49 -0700 (PDT) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email On Mon, Sep 11, 2023 at 02:49:46PM +0200, Lorenzo Bianconi wrote: > Introduce rpc_status netlink support for NFSD in order to dump pending > RPC requests debugging information from userspace. > > Tested-by: Jeff Layton > Signed-off-by: Lorenzo Bianconi o Hi Lorenzo, some minor feedback from my side. ... > int nfsd_server_nl_rpc_status_get_dumpit(struct sk_buff *skb, > struct netlink_callback *cb) > { > + struct nfsd_net *nn = net_generic(sock_net(skb->sk), nfsd_net_id); > + int i, ret, rqstp_index; > + > + rcu_read_lock(); > + > + for (i = 0; i < nn->nfsd_serv->sv_nrpools; i++) { > + struct svc_rqst *rqstp; > + > + if (i < cb->args[0]) /* already consumed */ > + continue; > + > + rqstp_index = 0; > + list_for_each_entry_rcu(rqstp, > + &nn->nfsd_serv->sv_pools[i].sp_all_threads, > + rq_all) { > + struct nfsd_genl_rqstp genl_rqstp; > + unsigned int status_counter; > + > + if (rqstp_index++ < cb->args[1]) /* already consumed */ > + continue; > + /* > + * Acquire rq_status_counter before parsing the rqst > + * fields. rq_status_counter is set to an odd value in > + * order to notify the consumers the rqstp fields are > + * meaningful. > + */ > + status_counter = > + smp_load_acquire(&rqstp->rq_status_counter); > + if (!(status_counter & 1)) > + continue; > + > + genl_rqstp.rq_xid = rqstp->rq_xid; > + genl_rqstp.rq_flags = rqstp->rq_flags; > + genl_rqstp.rq_vers = rqstp->rq_vers; > + genl_rqstp.rq_prog = rqstp->rq_prog; > + genl_rqstp.rq_proc = rqstp->rq_proc; > + genl_rqstp.rq_stime = rqstp->rq_stime; > + genl_rqstp.opcnt = 0; > + memcpy(&genl_rqstp.daddr, svc_daddr(rqstp), > + sizeof(struct sockaddr)); > + memcpy(&genl_rqstp.saddr, svc_addr(rqstp), > + sizeof(struct sockaddr)); > + > +#ifdef CONFIG_NFSD_V4 > + if (rqstp->rq_vers == NFS4_VERSION && > + rqstp->rq_proc == NFSPROC4_COMPOUND) { > + /* NFSv4 compund */ nit: compound > + struct nfsd4_compoundargs *args; > + int j; > + > + args = rqstp->rq_argp; > + genl_rqstp.opcnt = args->opcnt; > + for (j = 0; j < genl_rqstp.opcnt; j++) > + genl_rqstp.opnum[j] = > + args->ops[j].opnum; > + } > +#endif /* CONFIG_NFSD_V4 */ > + > + /* > + * Acquire rq_status_counter before reporting the rqst > + * fields to the user. > + */ > + if (smp_load_acquire(&rqstp->rq_status_counter) != > + status_counter) > + continue; > + > + ret = nfsd_genl_rpc_status_compose_msg(skb, cb, > + &genl_rqstp); > + if (ret) > + goto out; > + } > + } > + > + cb->args[0] = i; > + cb->args[1] = rqstp_index; I'm unsure if this is possible, but if the for loop above iterates zero times, or for all iterations (i < cb->args[0]), then rqstp_index will be used uninitialised here. Flagged by Smatch. > + ret = skb->len; > +out: > + rcu_read_unlock(); > + > + return ret; > +} ... > diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h > index 11c14faa6c67..d787bd38c053 100644 > --- a/fs/nfsd/nfsd.h > +++ b/fs/nfsd/nfsd.h > @@ -62,6 +62,22 @@ struct readdir_cd { > __be32 err; /* 0, nfserr, or nfserr_eof */ > }; > > +/* Maximum number of operations per session compound */ > +#define NFSD_MAX_OPS_PER_COMPOUND 50 > + > +struct nfsd_genl_rqstp { > + struct sockaddr daddr; > + struct sockaddr saddr; > + unsigned long rq_flags; > + ktime_t rq_stime; > + __be32 rq_xid; > + u32 rq_vers; > + u32 rq_prog; > + u32 rq_proc; > + /* NFSv4 compund */ nit: compound > + u32 opnum[NFSD_MAX_OPS_PER_COMPOUND]; > + u16 opcnt; > +}; > > extern struct svc_program nfsd_program; > extern const struct svc_version nfsd_version2, nfsd_version3, nfsd_version4; ...