diff options
author | Grigoriy Orlov <gluk@cvs.openbsd.org> | 2001-04-04 20:19:05 +0000 |
---|---|---|
committer | Grigoriy Orlov <gluk@cvs.openbsd.org> | 2001-04-04 20:19:05 +0000 |
commit | 5f0b8bc5940f501a5f097fbdaf785a597274dd29 (patch) | |
tree | 16aea2e6c2b721c50395db26d64c3b33645348f8 /sys | |
parent | 6d8e6e23755f00f6e9ca3de72b46523ec978316a (diff) |
Add "softdep" option to mount. Update from rw/async to softdep
and otherwise are disabled.
art@ ok.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/vfs_syscalls.c | 10 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_softdep.c | 6 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 139 |
3 files changed, 113 insertions, 42 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 4edefb404cf..64c9cbd11b2 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_syscalls.c,v 1.69 2001/03/16 16:24:57 art Exp $ */ +/* $OpenBSD: vfs_syscalls.c,v 1.70 2001/04/04 20:19:02 gluk Exp $ */ /* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */ /* @@ -142,7 +142,7 @@ sys_mount(p, v, retval) return (EOPNOTSUPP); /* Needs translation */ } mp->mnt_flag |= - SCARG(uap, flags) & (MNT_RELOAD | MNT_FORCE | MNT_UPDATE); + SCARG(uap, flags) & (MNT_RELOAD | MNT_UPDATE); /* * Only root, or the user that did the original mount is * permitted to update it. @@ -262,9 +262,11 @@ update: else if (mp->mnt_flag & MNT_RDONLY) mp->mnt_flag |= MNT_WANTRDWR; mp->mnt_flag &=~ (MNT_NOSUID | MNT_NOEXEC | MNT_NODEV | - MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_NOATIME); + MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_SOFTDEP | + MNT_NOATIME | MNT_FORCE); mp->mnt_flag |= SCARG(uap, flags) & (MNT_NOSUID | MNT_NOEXEC | - MNT_NODEV | MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_NOATIME); + MNT_NODEV | MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | + MNT_SOFTDEP | MNT_NOATIME | MNT_FORCE); /* * Mount the filesystem. */ diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index e647919e1c1..6018663b7b0 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_softdep.c,v 1.20 2001/03/08 10:56:47 art Exp $ */ +/* $OpenBSD: ffs_softdep.c,v 1.21 2001/04/04 20:19:03 gluk Exp $ */ /* * Copyright 1998, 2000 Marshall Kirk McKusick. All Rights Reserved. * @@ -1091,14 +1091,12 @@ softdep_mount(devvp, mp, fs, cred) struct buf *bp; int error, cyl; - mp->mnt_flag &= ~MNT_ASYNC; - mp->mnt_flag |= MNT_SOFTDEP; /* * When doing soft updates, the counters in the * superblock may have gotten out of sync, so we have * to scan the cylinder groups and recalculate them. */ - if (fs->fs_clean != 0) + if ((fs->fs_flags & FS_UNCLEAN) == 0) return (0); bzero(&cstotal, sizeof cstotal); for (cyl = 0; cyl < fs->fs_ncg; cyl++) { diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 5535fb7448f..077b95c9adf 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vfsops.c,v 1.34 2001/03/22 00:20:54 art Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.35 2001/04/04 20:19:04 gluk Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -157,6 +157,23 @@ ffs_mount(mp, path, data, ndp, p) error = copyin(data, &args, sizeof (struct ufs_args)); if (error) return (error); + +#ifndef FFS_SOFTUPDATES + if (mp->mnt_flag & MNT_SOFTDEP) { + printf("WARNING: soft updates isn't compiled in\n"); + mp->mnt_flag &= ~MNT_SOFTDEP; + } +#endif + + /* + * Soft updates is incompatible with "async", + * so if we are doing softupdates stop the user + * from setting the async flag. + */ + if ((mp->mnt_flag & (MNT_SOFTDEP | MNT_ASYNC)) == + (MNT_SOFTDEP | MNT_ASYNC)) { + return (EINVAL); + } /* * If updating, check whether changing from read-only to * read/write; if there is no device name, that's all we do. @@ -172,12 +189,47 @@ ffs_mount(mp, path, data, ndp, p) flags = WRITECLOSE; if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; - if (mp->mnt_flag & MNT_SOFTDEP) + if (fs->fs_flags & FS_DOSOFTDEP) { error = softdep_flushfiles(mp, flags, p); - else + mp->mnt_flag &= ~MNT_SOFTDEP; + } else error = ffs_flushfiles(mp, flags, p); ronly = 1; } + + /* + * Flush soft dependencies if disabling it via an update + * mount. This may leave some items to be processed, + * so don't do this yet XXX. + */ + if ((fs->fs_flags & FS_DOSOFTDEP) && + !(mp->mnt_flag & MNT_SOFTDEP) && + !(mp->mnt_flag & MNT_RDONLY) && fs->fs_ronly == 0) { +#if 0 + flags = WRITECLOSE; + if (mp->mnt_flag & MNT_FORCE) + flags |= FORCECLOSE; + error = softdep_flushfiles(mp, flags, p); +#elif FFS_SOFTUPDATES + mp->mnt_flag |= MNT_SOFTDEP; +#endif + } + /* + * When upgrading to a softdep mount, we must first flush + * all vnodes. (not done yet -- see above) + */ + if (!(fs->fs_flags & FS_DOSOFTDEP) && + (mp->mnt_flag & MNT_SOFTDEP) && fs->fs_ronly == 0) { +#if 0 + flags = WRITECLOSE; + if (mp->mnt_flag & MNT_FORCE) + flags |= FORCECLOSE; + error = ffs_flushfiles(mp, flags, p); +#else + mp->mnt_flag &= ~MNT_SOFTDEP; +#endif + } + if (!error && (mp->mnt_flag & MNT_RELOAD)) error = ffs_reload(mp, ndp->ni_cnd.cn_cred, p); if (error) @@ -198,6 +250,19 @@ ffs_mount(mp, path, data, ndp, p) } if (fs->fs_clean == 0) { +#if 0 + /* + * It is safe mount unclean file system + * if it was previously mounted with softdep + * but we may loss space and must + * sometimes run fsck manually. + */ + if (fs->fs_flags & FS_DOSOFTDEP) + printf( +"WARNING: %s was not properly unmounted\n", + fs->fs_fsmnt); + else +#endif if (mp->mnt_flag & MNT_FORCE) { printf( "WARNING: %s was not properly unmounted\n", @@ -220,17 +285,6 @@ ffs_mount(mp, path, data, ndp, p) ronly = 0; } - /* - * Soft updates is incompatible with "async", - * so if we are doing softupdates stop the user - * from setting the async flag in an update. - * Softdep_mount() clears it in an initial mount - * or ro->rw remount. - */ - if (mp->mnt_flag & MNT_SOFTDEP) { - mp->mnt_flag &= ~MNT_ASYNC; - } - if (args.fspec == 0) { /* * Process export requests. @@ -343,8 +397,6 @@ ffs_mount(mp, path, data, ndp, p) (void)VFS_STATFS(mp, &mp->mnt_stat, p); success: - if ((mp->mnt_flag & MNT_SOFTDEP)) - mp->mnt_flag &= ~MNT_ASYNC; if (path && (mp->mnt_flag & MNT_UPDATE)) { /* Update clean flag after changing read-onlyness. */ fs = ump->um_fs; @@ -352,8 +404,14 @@ success: fs->fs_ronly = ronly; fs->fs_clean = ronly && (fs->fs_flags & FS_UNCLEAN) == 0 ? 1 : 0; - ffs_sbupdate(ump, MNT_WAIT); } + if (!ronly) { + if (mp->mnt_flag & MNT_SOFTDEP) + fs->fs_flags |= FS_DOSOFTDEP; + else + fs->fs_flags &= ~FS_DOSOFTDEP; + } + ffs_sbupdate(ump, MNT_WAIT); } return (0); @@ -452,8 +510,6 @@ ffs_reload(mountp, cred, p) } if ((fs->fs_flags & FS_DOSOFTDEP)) (void) softdep_mount(devvp, mountp, fs, cred); - else - mountp->mnt_flag &= ~MNT_SOFTDEP; /* * We no longer know anything about clusters per cylinder group. */ @@ -572,6 +628,19 @@ ffs_mountfs(devvp, mp, p) fs->fs_flags &= ~FS_UNCLEAN; if (fs->fs_clean == 0) { fs->fs_flags |= FS_UNCLEAN; +#if 0 + /* + * It is safe mount unclean file system + * if it was previously mounted with softdep + * but we may loss space and must + * sometimes run fsck manually. + */ + if (fs->fs_flags & FS_DOSOFTDEP) + printf( +"WARNING: %s was not properly unmounted\n", + fs->fs_fsmnt); + else +#endif if (ronly || (mp->mnt_flag & MNT_FORCE)) { printf( "WARNING: %s was not properly unmounted\n", @@ -600,10 +669,6 @@ ffs_mountfs(devvp, mp, p) bp = NULL; fs = ump->um_fs; fs->fs_ronly = ronly; - if (ronly == 0) { - fs->fs_fmod = 1; - fs->fs_clean = 0; - } size = fs->fs_cssize; blks = howmany(size, fs->fs_fsize); if (fs->fs_contigsumsize > 0) @@ -680,7 +745,12 @@ ffs_mountfs(devvp, mp, p) free(base, M_UFSMNT); goto out; } + fs->fs_fmod = 1; fs->fs_clean = 0; + if (mp->mnt_flag & MNT_SOFTDEP) + fs->fs_flags |= FS_DOSOFTDEP; + else + fs->fs_flags &= ~FS_DOSOFTDEP; (void) ffs_sbupdate(ump, MNT_WAIT); } return (0); @@ -742,16 +812,16 @@ ffs_unmount(mp, mntflags, p) flags = 0; if (mntflags & MNT_FORCE) flags |= FORCECLOSE; - if (mp->mnt_flag & MNT_SOFTDEP) { - if ((error = softdep_flushfiles(mp, flags, p)) != 0) - return (error); - } else { - if ((error = ffs_flushfiles(mp, flags, p)) != 0) - return (error); - } ump = VFSTOUFS(mp); fs = ump->um_fs; + if (fs->fs_flags & FS_DOSOFTDEP) + error = softdep_flushfiles(mp, flags, p); + else + error = ffs_flushfiles(mp, flags, p); + if (error != 0) + return (error); + if (fs->fs_ronly == 0) { fs->fs_clean = (fs->fs_flags & FS_UNCLEAN) ? 0 : 1; error = ffs_sbupdate(ump, MNT_WAIT); @@ -881,6 +951,7 @@ ffs_sync(mp, waitfor, cred, p) printf("fs = %s\n", fs->fs_fsmnt); panic("update: rofs mod"); } + /* * Write back each (modified) inode. */ @@ -1078,10 +1149,10 @@ retry: * Ensure that uid and gid are correct. This is a temporary * fix until fsck has been changed to do the update. */ - if (fs->fs_inodefmt < FS_44INODEFMT) { /* XXX */ - ip->i_ffs_uid = ip->i_din.ffs_din.di_ouid; /* XXX */ - ip->i_ffs_gid = ip->i_din.ffs_din.di_ogid; /* XXX */ - } /* XXX */ + if (fs->fs_inodefmt < FS_44INODEFMT) { /* XXX */ + ip->i_ffs_uid = ip->i_din.ffs_din.di_ouid; /* XXX */ + ip->i_ffs_gid = ip->i_din.ffs_din.di_ogid; /* XXX */ + } /* XXX */ *vpp = vp; return (0); |