From nobody Tue Dec 14 17:19:52 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 D8CEA18EB8A7 for ; Tue, 14 Dec 2021 17:19:53 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JD4r94v7Nz3pry; Tue, 14 Dec 2021 17:19:53 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from [10.0.1.4] (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 2B7DD4AB5; Tue, 14 Dec 2021 17:19:53 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <5b07d437-a81e-9151-b7a4-82c843ef266a@FreeBSD.org> Date: Tue, 14 Dec 2021 09:19:52 -0800 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 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: RFC: What to do about Allocate in the NFS server for FreeBSD13? Content-Language: en-US To: Konstantin Belousov , Rick Macklem Cc: FreeBSD Current References: From: John Baldwin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639502393; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EnH1JMJTUaplXBgBkbAh7Njg9AHK5Cbw0BgRk0JK9rk=; b=CIQMgz+Zps3Lia5VrWdWq8iO8rsnC2tLYF8AhFHFHV+rJD0Bit64Id/zb0E+TJmOf2Hw+J oeiL++R8q7p/ShDkHo21CH3Cs35Y1tSFckCPL+1XYFRzSevHApOhNEMtIi3rZI1UJbITVW 3kzjU5usB9Qti+NDsIa6xpLe/pkXr8gZ+igKjDEJXD/7099meus//siJ4oPeE2HAjaZV9k MD5RFq4FM+mp2OxsHzboLYlO8EtEuFVu0qET2BwJ0hBopT0+urjdiIp0k2MmvGaJiF9RS4 1oR9RJ/2mbAaEZWzK+JfvGz9eZJG41sntIstzmisSLb58TQA2jiKOXM8XaFTmw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639502393; a=rsa-sha256; cv=none; b=WZj3IxDZTkJ2oVpdvUduN+VF6ttmGlfPtx2rNltx1rdzVaTOGucp6bOLXgwJU3bunm5eVZ TUu7Xo/9muT1wtDPuKtiZMJ5sS59lCaa2ZuBid6NyXqUmh6ff/cgC9N2yzhmNj7EbE72PO hjGDNjbJYrJLUdGWxQKj41hf+SyLFUl3qQMyqdX9iHlM55IO5WNaP8oLooA60D29jIetXp 7rtRUQHn0T1ocTd8ZbPJnjBsqCl7Ltl7A+knWECdV0jXDgkpJ8Pa+dTgz+R/atkHftvBd/ r1C8wGY/KOQYhKftpykmL0W6wUL//8RLUeQ4hhspFwx+X5j1QjNbL+gp2oyHug== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N On 12/13/21 8:30 AM, Konstantin Belousov wrote: > 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. I also think this is fine. -- John Baldwin