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 130585 2004-06-16 09:47:26Z phk $");
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>
--- 70 unchanged lines hidden (view full) ---
149
150/*
151 * Swap device table
152 */
153struct swdevt {
154 int sw_flags;
155 int sw_nblks;
156 int sw_used;
157 udev_t sw_udev;
158 struct vnode *sw_vp;
159 void *sw_id;
160 swblk_t sw_first;
161 swblk_t sw_end;
162 struct blist *sw_blist;
163 TAILQ_ENTRY(swdevt) sw_list;
164 sw_strategy_t *sw_strategy;
165 sw_close_t *sw_close;
--- 1908 unchanged lines hidden (view full) ---
2074 swdev_syscall_active = 0;
2075 wakeup_one(&swdev_syscall_active);
2076done2:
2077 mtx_unlock(&Giant);
2078 return (error);
2079}
2080
2081static void
2082swaponsomething(struct vnode *vp, void *id, u_long nblks, sw_strategy_t *strategy, sw_close_t *close, udev_t udev)
2083{
2084 struct swdevt *sp, *tsp;
2085 swblk_t dvbase;
2086 u_long mblocks;
2087
2088 /*
2089 * If we go beyond this, we get overflows in the radix
2090 * tree bitmap code.
--- 11 unchanged lines hidden (view full) ---
2102 * sw->sw_nblks is in page-sized chunks now too.
2103 */
2104 nblks &= ~(ctodb(1) - 1);
2105 nblks = dbtoc(nblks);
2106
2107 sp = malloc(sizeof *sp, M_VMPGDATA, M_WAITOK | M_ZERO);
2108 sp->sw_vp = vp;
2109 sp->sw_id = id;
2110 sp->sw_udev = udev;
2111 sp->sw_flags = 0;
2112 sp->sw_nblks = nblks;
2113 sp->sw_used = 0;
2114 sp->sw_strategy = strategy;
2115 sp->sw_close = close;
2116
2117 sp->sw_blist = blist_create(nblks);
2118 /*
--- 169 unchanged lines hidden (view full) ---
2288 return (EINVAL);
2289
2290 n = 0;
2291 mtx_lock(&sw_dev_mtx);
2292 TAILQ_FOREACH(sp, &swtailq, sw_list) {
2293 if (n == *name) {
2294 mtx_unlock(&sw_dev_mtx);
2295 xs.xsw_version = XSWDEV_VERSION;
2296 xs.xsw_dev = sp->sw_udev;
2297 xs.xsw_flags = sp->sw_flags;
2298 xs.xsw_nblks = sp->sw_nblks;
2299 xs.xsw_used = sp->sw_used;
2300
2301 error = SYSCTL_OUT(req, &xs, sizeof(xs));
2302 return (error);
2303 }
2304 n++;
--- 223 unchanged lines hidden (view full) ---
2528 */
2529
2530static void
2531swapdev_strategy(struct buf *bp, struct swdevt *sp)
2532{
2533 int s;
2534 struct vnode *vp, *vp2;
2535
2536 bp->b_dev = NODEV;
2537 bp->b_blkno = ctodb(bp->b_blkno - sp->sw_first);
2538
2539 vp2 = sp->sw_id;
2540 vhold(vp2);
2541 s = splvm();
2542 if (bp->b_iocmd == BIO_WRITE) {
2543 vp = bp->b_vp;
2544 if (vp) {
--- 48 unchanged lines hidden (view full) ---
2593 if (error == 0)
2594#endif
2595 error = VOP_OPEN(vp, FREAD | FWRITE, td->td_ucred, td, -1);
2596 (void) VOP_UNLOCK(vp, 0, td);
2597 if (error)
2598 return (error);
2599
2600 swaponsomething(vp, vp, nblks, swapdev_strategy, swapdev_close,
2601 NOUDEV);
2602 return (0);
2603}
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 130585 2004-06-16 09:47:26Z phk $");
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>
--- 70 unchanged lines hidden (view full) ---
149
150/*
151 * Swap device table
152 */
153struct swdevt {
154 int sw_flags;
155 int sw_nblks;
156 int sw_used;
157 udev_t sw_udev;
158 struct vnode *sw_vp;
159 void *sw_id;
160 swblk_t sw_first;
161 swblk_t sw_end;
162 struct blist *sw_blist;
163 TAILQ_ENTRY(swdevt) sw_list;
164 sw_strategy_t *sw_strategy;
165 sw_close_t *sw_close;
--- 1908 unchanged lines hidden (view full) ---
2074 swdev_syscall_active = 0;
2075 wakeup_one(&swdev_syscall_active);
2076done2:
2077 mtx_unlock(&Giant);
2078 return (error);
2079}
2080
2081static void
2082swaponsomething(struct vnode *vp, void *id, u_long nblks, sw_strategy_t *strategy, sw_close_t *close, udev_t udev)
2083{
2084 struct swdevt *sp, *tsp;
2085 swblk_t dvbase;
2086 u_long mblocks;
2087
2088 /*
2089 * If we go beyond this, we get overflows in the radix
2090 * tree bitmap code.
--- 11 unchanged lines hidden (view full) ---
2102 * sw->sw_nblks is in page-sized chunks now too.
2103 */
2104 nblks &= ~(ctodb(1) - 1);
2105 nblks = dbtoc(nblks);
2106
2107 sp = malloc(sizeof *sp, M_VMPGDATA, M_WAITOK | M_ZERO);
2108 sp->sw_vp = vp;
2109 sp->sw_id = id;
2110 sp->sw_udev = udev;
2111 sp->sw_flags = 0;
2112 sp->sw_nblks = nblks;
2113 sp->sw_used = 0;
2114 sp->sw_strategy = strategy;
2115 sp->sw_close = close;
2116
2117 sp->sw_blist = blist_create(nblks);
2118 /*
--- 169 unchanged lines hidden (view full) ---
2288 return (EINVAL);
2289
2290 n = 0;
2291 mtx_lock(&sw_dev_mtx);
2292 TAILQ_FOREACH(sp, &swtailq, sw_list) {
2293 if (n == *name) {
2294 mtx_unlock(&sw_dev_mtx);
2295 xs.xsw_version = XSWDEV_VERSION;
2296 xs.xsw_dev = sp->sw_udev;
2297 xs.xsw_flags = sp->sw_flags;
2298 xs.xsw_nblks = sp->sw_nblks;
2299 xs.xsw_used = sp->sw_used;
2300
2301 error = SYSCTL_OUT(req, &xs, sizeof(xs));
2302 return (error);
2303 }
2304 n++;
--- 223 unchanged lines hidden (view full) ---
2528 */
2529
2530static void
2531swapdev_strategy(struct buf *bp, struct swdevt *sp)
2532{
2533 int s;
2534 struct vnode *vp, *vp2;
2535
2536 bp->b_dev = NODEV;
2537 bp->b_blkno = ctodb(bp->b_blkno - sp->sw_first);
2538
2539 vp2 = sp->sw_id;
2540 vhold(vp2);
2541 s = splvm();
2542 if (bp->b_iocmd == BIO_WRITE) {
2543 vp = bp->b_vp;
2544 if (vp) {
--- 48 unchanged lines hidden (view full) ---
2593 if (error == 0)
2594#endif
2595 error = VOP_OPEN(vp, FREAD | FWRITE, td->td_ucred, td, -1);
2596 (void) VOP_UNLOCK(vp, 0, td);
2597 if (error)
2598 return (error);
2599
2600 swaponsomething(vp, vp, nblks, swapdev_strategy, swapdev_close,
2601 NOUDEV);
2602 return (0);
2603}