On Sun, 16 Oct 2016, Stefan Fritsch wrote: > > * When a R/W mount is updated to R/O. I will send patches for this in a > > separate mail.
Part 2: Use it msdosfs & ffs: flush cache if updating mount to r/o Other filesystems can be changed later. ok? diff --git sys/msdosfs/msdosfs_vfsops.c sys/msdosfs/msdosfs_vfsops.c index e13b0b1..ae1a6d9 100644 --- sys/msdosfs/msdosfs_vfsops.c +++ sys/msdosfs/msdosfs_vfsops.c @@ -64,6 +64,7 @@ #include <sys/malloc.h> #include <sys/dirent.h> #include <sys/disk.h> +#include <sys/dkio.h> #include <sys/stdint.h> #include <msdosfs/bpb.h> @@ -128,8 +129,13 @@ msdosfs_mount(struct mount *mp, const char *path, void *data, if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; error = vflush(mp, NULLVP, flags); - if (!error) + if (!error) { + int force = 0; + pmp->pm_flags |= MSDOSFSMNT_RONLY; + /* may be not supported, ignore error */ + VOP_IOCTL(pmp->pm_devvp, DIOCCACHESYNC, &force, FWRITE, FSCRED, p); + } } if (!error && (mp->mnt_flag & MNT_RELOAD)) /* not yet implemented */ diff --git sys/ufs/ffs/ffs_vfsops.c sys/ufs/ffs/ffs_vfsops.c index 99eaf52..abe5756 100644 --- sys/ufs/ffs/ffs_vfsops.c +++ sys/ufs/ffs/ffs_vfsops.c @@ -456,6 +456,16 @@ success: fs->fs_flags &= ~FS_DOSOFTDEP; } ffs_sbupdate(ump, MNT_WAIT); + if (ronly) { + int force = 0; + + /* + * Updating mount to readonly. Try a cache flush. + * Ignore error because the ioctl may not be supported. + */ + VOP_IOCTL(ump->um_devvp, DIOCCACHESYNC, &force, + FWRITE, FSCRED, p); + } } return (0);