|
Link Here
|
| 113 |
static int nsw_cluster_max; /* maximum VOP I/O allowed */ |
113 |
static int nsw_cluster_max; /* maximum VOP I/O allowed */ |
| 114 |
|
114 |
|
| 115 |
struct blist *swapblist; |
115 |
struct blist *swapblist; |
|
|
116 |
|
| 117 |
static struct mtx swhash_mtx; /* protect hash table */ |
| 116 |
static struct swblock **swhash; |
118 |
static struct swblock **swhash; |
| 117 |
static int swhash_mask; |
119 |
static int swhash_mask; |
|
|
120 |
|
| 118 |
static int swap_async_max = 4; /* maximum in-progress async I/O's */ |
121 |
static int swap_async_max = 4; /* maximum in-progress async I/O's */ |
| 119 |
static struct sx sw_alloc_sx; |
122 |
static struct sx sw_alloc_sx; |
| 120 |
|
123 |
|
|
Link Here
|
| 256 |
*/ |
259 |
*/ |
| 257 |
dmmax = SWB_NPAGES * 2; |
260 |
dmmax = SWB_NPAGES * 2; |
| 258 |
dmmax_mask = ~(dmmax - 1); |
261 |
dmmax_mask = ~(dmmax - 1); |
|
|
262 |
|
| 263 |
mtx_init(&swhash_mtx, "swap_pager swhash mutex", NULL, MTX_DEF); |
| 259 |
} |
264 |
} |
| 260 |
|
265 |
|
| 261 |
/* |
266 |
/* |
|
Link Here
|
| 1752 |
|
1757 |
|
| 1753 |
full_rescan: |
1758 |
full_rescan: |
| 1754 |
waitobj = NULL; |
1759 |
waitobj = NULL; |
|
|
1760 |
mtx_lock(&swhash_mtx); |
| 1755 |
for (i = 0; i <= swhash_mask; i++) { /* '<=' is correct here */ |
1761 |
for (i = 0; i <= swhash_mask; i++) { /* '<=' is correct here */ |
| 1756 |
restart: |
1762 |
restart: |
| 1757 |
pswap = &swhash[i]; |
1763 |
pswap = &swhash[i]; |
|
Link Here
|
| 1763 |
break; |
1769 |
break; |
| 1764 |
} |
1770 |
} |
| 1765 |
if (j < SWAP_META_PAGES) { |
1771 |
if (j < SWAP_META_PAGES) { |
|
|
1772 |
mtx_unlock(&swhash_mtx); |
| 1766 |
swp_pager_force_pagein(swap, j); |
1773 |
swp_pager_force_pagein(swap, j); |
|
|
1774 |
mtx_lock(&swhash_mtx); |
| 1767 |
goto restart; |
1775 |
goto restart; |
| 1768 |
} else if (swap->swb_object->paging_in_progress) { |
1776 |
} else if (swap->swb_object->paging_in_progress) { |
| 1769 |
if (!waitobj) |
1777 |
if (!waitobj) |
|
Link Here
|
| 1772 |
pswap = &swap->swb_hnext; |
1780 |
pswap = &swap->swb_hnext; |
| 1773 |
} |
1781 |
} |
| 1774 |
} |
1782 |
} |
|
|
1783 |
mtx_unlock(&swhash_mtx); |
| 1784 |
|
| 1775 |
if (waitobj && *sw_used) { |
1785 |
if (waitobj && *sw_used) { |
| 1776 |
/* |
1786 |
/* |
| 1777 |
* We wait on an arbitrary object to clock our rescans |
1787 |
* We wait on an arbitrary object to clock our rescans |
|
Link Here
|
| 1782 |
VM_OBJECT_UNLOCK(waitobj); |
1792 |
VM_OBJECT_UNLOCK(waitobj); |
| 1783 |
goto full_rescan; |
1793 |
goto full_rescan; |
| 1784 |
} |
1794 |
} |
|
|
1795 |
|
| 1785 |
if (*sw_used) |
1796 |
if (*sw_used) |
| 1786 |
panic("swapoff: failed to locate %d swap blocks", *sw_used); |
1797 |
panic("swapoff: failed to locate %d swap blocks", *sw_used); |
| 1787 |
} |
1798 |
} |
|
Link Here
|
| 1817 |
struct swblock *swap; |
1828 |
struct swblock *swap; |
| 1818 |
|
1829 |
|
| 1819 |
index &= ~(vm_pindex_t)SWAP_META_MASK; |
1830 |
index &= ~(vm_pindex_t)SWAP_META_MASK; |
|
|
1831 |
|
| 1832 |
mtx_lock(&swhash_mtx); |
| 1820 |
pswap = &swhash[(index ^ (int)(intptr_t)object) & swhash_mask]; |
1833 |
pswap = &swhash[(index ^ (int)(intptr_t)object) & swhash_mask]; |
| 1821 |
while ((swap = *pswap) != NULL) { |
1834 |
while ((swap = *pswap) != NULL) { |
| 1822 |
if (swap->swb_object == object && |
1835 |
if (swap->swb_object == object && |
|
Link Here
|
| 1826 |
} |
1839 |
} |
| 1827 |
pswap = &swap->swb_hnext; |
1840 |
pswap = &swap->swb_hnext; |
| 1828 |
} |
1841 |
} |
|
|
1842 |
mtx_unlock(&swhash_mtx); |
| 1843 |
|
| 1829 |
return (pswap); |
1844 |
return (pswap); |
| 1830 |
} |
1845 |
} |