diff options
author | mckusick <mckusick@FreeBSD.org> | 2002-01-15 07:17:12 +0000 |
---|---|---|
committer | mckusick <mckusick@FreeBSD.org> | 2002-01-15 07:17:12 +0000 |
commit | b8d6599e4cce8ed2f9fb198c5a189d50da1e8353 (patch) | |
tree | 45f779b07dad926c32bb99b3e69a99ca2b14be36 /sys/ufs/ffs/ffs_vfsops.c | |
parent | ec363a654937df9a2fd6fc5b9acdd5a94864a2ad (diff) | |
download | FreeBSD-src-b8d6599e4cce8ed2f9fb198c5a189d50da1e8353.zip FreeBSD-src-b8d6599e4cce8ed2f9fb198c5a189d50da1e8353.tar.gz |
When downgrading a filesystem from read-write to read-only, operations
involving file removal or file update were not always being fully
committed to disk. The result was lost files or corrupted file data.
This change ensures that the filesystem is properly synced to disk
before the filesystem is down-graded.
This delta also fixes a long standing bug in which a file open for
reading has been unlinked. When the last open reference to the file
is closed, the inode is reclaimed by the filesystem. Previously,
if the filesystem had been down-graded to read-only, the inode could
not be reclaimed, and thus was lost and had to be later recovered
by fsck. With this change, such files are found at the time of the
down-grade. Normally they will result in the filesystem down-grade
failing with `device busy'. If a forcible down-grade is done, then
the affected files will be revoked causing the inode to be released
and the open file descriptors to begin failing on attempts to read.
Submitted by: "Sam Leffler" <sam@errno.com>
Diffstat (limited to 'sys/ufs/ffs/ffs_vfsops.c')
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index a9985d5..9025767 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -180,6 +180,14 @@ ffs_mount(mp, path, data, ndp, td) if (fs->fs_ronly == 0 && (mp->mnt_flag & MNT_RDONLY)) { if ((error = vn_start_write(NULL, &mp, V_WAIT)) != 0) return (error); + /* + * Flush any dirty data. + */ + VFS_SYNC(mp, MNT_WAIT, td->td_proc->p_ucred, td); + /* + * Check for and optionally get rid of files open + * for writing. + */ flags = WRITECLOSE; if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; |