Release all hypervisor-level resources for rump_etfs paths when the rump kernel is halted. Allows a Xen domU to not complain after it was shut down, or something like that. Requested by Martin Lucina.diff -r1.80 -r1.81 src/sys/rump/librump/rumpvfs/rump_vfs.c
(pooka)
--- src/sys/rump/librump/rumpvfs/rump_vfs.c 2014/05/23 10:56:36 1.80
+++ src/sys/rump/librump/rumpvfs/rump_vfs.c 2014/11/17 14:30:31 1.81
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rump_vfs.c,v 1.80 2014/05/23 10:56:36 pooka Exp $ */ | 1 | /* $NetBSD: rump_vfs.c,v 1.81 2014/11/17 14:30:31 pooka Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2008 Antti Kantee. All Rights Reserved. | 4 | * Copyright (c) 2008 Antti Kantee. All Rights Reserved. | |
5 | * | 5 | * | |
6 | * Development of this software was supported by the | 6 | * Development of this software was supported by the | |
7 | * Finnish Cultural Foundation. | 7 | * Finnish Cultural Foundation. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -19,27 +19,27 @@ | @@ -19,27 +19,27 @@ | |||
19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 19 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
21 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 21 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
28 | * SUCH DAMAGE. | 28 | * SUCH DAMAGE. | |
29 | */ | 29 | */ | |
30 | 30 | |||
31 | #include <sys/cdefs.h> | 31 | #include <sys/cdefs.h> | |
32 | __KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.80 2014/05/23 10:56:36 pooka Exp $"); | 32 | __KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.81 2014/11/17 14:30:31 pooka Exp $"); | |
33 | 33 | |||
34 | #include <sys/param.h> | 34 | #include <sys/param.h> | |
35 | #include <sys/buf.h> | 35 | #include <sys/buf.h> | |
36 | #include <sys/conf.h> | 36 | #include <sys/conf.h> | |
37 | #include <sys/evcnt.h> | 37 | #include <sys/evcnt.h> | |
38 | #include <sys/fcntl.h> | 38 | #include <sys/fcntl.h> | |
39 | #include <sys/filedesc.h> | 39 | #include <sys/filedesc.h> | |
40 | #include <sys/fstrans.h> | 40 | #include <sys/fstrans.h> | |
41 | #include <sys/lockf.h> | 41 | #include <sys/lockf.h> | |
42 | #include <sys/kthread.h> | 42 | #include <sys/kthread.h> | |
43 | #include <sys/module.h> | 43 | #include <sys/module.h> | |
44 | #include <sys/namei.h> | 44 | #include <sys/namei.h> | |
45 | #include <sys/queue.h> | 45 | #include <sys/queue.h> | |
@@ -69,26 +69,27 @@ pvfs_init(struct proc *p) | @@ -69,26 +69,27 @@ pvfs_init(struct proc *p) | |||
69 | 69 | |||
70 | static void | 70 | static void | |
71 | pvfs_rele(struct proc *p) | 71 | pvfs_rele(struct proc *p) | |
72 | { | 72 | { | |
73 | 73 | |||
74 | cwdfree(p->p_cwdi); | 74 | cwdfree(p->p_cwdi); | |
75 | } | 75 | } | |
76 | 76 | |||
77 | static void | 77 | static void | |
78 | fini(void) | 78 | fini(void) | |
79 | { | 79 | { | |
80 | 80 | |||
81 | vfs_shutdown(); | 81 | vfs_shutdown(); | |
82 | rumpblk_fini(); | |||
82 | } | 83 | } | |
83 | 84 | |||
84 | static void | 85 | static void | |
85 | drainbufs(int npages) | 86 | drainbufs(int npages) | |
86 | { | 87 | { | |
87 | 88 | |||
88 | mutex_enter(&bufcache_lock); | 89 | mutex_enter(&bufcache_lock); | |
89 | buf_drain(npages); | 90 | buf_drain(npages); | |
90 | mutex_exit(&bufcache_lock); | 91 | mutex_exit(&bufcache_lock); | |
91 | } | 92 | } | |
92 | 93 | |||
93 | RUMP_COMPONENT(RUMP__FACTION_VFS) | 94 | RUMP_COMPONENT(RUMP__FACTION_VFS) | |
94 | { | 95 | { |
--- src/sys/rump/librump/rumpvfs/rump_vfs_private.h 2013/03/07 22:12:34 1.17
+++ src/sys/rump/librump/rumpvfs/rump_vfs_private.h 2014/11/17 14:30:31 1.18
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rump_vfs_private.h,v 1.17 2013/03/07 22:12:34 pooka Exp $ */ | 1 | /* $NetBSD: rump_vfs_private.h,v 1.18 2014/11/17 14:30:31 pooka Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2008 Antti Kantee. All Rights Reserved. | 4 | * Copyright (c) 2008 Antti Kantee. All Rights Reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
@@ -30,26 +30,27 @@ | @@ -30,26 +30,27 @@ | |||
30 | 30 | |||
31 | #include <sys/types.h> | 31 | #include <sys/types.h> | |
32 | #include <sys/conf.h> | 32 | #include <sys/conf.h> | |
33 | 33 | |||
34 | void rumpfs_init(void); | 34 | void rumpfs_init(void); | |
35 | 35 | |||
36 | int rump_devnull_init(void); | 36 | int rump_devnull_init(void); | |
37 | 37 | |||
38 | #define RUMPBLK_DEVMAJOR 197 /* from conf/majors, XXX: not via config yet */ | 38 | #define RUMPBLK_DEVMAJOR 197 /* from conf/majors, XXX: not via config yet */ | |
39 | #define RUMPBLK_SIZENOTSET ((uint64_t)-1) | 39 | #define RUMPBLK_SIZENOTSET ((uint64_t)-1) | |
40 | int rumpblk_register(const char *, devminor_t *, uint64_t, uint64_t); | 40 | int rumpblk_register(const char *, devminor_t *, uint64_t, uint64_t); | |
41 | int rumpblk_deregister(const char *); | 41 | int rumpblk_deregister(const char *); | |
42 | int rumpblk_init(void); | 42 | int rumpblk_init(void); | |
43 | void rumpblk_fini(void); | |||
43 | 44 | |||
44 | void rump_biodone(void *, size_t, int); | 45 | void rump_biodone(void *, size_t, int); | |
45 | 46 | |||
46 | void rump_vfs_builddevs(struct devsw_conv *, size_t numelem); | 47 | void rump_vfs_builddevs(struct devsw_conv *, size_t numelem); | |
47 | 48 | |||
48 | extern int (*rump_vfs_makeonedevnode)(dev_t, const char *, | 49 | extern int (*rump_vfs_makeonedevnode)(dev_t, const char *, | |
49 | devmajor_t, devminor_t); | 50 | devmajor_t, devminor_t); | |
50 | extern int (*rump_vfs_makedevnodes)(dev_t, const char *, char, | 51 | extern int (*rump_vfs_makedevnodes)(dev_t, const char *, char, | |
51 | devmajor_t, devminor_t, int); | 52 | devmajor_t, devminor_t, int); | |
52 | extern void (*rump_vfs_drainbufs)(int); | 53 | extern void (*rump_vfs_drainbufs)(int); | |
53 | extern void (*rump_vfs_fini)(void); | 54 | extern void (*rump_vfs_fini)(void); | |
54 | 55 | |||
55 | #include <sys/mount.h> | 56 | #include <sys/mount.h> |
--- src/sys/rump/librump/rumpvfs/rumpblk.c 2014/07/25 08:10:40 1.57
+++ src/sys/rump/librump/rumpvfs/rumpblk.c 2014/11/17 14:30:31 1.58
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rumpblk.c,v 1.57 2014/07/25 08:10:40 dholland Exp $ */ | 1 | /* $NetBSD: rumpblk.c,v 1.58 2014/11/17 14:30:31 pooka Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2009 Antti Kantee. All Rights Reserved. | 4 | * Copyright (c) 2009 Antti Kantee. All Rights Reserved. | |
5 | * | 5 | * | |
6 | * Development of this software was supported by the | 6 | * Development of this software was supported by the | |
7 | * Finnish Cultural Foundation. | 7 | * Finnish Cultural Foundation. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -27,27 +27,27 @@ | @@ -27,27 +27,27 @@ | |||
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
28 | * SUCH DAMAGE. | 28 | * SUCH DAMAGE. | |
29 | */ | 29 | */ | |
30 | 30 | |||
31 | /* | 31 | /* | |
32 | * Block device emulation. Presents a block device interface and | 32 | * Block device emulation. Presents a block device interface and | |
33 | * uses rumpuser system calls to satisfy I/O requests. | 33 | * uses rumpuser system calls to satisfy I/O requests. | |
34 | * | 34 | * | |
35 | * We provide fault injection. The driver can be made to fail | 35 | * We provide fault injection. The driver can be made to fail | |
36 | * I/O occasionally. | 36 | * I/O occasionally. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include <sys/cdefs.h> | 39 | #include <sys/cdefs.h> | |
40 | __KERNEL_RCSID(0, "$NetBSD: rumpblk.c,v 1.57 2014/07/25 08:10:40 dholland Exp $"); | 40 | __KERNEL_RCSID(0, "$NetBSD: rumpblk.c,v 1.58 2014/11/17 14:30:31 pooka Exp $"); | |
41 | 41 | |||
42 | #include <sys/param.h> | 42 | #include <sys/param.h> | |
43 | #include <sys/buf.h> | 43 | #include <sys/buf.h> | |
44 | #include <sys/conf.h> | 44 | #include <sys/conf.h> | |
45 | #include <sys/condvar.h> | 45 | #include <sys/condvar.h> | |
46 | #include <sys/disklabel.h> | 46 | #include <sys/disklabel.h> | |
47 | #include <sys/evcnt.h> | 47 | #include <sys/evcnt.h> | |
48 | #include <sys/fcntl.h> | 48 | #include <sys/fcntl.h> | |
49 | #include <sys/kmem.h> | 49 | #include <sys/kmem.h> | |
50 | #include <sys/malloc.h> | 50 | #include <sys/malloc.h> | |
51 | #include <sys/queue.h> | 51 | #include <sys/queue.h> | |
52 | #include <sys/stat.h> | 52 | #include <sys/stat.h> | |
53 | #include <sys/cprng.h> | 53 | #include <sys/cprng.h> | |
@@ -331,26 +331,45 @@ rumpblk_deregister(const char *path) | @@ -331,26 +331,45 @@ rumpblk_deregister(const char *path) | |||
331 | if (i == RUMPBLK_SIZE) | 331 | if (i == RUMPBLK_SIZE) | |
332 | return ENOENT; | 332 | return ENOENT; | |
333 | 333 | |||
334 | rblk = &minors[i]; | 334 | rblk = &minors[i]; | |
335 | backend_close(rblk); | 335 | backend_close(rblk); | |
336 | 336 | |||
337 | free(rblk->rblk_path, M_TEMP); | 337 | free(rblk->rblk_path, M_TEMP); | |
338 | memset(&rblk->rblk_label, 0, sizeof(rblk->rblk_label)); | 338 | memset(&rblk->rblk_label, 0, sizeof(rblk->rblk_label)); | |
339 | rblk->rblk_path = NULL; | 339 | rblk->rblk_path = NULL; | |
340 | 340 | |||
341 | return 0; | 341 | return 0; | |
342 | } | 342 | } | |
343 | 343 | |||
344 | /* | |||
345 | * Release all backend resources, to be called only when the rump | |||
346 | * kernel is being shut down. | |||
347 | * This routine does not do a full "fini" since we're going down anyway. | |||
348 | */ | |||
349 | void | |||
350 | rumpblk_fini(void) | |||
351 | { | |||
352 | int i; | |||
353 | ||||
354 | for (i = 0; i < RUMPBLK_SIZE; i++) { | |||
355 | struct rblkdev *rblk; | |||
356 | ||||
357 | rblk = &minors[i]; | |||
358 | if (rblk->rblk_fd != -1) | |||
359 | backend_close(rblk); | |||
360 | } | |||
361 | } | |||
362 | ||||
344 | static int | 363 | static int | |
345 | backend_open(struct rblkdev *rblk, const char *path) | 364 | backend_open(struct rblkdev *rblk, const char *path) | |
346 | { | 365 | { | |
347 | int error, fd; | 366 | int error, fd; | |
348 | 367 | |||
349 | KASSERT(rblk->rblk_fd == -1); | 368 | KASSERT(rblk->rblk_fd == -1); | |
350 | error = rumpuser_open(path, | 369 | error = rumpuser_open(path, | |
351 | RUMPUSER_OPEN_RDWR | RUMPUSER_OPEN_BIO, &fd); | 370 | RUMPUSER_OPEN_RDWR | RUMPUSER_OPEN_BIO, &fd); | |
352 | if (error) { | 371 | if (error) { | |
353 | error = rumpuser_open(path, | 372 | error = rumpuser_open(path, | |
354 | RUMPUSER_OPEN_RDONLY | RUMPUSER_OPEN_BIO, &fd); | 373 | RUMPUSER_OPEN_RDONLY | RUMPUSER_OPEN_BIO, &fd); | |
355 | if (error) | 374 | if (error) | |
356 | return error; | 375 | return error; |