Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Feb 2023 22:27:13 GMT
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 847967bc4e19 - main - nfscl: Fix interaction between mmap'd and VOP_WRITE file updates
Message-ID:  <202302082227.318MRDaE081981@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=847967bc4e198a258b030a5864e64e029e7452e5

commit 847967bc4e198a258b030a5864e64e029e7452e5
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2023-02-08 22:25:01 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2023-02-08 22:25:01 +0000

    nfscl: Fix interaction between mmap'd and VOP_WRITE file updates
    
    asomers@ found a problem with the NFS client, where a write to
    an NFS mounted file done via mmap(2) was lost when fspacectl(2)
    was done before it.  This turned out to be caused by clearing the
    dirty bit on pages when the client was doing commit RPCs,
    due to the second argument to vfs_busy_pages() being set to 1.
    Commit RPCs tell the server to commit previously written data to
    stable storage.  However, Commit RPCs do not write data from the
    client to the server.  As such, if the dirty bit on the page has
    been set by a mmap'd write to an address in the page, it should
    not be cleared.  Clearing it causes the mmap'd write to by lost.
    
    This patch fixes the problem by changing the 2nd argument to
    vfs_busy_pages() to 0 for this case.
    
    I doubt this bug has affected many, since it was inherited from
    the old NFS client and was in 4.3 FreeBSD twenty years ago.
    Although fspacectl(2) is FreeBSD 14 specific, a write(2) would
    cause the same failure.
    
    Reviewed by:    kib
    Tested by:      asomers
    PR:     269328
    MFC after:      1 week
---
 sys/fs/nfsclient/nfs_clvnops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index eeffce65a7db..3e9cf7e3a475 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -3015,7 +3015,7 @@ again:
 				wcred = bp->b_wcred;
 			else if (wcred != bp->b_wcred)
 				wcred = NOCRED;
-			vfs_busy_pages(bp, 1);
+			vfs_busy_pages(bp, 0);
 
 			BO_LOCK(bo);
 			/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302082227.318MRDaE081981>