summaryrefslogtreecommitdiffstats
path: root/sys/tmpfs/tmpfs_vfsops.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2017-12-11 05:27:40 +0000
committerderaadt <deraadt@openbsd.org>2017-12-11 05:27:40 +0000
commit7efda1a11d8bf31499aa02da4d14eddf1b5293ae (patch)
tree77661cbfae0631d2f5a2086c7baae6f06a9af989 /sys/tmpfs/tmpfs_vfsops.c
parentSergey Bronnikov's code coverage analysis shows that a few more code paths (diff)
downloadwireguard-openbsd-7efda1a11d8bf31499aa02da4d14eddf1b5293ae.tar.xz
wireguard-openbsd-7efda1a11d8bf31499aa02da4d14eddf1b5293ae.zip
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
Diffstat (limited to 'sys/tmpfs/tmpfs_vfsops.c')
-rw-r--r--sys/tmpfs/tmpfs_vfsops.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/sys/tmpfs/tmpfs_vfsops.c b/sys/tmpfs/tmpfs_vfsops.c
index 9a17e74ae63..28b757230a0 100644
--- a/sys/tmpfs/tmpfs_vfsops.c
+++ b/sys/tmpfs/tmpfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmpfs_vfsops.c,v 1.13 2017/09/08 05:36:53 deraadt Exp $ */
+/* $OpenBSD: tmpfs_vfsops.c,v 1.14 2017/12/11 05:27:40 deraadt Exp $ */
/* $NetBSD: tmpfs_vfsops.c,v 1.52 2011/09/27 01:10:43 christos Exp $ */
/*
@@ -84,7 +84,7 @@ int
tmpfs_mount(struct mount *mp, const char *path, void *data,
struct nameidata *ndp, struct proc *p)
{
- struct tmpfs_args args;
+ struct tmpfs_args *args = data;
tmpfs_mount_t *tmp;
tmpfs_node_t *root;
uint64_t memlimit;
@@ -121,25 +121,25 @@ tmpfs_mount(struct mount *mp, const char *path, void *data,
if (tmpfs_mem_info(1) < TMPFS_PAGES_RESERVED)
return EINVAL;
- error = copyin(data, &args, sizeof(struct tmpfs_args));
+ error = copyin(data, args, sizeof(struct tmpfs_args));
if (error)
return error;
- if (args.ta_root_uid == VNOVAL || args.ta_root_gid == VNOVAL ||
- args.ta_root_mode == VNOVAL)
+ if (args->ta_root_uid == VNOVAL || args->ta_root_gid == VNOVAL ||
+ args->ta_root_mode == VNOVAL)
return EINVAL;
/* Get the memory usage limit for this file-system. */
- if (args.ta_size_max < PAGE_SIZE) {
+ if (args->ta_size_max < PAGE_SIZE) {
memlimit = UINT64_MAX;
} else {
- memlimit = args.ta_size_max;
+ memlimit = args->ta_size_max;
}
KASSERT(memlimit > 0);
- if (args.ta_nodes_max <= 3) {
+ if (args->ta_nodes_max <= 3) {
nodes = 3 + (memlimit / 1024);
} else {
- nodes = args.ta_nodes_max;
+ nodes = args->ta_nodes_max;
}
nodes = MIN(nodes, INT_MAX);
KASSERT(nodes >= 3);
@@ -156,8 +156,8 @@ tmpfs_mount(struct mount *mp, const char *path, void *data,
tmpfs_mntmem_init(tmp, memlimit);
/* Allocate the root node. */
- error = tmpfs_alloc_node(tmp, VDIR, args.ta_root_uid,
- args.ta_root_gid, args.ta_root_mode & ALLPERMS, NULL,
+ error = tmpfs_alloc_node(tmp, VDIR, args->ta_root_uid,
+ args->ta_root_gid, args->ta_root_mode & ALLPERMS, NULL,
VNOVAL, &root);
KASSERT(error == 0 && root != NULL);
@@ -180,7 +180,7 @@ tmpfs_mount(struct mount *mp, const char *path, void *data,
#endif
vfs_getnewfsid(mp);
- mp->mnt_stat.mount_info.tmpfs_args = args;
+ mp->mnt_stat.mount_info.tmpfs_args = *args;
bzero(&mp->mnt_stat.f_mntonname, sizeof(mp->mnt_stat.f_mntonname));
bzero(&mp->mnt_stat.f_mntfromname, sizeof(mp->mnt_stat.f_mntfromname));