From d1538d110d9557ee9f9e4b04b6cba258e4f43d3a Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Mon, 11 Dec 2017 05:27:41 +0000 Subject: In uvm Chuck decided backing store would not be allocated proactively for blocks re-fetchable from the filesystem. However at reboot time, filesystems are unmounted, and since processes lack backing store they are killed. Since the scheduler is still running, in some cases init is killed... which drops us to ddb [noted by bluhm]. Solution is to convert filesystems to read-only [proposed by kettenis]. The tale follows: sys_reboot() should pass proc * to MD boot() to vfs_shutdown() which completes current IO with vfs_busy VB_WRITE|VB_WAIT, then calls VFS_MOUNT() with MNT_UPDATE | MNT_RDONLY, soon teaching us that *fs_mount() calls a copyin() late... so store the sizes in vfsconflist[] and move the copyin() to sys_mount()... and notice nfs_mount copyin() is size-variant, so kill legacy struct nfs_args3. Next we learn ffs_mount()'s MNT_UPDATE code is sharp and rusty especially wrt softdep, so fix some bugs adn add ~MNT_SOFTDEP to the downgrade. Some vnodes need a little more help, so tie them to &dead_vnops. ffs_mount calling DIOCCACHESYNC is causing a bit of grief still but this issue is seperate and will be dealt with in time. couple hundred reboots by bluhm and myself, advice from guenther and others at the hut --- sys/ufs/ext2fs/ext2fs_vfsops.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'sys/ufs/ext2fs') diff --git a/sys/ufs/ext2fs/ext2fs_vfsops.c b/sys/ufs/ext2fs/ext2fs_vfsops.c index c99cfc78b38..365f01e15ad 100644 --- a/sys/ufs/ext2fs/ext2fs_vfsops.c +++ b/sys/ufs/ext2fs/ext2fs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_vfsops.c,v 1.99 2017/05/30 10:32:53 sf Exp $ */ +/* $OpenBSD: ext2fs_vfsops.c,v 1.100 2017/12/11 05:27:40 deraadt Exp $ */ /* $NetBSD: ext2fs_vfsops.c,v 1.1 1997/06/11 09:34:07 bouyer Exp $ */ /* @@ -162,17 +162,13 @@ ext2fs_mount(struct mount *mp, const char *path, void *data, struct nameidata *ndp, struct proc *p) { struct vnode *devvp; - struct ufs_args args; + struct ufs_args *args = data; struct ufsmount *ump = NULL; struct m_ext2fs *fs; char fname[MNAMELEN]; char fspec[MNAMELEN]; int error, flags; - error = copyin(data, &args, sizeof(struct ufs_args)); - if (error) - return (error); - /* * If updating, check whether changing from read-only to * read/write; if there is no device name, that's all we do. @@ -208,19 +204,21 @@ ext2fs_mount(struct mount *mp, const char *path, void *data, fs->e2fs.e2fs_state = E2FS_ERRORS; fs->e2fs_fmod = 1; } - if (args.fspec == NULL) { + if (args && args->fspec == NULL) { /* * Process export requests. */ return (vfs_export(mp, &ump->um_export, - &args.export_info)); + &args->export_info)); } + if (args == NULL) + goto success; } /* * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. */ - error = copyinstr(args.fspec, fspec, sizeof(fspec), NULL); + error = copyinstr(args->fspec, fspec, sizeof(fspec), NULL); if (error) goto error; @@ -265,7 +263,7 @@ ext2fs_mount(struct mount *mp, const char *path, void *data, strlcpy(mp->mnt_stat.f_mntfromname, fname, MNAMELEN); memset(mp->mnt_stat.f_mntfromspec, 0, MNAMELEN); strlcpy(mp->mnt_stat.f_mntfromspec, fspec, MNAMELEN); - memcpy(&mp->mnt_stat.mount_info.ufs_args, &args, sizeof(args)); + memcpy(&mp->mnt_stat.mount_info.ufs_args, args, sizeof(*args)); if (fs->e2fs_fmod != 0) { /* XXX */ fs->e2fs_fmod = 0; -- cgit v1.2.3