aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Ercolani <rincebrain@gmail.com>2021-06-02 13:00:29 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2021-06-02 13:42:02 +0000
commita19ae1b099ad4d43588f15ef19b8506f606b27cb (patch)
treebe0ccf9e1b4d2c0a2155cb7ae3c8894c1c742e78
parent2422138952d86dd8b02ff33c55f747ca8e381afe (diff)
downloadsrc-a19ae1b099ad4d43588f15ef19b8506f606b27cb.tar.gz
src-a19ae1b099ad4d43588f15ef19b8506f606b27cb.zip
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
-rw-r--r--sys/kern/vfs_vnops.c11
1 files 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