git: a19ae1b099ad - main - vfs: fix MNT_SYNCHRONOUS check in vn_write

Mateusz Guzik mjg at FreeBSD.org
Wed Jun 2 13:43:16 UTC 2021


The branch main has been updated by mjg:

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

commit a19ae1b099ad4d43588f15ef19b8506f606b27cb
Author:     Rich Ercolani <rincebrain at gmail.com>
AuthorDate: 2021-06-02 13:00:29 +0000
Commit:     Mateusz Guzik <mjg at FreeBSD.org>
CommitDate: 2021-06-02 13:42:02 +0000

    vfs: fix MNT_SYNCHRONOUS check in vn_write
    
    ca1ce50b2b5ef11d ("vfs: add more safety against concurrent forced
    unmount to vn_write") has a side effect of only checking MNT_SYNCHRONOUS
    if O_FSYNC is set.
    
    Reviewed By: mjg
    Differential Revision: https://reviews.freebsd.org/D30610
---
 sys/kern/vfs_vnops.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 019aefead0b3..fc5118e8aa24 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -1123,11 +1123,12 @@ vn_write(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags,
 		ioflag |= IO_NDELAY;
 	if (fp->f_flag & O_DIRECT)
 		ioflag |= IO_DIRECT;
-	if (fp->f_flag & O_FSYNC) {
-		mp = atomic_load_ptr(&vp->v_mount);
-		if (mp != NULL && mp->mnt_flag & MNT_SYNCHRONOUS)
-			ioflag |= IO_SYNC;
-	}
+
+	mp = atomic_load_ptr(&vp->v_mount);
+	if ((fp->f_flag & O_FSYNC) ||
+	    (mp != NULL && (mp->mnt_flag & MNT_SYNCHRONOUS)))
+		ioflag |= IO_SYNC;
+
 	/*
 	 * For O_DSYNC we set both IO_SYNC and IO_DATASYNC, so that VOP_WRITE()
 	 * implementations that don't understand IO_DATASYNC fall back to full


More information about the dev-commits-src-all mailing list