git: e7347be9e34d - main - ffs: Support O_DSYNC.

Thomas Munro tmunro at FreeBSD.org
Fri Jan 8 00:16:58 UTC 2021


The branch main has been updated by tmunro:

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

commit e7347be9e34d05130df878d6af2ff847227610b6
Author:     Thomas Munro <tmunro at FreeBSD.org>
AuthorDate: 2021-01-07 10:50:59 +0000
Commit:     Thomas Munro <tmunro at FreeBSD.org>
CommitDate: 2021-01-08 00:15:56 +0000

    ffs: Support O_DSYNC.
    
    Respect the new IO_DATASYNC flag when performing synchronous writes.
    Compared to O_SYNC, O_DSYNC lets us skip updating the inode in some
    cases, matching the behaviour of fdatasync(2).
    
    Reviewed by: kib
    Differential Review: https://reviews.freebsd.org/D25160
---
 sys/ufs/ffs/ffs_vnops.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c
index f7a1084d2838..6ca98a84869d 100644
--- a/sys/ufs/ffs/ffs_vnops.c
+++ b/sys/ufs/ffs/ffs_vnops.c
@@ -1001,7 +1001,9 @@ ffs_write(ap)
 			uio->uio_resid = resid;
 		}
 	} else if (resid > uio->uio_resid && (ioflag & IO_SYNC)) {
-		error = ffs_update(vp, 1);
+		if (!(ioflag & IO_DATASYNC) ||
+		    (ip->i_flags & (IN_SIZEMOD | IN_IBLKDATA)))
+			error = ffs_update(vp, 1);
 		if (ffs_fsfail_cleanup(VFSTOUFS(vp->v_mount), error))
 			error = ENXIO;
 	}


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