swap_pager.c (163622) | swap_pager.c (164033) |
---|---|
1/*- 2 * Copyright (c) 1998 Matthew Dillon, 3 * Copyright (c) 1994 John S. Dyson 4 * Copyright (c) 1990 University of Utah. 5 * Copyright (c) 1982, 1986, 1989, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by --- 53 unchanged lines hidden (view full) --- 62 * 63 * from: Utah $Hdr: swap_pager.c 1.4 91/04/30$ 64 * 65 * @(#)swap_pager.c 8.9 (Berkeley) 3/21/94 66 * @(#)vm_swap.c 8.5 (Berkeley) 2/17/94 67 */ 68 69#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1998 Matthew Dillon, 3 * Copyright (c) 1994 John S. Dyson 4 * Copyright (c) 1990 University of Utah. 5 * Copyright (c) 1982, 1986, 1989, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by --- 53 unchanged lines hidden (view full) --- 62 * 63 * from: Utah $Hdr: swap_pager.c 1.4 91/04/30$ 64 * 65 * @(#)swap_pager.c 8.9 (Berkeley) 3/21/94 66 * @(#)vm_swap.c 8.5 (Berkeley) 2/17/94 67 */ 68 69#include <sys/cdefs.h> |
70__FBSDID("$FreeBSD: head/sys/vm/swap_pager.c 163622 2006-10-23 05:27:31Z alc $"); | 70__FBSDID("$FreeBSD: head/sys/vm/swap_pager.c 164033 2006-11-06 13:42:10Z rwatson $"); |
71 72#include "opt_mac.h" 73#include "opt_swap.h" 74#include "opt_vm.h" 75 76#include <sys/param.h> 77#include <sys/systm.h> 78#include <sys/conf.h> 79#include <sys/kernel.h> | 71 72#include "opt_mac.h" 73#include "opt_swap.h" 74#include "opt_vm.h" 75 76#include <sys/param.h> 77#include <sys/systm.h> 78#include <sys/conf.h> 79#include <sys/kernel.h> |
80#include <sys/priv.h> |
|
80#include <sys/proc.h> 81#include <sys/bio.h> 82#include <sys/buf.h> 83#include <sys/disk.h> 84#include <sys/fcntl.h> 85#include <sys/mount.h> 86#include <sys/namei.h> 87#include <sys/vnode.h> --- 1873 unchanged lines hidden (view full) --- 1961int 1962swapon(struct thread *td, struct swapon_args *uap) 1963{ 1964 struct vattr attr; 1965 struct vnode *vp; 1966 struct nameidata nd; 1967 int error; 1968 | 81#include <sys/proc.h> 82#include <sys/bio.h> 83#include <sys/buf.h> 84#include <sys/disk.h> 85#include <sys/fcntl.h> 86#include <sys/mount.h> 87#include <sys/namei.h> 88#include <sys/vnode.h> --- 1873 unchanged lines hidden (view full) --- 1962int 1963swapon(struct thread *td, struct swapon_args *uap) 1964{ 1965 struct vattr attr; 1966 struct vnode *vp; 1967 struct nameidata nd; 1968 int error; 1969 |
1969 mtx_lock(&Giant); 1970 error = suser(td); | 1970 error = priv_check(td, PRIV_SWAPON); |
1971 if (error) | 1971 if (error) |
1972 goto done2; | 1972 return (error); |
1973 | 1973 |
1974 mtx_lock(&Giant); |
|
1974 while (swdev_syscall_active) 1975 tsleep(&swdev_syscall_active, PUSER - 1, "swpon", 0); 1976 swdev_syscall_active = 1; 1977 1978 /* 1979 * Swap metadata may not fit in the KVM if we have physical 1980 * memory of >1GB. 1981 */ --- 22 unchanged lines hidden (view full) --- 2004 error = swaponvp(td, vp, attr.va_size / DEV_BSIZE); 2005 } 2006 2007 if (error) 2008 vrele(vp); 2009done: 2010 swdev_syscall_active = 0; 2011 wakeup_one(&swdev_syscall_active); | 1975 while (swdev_syscall_active) 1976 tsleep(&swdev_syscall_active, PUSER - 1, "swpon", 0); 1977 swdev_syscall_active = 1; 1978 1979 /* 1980 * Swap metadata may not fit in the KVM if we have physical 1981 * memory of >1GB. 1982 */ --- 22 unchanged lines hidden (view full) --- 2005 error = swaponvp(td, vp, attr.va_size / DEV_BSIZE); 2006 } 2007 2008 if (error) 2009 vrele(vp); 2010done: 2011 swdev_syscall_active = 0; 2012 wakeup_one(&swdev_syscall_active); |
2012done2: | |
2013 mtx_unlock(&Giant); 2014 return (error); 2015} 2016 2017static void 2018swaponsomething(struct vnode *vp, void *id, u_long nblks, sw_strategy_t *strategy, sw_close_t *close, dev_t dev) 2019{ 2020 struct swdevt *sp, *tsp; --- 79 unchanged lines hidden (view full) --- 2100int 2101swapoff(struct thread *td, struct swapoff_args *uap) 2102{ 2103 struct vnode *vp; 2104 struct nameidata nd; 2105 struct swdevt *sp; 2106 int error; 2107 | 2013 mtx_unlock(&Giant); 2014 return (error); 2015} 2016 2017static void 2018swaponsomething(struct vnode *vp, void *id, u_long nblks, sw_strategy_t *strategy, sw_close_t *close, dev_t dev) 2019{ 2020 struct swdevt *sp, *tsp; --- 79 unchanged lines hidden (view full) --- 2100int 2101swapoff(struct thread *td, struct swapoff_args *uap) 2102{ 2103 struct vnode *vp; 2104 struct nameidata nd; 2105 struct swdevt *sp; 2106 int error; 2107 |
2108 error = suser(td); | 2108 error = priv_check(td, PRIV_SWAPOFF); |
2109 if (error) 2110 return (error); 2111 2112 mtx_lock(&Giant); 2113 while (swdev_syscall_active) 2114 tsleep(&swdev_syscall_active, PUSER - 1, "swpoff", 0); 2115 swdev_syscall_active = 1; 2116 --- 458 unchanged lines hidden --- | 2109 if (error) 2110 return (error); 2111 2112 mtx_lock(&Giant); 2113 while (swdev_syscall_active) 2114 tsleep(&swdev_syscall_active, PUSER - 1, "swpoff", 0); 2115 swdev_syscall_active = 1; 2116 --- 458 unchanged lines hidden --- |