tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
unconfiguring swap at shutdown
Hello,
The following patch removes swap devices at shutdown. This is useful for
example when typing reboot and having a raidframe partition... Comments?
christos
Index: kern/vfs_subr.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_subr.c,v
retrieving revision 1.355
diff -u -u -r1.355 vfs_subr.c
--- kern/vfs_subr.c 31 Jul 2008 05:38:05 -0000 1.355
+++ kern/vfs_subr.c 28 Aug 2008 15:52:33 -0000
@@ -114,6 +114,7 @@
#include <uvm/uvm.h>
#include <uvm/uvm_readahead.h>
#include <uvm/uvm_ddb.h>
+#include <uvm/uvm_swap.h>
#include <sys/sysctl.h>
@@ -2333,6 +2334,13 @@
if (panicstr != NULL)
return;
+#if defined(_KERNEL) && !defined(_RUMPKERNEL)
+ /*
+ * We need to turn off swap first before we unmount
+ * /dev, because otherwise the spec_vnodes are bad.
+ */
+ uvm_swap_shutdown(l);
+#endif
/* Release inodes held by texts before update. */
#ifdef notdef
vnshutdown();
Index: uvm/uvm_swap.c
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm_swap.c,v
retrieving revision 1.139
diff -u -u -r1.139 uvm_swap.c
--- uvm/uvm_swap.c 29 May 2008 14:51:27 -0000 1.139
+++ uvm/uvm_swap.c 28 Aug 2008 15:52:35 -0000
@@ -1073,6 +1073,55 @@
return (0);
}
+void
+uvm_swap_shutdown(struct lwp *l)
+{
+ struct swapdev *sdp;
+ struct swappri *spp;
+ struct vnode *vp;
+ int error;
+
+ printf("turning of swap...");
+ rw_enter(&swap_syscall_lock, RW_WRITER);
+ mutex_enter(&uvm_swap_data_lock);
+again:
+ LIST_FOREACH(spp, &swap_priority, spi_swappri)
+ CIRCLEQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) {
+ if (sdp->swd_flags & SWF_FAKE)
+ continue;
+ if ((sdp->swd_flags & (SWF_INUSE|SWF_ENABLE)) == 0)
+ continue;
+#ifdef DEBUG
+ printf("\nturning off swap on %s...",
+ sdp->swd_path);
+#endif
+ if (vn_lock(vp = sdp->swd_vp, LK_EXCLUSIVE)) {
+ error = EBUSY;
+ vp = NULL;
+ } else
+ error = 0;
+ if (!error) {
+ error = swap_off(l, sdp);
+ mutex_enter(&uvm_swap_data_lock);
+ }
+ if (error) {
+ printf("stopping swap on %s failed "
+ "with error %d\n", sdp->swd_path, error);
+ CIRCLEQ_REMOVE(&spp->spi_swapdev, sdp,
+ swd_next);
+ uvmexp.nswapdev--;
+ swaplist_trim();
+ if (vp)
+ vput(vp);
+ }
+ goto again;
+ }
+ printf(" done\n");
+ mutex_exit(&uvm_swap_data_lock);
+ rw_exit(&swap_syscall_lock);
+}
+
+
/*
* /dev/drum interface and i/o functions
*/
Index: uvm/uvm_swap.h
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm_swap.h,v
retrieving revision 1.17
diff -u -u -r1.17 uvm_swap.h
--- uvm/uvm_swap.h 29 May 2008 14:51:27 -0000 1.17
+++ uvm/uvm_swap.h 28 Aug 2008 15:52:35 -0000
@@ -39,6 +39,7 @@
#endif
struct swapent;
+struct lwp;
#if defined(VMSWAP)
int uvm_swap_get(struct vm_page *, int, int);
@@ -51,6 +52,7 @@
#define uvm_swapisfull() true
#endif /* defined(VMSWAP) */
void uvm_swap_stats(int, struct swapent *, int, register_t *);
+void uvm_swap_shutdown(struct lwp *);
#endif /* _KERNEL */
Home |
Main Index |
Thread Index |
Old Index