summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2003-10-30 09:12:43 +0000
committeralc <alc@FreeBSD.org>2003-10-30 09:12:43 +0000
commitbbdba26328b9b5d6bc1b53351610790f6dc448c6 (patch)
tree9f207b016cb67792978bdf7a258767b9f3a37743
parentf2e7bd69b88aa2eb4434410b9dc5c7d364505ee1 (diff)
downloadFreeBSD-src-bbdba26328b9b5d6bc1b53351610790f6dc448c6.zip
FreeBSD-src-bbdba26328b9b5d6bc1b53351610790f6dc448c6.tar.gz
- Synchronize access to the swdevt's sw_blist with sw_dev_mtx.
- Remove several instances of GIANT_REQUIRED.
-rw-r--r--sys/vm/swap_pager.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index 73cddff..e03321e 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -298,7 +298,6 @@ static daddr_t swp_pager_meta_ctl(vm_object_t, vm_pindex_t, int);
static void
swp_sizecheck(void)
{
- GIANT_REQUIRED;
if (swap_pager_avail < nswap_lowat) {
if (swap_pager_almost_full == 0) {
@@ -585,8 +584,6 @@ swp_pager_getswapspace(int npages)
struct swdevt *sp;
int i;
- GIANT_REQUIRED;
-
blk = SWAPBLK_NONE;
mtx_lock(&sw_dev_mtx);
sp = swdevhd;
@@ -668,23 +665,26 @@ swp_pager_freeswapspace(daddr_t blk, int npages)
{
struct swdevt *sp;
- GIANT_REQUIRED;
-
- sp = swp_pager_find_dev(blk);
-
- /* per-swap area stats */
- sp->sw_used -= npages;
-
- /*
- * If we are attempting to stop swapping on this device, we
- * don't want to mark any blocks free lest they be reused.
- */
- if (sp->sw_flags & SW_CLOSING)
- return;
-
- blist_free(sp->sw_blist, blk - sp->sw_first, npages);
- swap_pager_avail += npages;
- swp_sizecheck();
+ mtx_lock(&sw_dev_mtx);
+ TAILQ_FOREACH(sp, &swtailq, sw_list) {
+ if (blk >= sp->sw_first && blk < sp->sw_end) {
+ sp->sw_used -= npages;
+ /*
+ * If we are attempting to stop swapping on
+ * this device, we don't want to mark any
+ * blocks free lest they be reused.
+ */
+ if ((sp->sw_flags & SW_CLOSING) == 0) {
+ blist_free(sp->sw_blist, blk - sp->sw_first,
+ npages);
+ swap_pager_avail += npages;
+ swp_sizecheck();
+ }
+ mtx_unlock(&sw_dev_mtx);
+ return;
+ }
+ }
+ panic("Swapdev not found");
}
/*
OpenPOWER on IntegriCloud