From nobody Mon Dec 13 16:30:44 2021 X-Original-To: freebsd-current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1759318D3F31 for ; Mon, 13 Dec 2021 16:30:52 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4JCRp35lYfz4RSG for ; Mon, 13 Dec 2021 16:30:51 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 1BDGUiEG055385 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 13 Dec 2021 18:30:47 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 1BDGUiEG055385 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 1BDGUiUi055384; Mon, 13 Dec 2021 18:30:44 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 13 Dec 2021 18:30:44 +0200 From: Konstantin Belousov To: Rick Macklem Cc: FreeBSD Current Subject: Re: RFC: What to do about Allocate in the NFS server for FreeBSD13? Message-ID: References: List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.5 X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on tom.home X-Rspamd-Queue-Id: 4JCRp35lYfz4RSG X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Mon, Dec 13, 2021 at 04:26:42PM +0000, Rick Macklem wrote: > Hi, > > There are two problems with Allocate in the NFSv4.2 server in FreeBSD13: > 1 - It uses the thread credentials instead of the ones for the RPC. > 2 - It does not ensure that file changes are committed to stable storage. > These problems are fixed by commit f0c9847a6c47 in main, which added > ioflag and cred arguments to VOP_ALLOCATE(). > > I can think of 3 ways to fix Allocate in FreeBSD13: > 1 - Apply a *hackish* patch like this: > + savcred = p->td_ucred; > + td->td_ucred = cred; > do { > olen = len; > error = VOP_ALLOCATE(vp, &off, &len); > if (error == 0 && len > 0 && olen > len) > maybe_yield(); > } while (error == 0 && len > 0 && olen > len); > + p->td_ucred = savcred; > if (error == 0 && len > 0) > error = NFSERR_IO; > + if (error == 0) > + error = VOP_FSYNC(vp, MNT_WAIT, p); > The worst part of it is temporarily setting td_ucred to cred. > > 2 - MFC'ng commit f0c9847a6c47. Normally changes to the > VOP/VFS are not MFC'd. However, in this case, it might be > ok to do so, since it is unlikely there is an out of source tree > file system with a custom VOP_ALLOCATE() method? I do not see much wrong with #2, this is what I would do myself. > > 3 - Just disable it. Currently it is disabled by default and it > could just be wired down disabled. > Allocate is not that useful, since ZFS does not support it. > > As an aside to this, the IETF NFSv4 working group seems to > have agreed that NFS4ERR_NOTSUPP can be returned by a > NFSv4.2 server on a 'per file system basis" instead of globally, > since the Linux knfsd already does this. > --> As such, Allocate can be enabled by default in main and > could be enabled by default in FreeBSD13, if #1 or #2 was > done. > --> It still would not work for ZFS exports. > > So, what do you think is the preferred alternative? > > rick >