Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp24736rdh; Fri, 22 Sep 2023 23:26:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgBV4b7AAPgURvM8ovORGE5Zk0UDZteHdkARmIJN5yTdq0r9AZUweAL5+SMBuiSYL+bXWk X-Received: by 2002:a17:902:c40e:b0:1be:f37f:a8d5 with SMTP id k14-20020a170902c40e00b001bef37fa8d5mr8321260plk.10.1695450407716; Fri, 22 Sep 2023 23:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695450407; cv=none; d=google.com; s=arc-20160816; b=DuP43ps1eQx7psAfRB3Wkf5OQymKNXZ+Uaq57gGrEpRppzSb5HScxzF/zoEpHYDcb+ I7PfKhmi6FrPmpiWiFWgkH8pd4qaba9FqS7WQwgsEqZypyilzzUQluWdFdeFU4b69wt6 gYnL4l9UONhjEblIjwTAYW9fDnYw3K5WfjGBO1MWw+QjoP1mxowubt1YIc5ohAbiKCMI tg35tBd+lJW3qpo2KYUtB99936p19WNktHxhSC0A4k4gv8uyF/ZCtRJhf47eWFXVAflw IzfDXTGVpgagXBW54WKTspf00c7HQKjOVNhNWMGmeBTTBZv+heKmV0Nk8jZC13noAKWV BqFg== 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=b1iw1laBUN5rzxgrcLFInMJ18Xo8+ygFbeYJ2uUzQns=; fh=ejy/pG1FdSTJlpgEC6m8evkf3Y+lyk6aF6/y5+lRk80=; b=NTxEb0vqHt198TE7TE82DWv2DJzHYF8xl9CHy68fmx7+NALSJTVT6uMXb0tOU01zk+ K/Wg1TQQkhImK+rm1BPHK/coOwrdPMu8D1QRbfvDx9VyyF9ztDh0HjtjEfUMX6keflUW TspgCSS5XF/0G6KvSPyTEpzxnvwPWOrYU45icB83Gp9TuhZYfoYTccn6npqs2bgLueaO UGlbyQ+y+pIF1Tt8mFkpVM5fQeyccsMqJao6rha+2CdIppQ0ePrvPsk5Teib56asRu5Y KvVySJzKw+AGOCF2Ls+vmn5Ti5LFKDumJPM2dPL2hSWF2Gjtj8ESvxwk294vdQWDpofU eXzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N32OfJiK; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id t17-20020a170902e85100b001c46edd8ecfsi6004903plg.276.2023.09.22.23.26.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 23:26:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N32OfJiK; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 2F80D80EA96C; Fri, 22 Sep 2023 12:26:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231283AbjIVT0X (ORCPT + 99 others); Fri, 22 Sep 2023 15:26:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbjIVT0X (ORCPT ); Fri, 22 Sep 2023 15:26:23 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4D23A3 for ; Fri, 22 Sep 2023 12:25:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695410732; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=b1iw1laBUN5rzxgrcLFInMJ18Xo8+ygFbeYJ2uUzQns=; b=N32OfJiKi6UQnXv+pikV3WMPwh8LLyZUdUdamp1Dgo3BMwlbDMBoJe91TgvG/Fm/P+0zmf ahI2nUUvcMct/VOuX83wD0GYB9oufnW82zoOMo7iWAWw+gHZlF/tD8Er6hmtkZ2brHwqyR BPCVL2zFfHfXR7CCB0i8mpgBqpWoCP0= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-437-xStSmjzfPWudn2viC9nbdg-1; Fri, 22 Sep 2023 15:25:31 -0400 X-MC-Unique: xStSmjzfPWudn2viC9nbdg-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-9ae52fbac1dso582218466b.1 for ; Fri, 22 Sep 2023 12:25:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695410730; x=1696015530; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=b1iw1laBUN5rzxgrcLFInMJ18Xo8+ygFbeYJ2uUzQns=; b=leaoqFNsSYfz/c8X9R+CW/mllC6xTEnG572wetCoaZ95m9NIYGF/stqb2qG7x6pWB6 T+4+JsxEwtzYmOj6RZv7l3wEsOmTdDU8uYOd34RvbGbSZ3hNOFAwgeRT1vLfqdRcn1N4 rXzr3DdsiSoaogPRzUkzClmhRJpbsqmD7zqtS76ZQp3B7L31gluPSKUPy2eWAkAn5aGC 8ZqHNu81ptYr8fcAIb+6MMIFygNtmI5fUblOcRM1BGHG8raSE+FYA7IV3ncWOiMevofK V2RKCesS1CjTlk1OjyvRJ6dXuBoGV8Xqt0etDuaUwIiPf//wygrIq7hFrokxY0wtkFyK ZC+A== X-Gm-Message-State: AOJu0Yx6pmPJX4EqXBws7BQI0myu7uhz3KfGYkqPJhJMEiaSOwtKWWfd bek6xIf2f6Auzb1jW1gAQz1AO/brHmBbCpcORTbBakU3ZXAEJaCTIPhQHhz6SNMyAPFfnQobcvM V1Vg3PRphB+b172tfMKB8 X-Received: by 2002:a17:907:daa:b0:9aa:1794:945b with SMTP id go42-20020a1709070daa00b009aa1794945bmr4502195ejc.22.1695410724790; Fri, 22 Sep 2023 12:25:24 -0700 (PDT) X-Received: by 2002:a17:907:daa:b0:9aa:1794:945b with SMTP id go42-20020a1709070daa00b009aa1794945bmr4502151ejc.22.1695410723845; Fri, 22 Sep 2023 12:25:23 -0700 (PDT) Received: from localhost (net-2-34-76-254.cust.vodafonedsl.it. [2.34.76.254]) by smtp.gmail.com with ESMTPSA id z25-20020aa7c659000000b00530ba0fd672sm2589428edr.75.2023.09.22.12.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 12:25:23 -0700 (PDT) Date: Fri, 22 Sep 2023 21:25:21 +0200 From: Lorenzo Bianconi To: Chuck Lever III Cc: Jeff Layton , Lorenzo Bianconi , Linux NFS Mailing List , Neil Brown , "netdev@vger.kernel.org" Subject: Re: [PATCH] NFSD: convert write_threads and write_v4_end_grace to netlink commands Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="czcUg8cbmTF6BK8e" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Fri, 22 Sep 2023 12:26:20 -0700 (PDT) X-Spam-Level: ** --czcUg8cbmTF6BK8e Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable >=20 >=20 > > On Sep 22, 2023, at 12:20 PM, Lorenzo Bianconi wrote: > >=20 > >> On Fri, 2023-09-22 at 14:44 +0200, Lorenzo Bianconi wrote: > >>> Introduce write_threads and write_v4_end_grace netlink commands simil= ar > >>> to the ones available through the procfs. > >>> Introduce nfsd_nl_server_status_get_dumpit netlink command in order to > >>> report global server metadata. > >>>=20 > >>> Signed-off-by: Lorenzo Bianconi > >>> --- > >>> This patch can be tested with user-space tool reported below: > >>> https://github.com/LorenzoBianconi/nfsd-netlink.git > >>> --- > >>> Documentation/netlink/specs/nfsd.yaml | 33 +++++++++ > >>> fs/nfsd/netlink.c | 30 ++++++++ > >>> fs/nfsd/netlink.h | 5 ++ > >>> fs/nfsd/nfsctl.c | 98 +++++++++++++++++++++++++++ > >>> include/uapi/linux/nfsd_netlink.h | 11 +++ > >>> 5 files changed, 177 insertions(+) > >>>=20 > >>> diff --git a/Documentation/netlink/specs/nfsd.yaml b/Documentation/ne= tlink/specs/nfsd.yaml > >>> index 403d3e3a04f3..fa1204892703 100644 > >>> --- a/Documentation/netlink/specs/nfsd.yaml > >>> +++ b/Documentation/netlink/specs/nfsd.yaml > >>> @@ -62,6 +62,15 @@ attribute-sets: > >>> name: compound-ops > >>> type: u32 > >>> multi-attr: true > >>> + - > >>> + name: server-attr > >>> + attributes: > >>> + - > >>> + name: threads > >>> + type: u16 > >>=20 > >> 65k threads ought to be enough for anybody! > >=20 > > maybe u8 is fine here :) >=20 > 32-bit is the usual for this kind of interface. I don't think we need to = go with 16-bit. ack, fine >=20 >=20 > >>> + - > >>> + name: v4-grace > >>> + type: u8 > >>>=20 > >>> operations: > >>> list: > >>> @@ -72,3 +81,27 @@ operations: > >>> dump: > >>> pre: nfsd-nl-rpc-status-get-start > >>> post: nfsd-nl-rpc-status-get-done > >>> + - > >>> + name: threads-set > >>> + doc: set the number of running threads > >>> + attribute-set: server-attr > >>> + flags: [ admin-perm ] [...] > >=20 > > I am not sure if ynl supports a doit operation with a request with no p= arameters. > > @Chuck, Jakub: any input here? >=20 > I think it does, I might have done something like that for one of the > handshake protocol commands. please correct me if I am wrong but in Documentation/netlink/specs/handshak= e.yaml we have accept and done operations and both of them have some parameters in= the request field, right? >=20 > But I think Jeff's right, end_grace might be better postponed. Pick any of > the others that you think might be easy to implement instead. ack, fine. Do you agree to have a global container (server-status-get) for = all the server metadata instead of adding dedicated get APIs? Regards, Lorenzo >=20 >=20 > > Regards, > > Lorenzo > >=20 > >>=20 > >>> + return 0; > >>> +#else > >>> + return -EOPNOTSUPP; > >>> +#endif /* CONFIG_NFSD_V4 */ > >>> +} > >>> + > >>> +/** > >>> + * nfsd_nl_server_status_get_start - Prepare server_status_get dumpit > >>> + * @cb: netlink metadata and command arguments > >>> + * > >>> + * Return values: > >>> + * %0: The server_status_get command may proceed > >>> + * %-ENODEV: There is no NFSD running in this namespace > >>> + */ > >>> +int nfsd_nl_server_status_get_start(struct netlink_callback *cb) > >>> +{ > >>> + struct nfsd_net *nn =3D net_generic(sock_net(cb->skb->sk), nfsd_net= _id); > >>> + > >>> + return nn->nfsd_serv ? 0 : -ENODEV; > >>> +} > >>> + > >>> +/** > >>> + * nfsd_nl_server_status_get_dumpit - dump server status info > >>> + * @skb: reply buffer > >>> + * @cb: netlink metadata and command arguments > >>> + * > >>> + * Returns the size of the reply or a negative errno. > >>> + */ > >>> +int nfsd_nl_server_status_get_dumpit(struct sk_buff *skb, > >>> + struct netlink_callback *cb) > >>> +{ > >>> + struct net *net =3D sock_net(skb->sk); > >>> +#ifdef CONFIG_NFSD_V4 > >>> + struct nfsd_net *nn =3D net_generic(net, nfsd_net_id); > >>> +#endif /* CONFIG_NFSD_V4 */ > >>> + void *hdr; > >>> + > >>> + if (cb->args[0]) /* already consumed */ > >>> + return 0; > >>> + > >>> + hdr =3D genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg= _seq, > >>> + &nfsd_nl_family, NLM_F_MULTI, > >>> + NFSD_CMD_SERVER_STATUS_GET); > >>> + if (!hdr) > >>> + return -ENOBUFS; > >>> + > >>> + if (nla_put_u16(skb, NFSD_A_SERVER_ATTR_THREADS, nfsd_nrthreads(net= ))) > >>> + return -ENOBUFS; > >>> +#ifdef CONFIG_NFSD_V4 > >>> + if (nla_put_u8(skb, NFSD_A_SERVER_ATTR_V4_GRACE, !nn->grace_ended)) > >>> + return -ENOBUFS; > >>> +#endif /* CONFIG_NFSD_V4 */ > >>> + > >>> + genlmsg_end(skb, hdr); > >>> + cb->args[0] =3D 1; > >>> + > >>> + return skb->len; > >>> +} > >>> + > >>> /** > >>> * nfsd_net_init - Prepare the nfsd_net portion of a new net namespace > >>> * @net: a freshly-created network namespace > >>> diff --git a/include/uapi/linux/nfsd_netlink.h b/include/uapi/linux/n= fsd_netlink.h > >>> index c8ae72466ee6..b82fbc53d336 100644 > >>> --- a/include/uapi/linux/nfsd_netlink.h > >>> +++ b/include/uapi/linux/nfsd_netlink.h > >>> @@ -29,8 +29,19 @@ enum { > >>> NFSD_A_RPC_STATUS_MAX =3D (__NFSD_A_RPC_STATUS_MAX - 1) > >>> }; > >>>=20 > >>> +enum { > >>> + NFSD_A_SERVER_ATTR_THREADS =3D 1, > >>> + NFSD_A_SERVER_ATTR_V4_GRACE, > >>> + > >>> + __NFSD_A_SERVER_ATTR_MAX, > >>> + NFSD_A_SERVER_ATTR_MAX =3D (__NFSD_A_SERVER_ATTR_MAX - 1) > >>> +}; > >>> + > >>> enum { > >>> NFSD_CMD_RPC_STATUS_GET =3D 1, > >>> + NFSD_CMD_THREADS_SET, > >>> + NFSD_CMD_V4_GRACE_RELEASE, > >>> + NFSD_CMD_SERVER_STATUS_GET, > >>>=20 > >>> __NFSD_CMD_MAX, > >>> NFSD_CMD_MAX =3D (__NFSD_CMD_MAX - 1) > >>=20 > >> --=20 > >> Jeff Layton > >>=20 >=20 > -- > Chuck Lever >=20 >=20 --czcUg8cbmTF6BK8e Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCZQ3qIQAKCRA6cBh0uS2t rJ48AP0VvpNgQKtdjwn7ofeNi3L5yI66kg6kpSFYRk2bS0CzjgD+M07e7zYmkJuh kV7bYV5G4kaRAMQdiofyYSixUiVYRA8= =TXI6 -----END PGP SIGNATURE----- --czcUg8cbmTF6BK8e--