View | Details | Raw Unified | Return to bug 223831 | Differences between
and this patch

Collapse All | Expand All

(-)sys/vm/swap_pager.c (-30 / +56 lines)
Lines 1621-1657 Link Here
1621
 *	We also attempt to swap in all other pages in the swap block.
1768
 *	We also attempt to swap in all other pages in the swap block.
1622
 *	However, we only guarantee that the one at the specified index is
1769
 *	However, we only guarantee that the one at the specified index is
1623
 *	paged in.
1770
 *	paged in.
1624
 *
1625
 *	XXX - The code to page the whole block in doesn't work, so we
1626
 *	      revert to the one-by-one behavior for now.  Sigh.
1627
 */
1771
 */
1628
static inline void
1772
static int
1629
swp_pager_force_pagein(vm_object_t object, vm_pindex_t pindex)
1773
swp_pager_force_pagein(vm_object_t object, vm_pindex_t pindex)
1630
{
1774
{
1631
	vm_page_t m;
1775
	vm_page_t m[SWB_NPAGES];
1776
	int count, i, j, npages, rv;
1632
1777
1633
	vm_object_pip_add(object, 1);
1778
	rv = swap_pager_haspage(object, pindex, NULL, &npages);
1634
	m = vm_page_grab(object, pindex, VM_ALLOC_NORMAL);
1779
	KASSERT(rv == 1, ("%s: missing page %p", __func__, m));
1635
	if (m->valid == VM_PAGE_BITS_ALL) {
1780
	npages += 1;
1636
		vm_object_pip_wakeup(object);
1781
	i = vm_page_grab_pages(object, pindex, VM_ALLOC_NORMAL, m, npages);
1637
		vm_page_dirty(m);
1782
	vm_object_pip_add(object, npages);
1638
		vm_page_lock(m);
1783
1639
		vm_page_activate(m);
1784
	for (i = 0; i < npages;) {
1640
		vm_page_unlock(m);
1785
		if (m[i]->valid == VM_PAGE_BITS_ALL) {
1641
		vm_page_xunbusy(m);
1786
			vm_object_pip_wakeup(object);
1642
		vm_pager_page_unswapped(m);
1787
			vm_page_dirty(m[i]);
1643
		return;
1788
			vm_page_lock(m[i]);
1789
			vm_page_activate(m[i]);
1790
			vm_page_unlock(m[i]);
1791
			vm_page_xunbusy(m[i]);
1792
			vm_pager_page_unswapped(m[i]);
1793
			i++;
1794
			continue;
1795
		}
1796
1797
		for (j = i + 1; j < npages; j++)
1798
			if (m[j]->valid == VM_PAGE_BITS_ALL)
1799
				break;
1800
1801
		count = j - i;
1802
		if (swap_pager_getpages(object, &m[i], count, NULL, NULL) != VM_PAGER_OK)
1803
			panic("swap_pager_force_pagein: read from swap failed");/*XXX*/
1804
		for (; i < j; i++) {
1805
			vm_object_pip_wakeup(object);
1806
			vm_page_dirty(m[i]);
1807
			vm_page_lock(m[i]);
1808
			vm_page_launder(m[i]);
1809
			vm_page_unlock(m[i]);
1810
			vm_page_xunbusy(m[i]);
1811
			vm_pager_page_unswapped(m[i]);
1812
		}
1644
	}
1813
	}
1645
1814
	return npages;
1646
	if (swap_pager_getpages(object, &m, 1, NULL, NULL) != VM_PAGER_OK)
1647
		panic("swap_pager_force_pagein: read from swap failed");/*XXX*/
1648
	vm_object_pip_wakeup(object);
1649
	vm_page_dirty(m);
1650
	vm_page_lock(m);
1651
	vm_page_launder(m);
1652
	vm_page_unlock(m);
1653
	vm_page_xunbusy(m);
1654
	vm_pager_page_unswapped(m);
1655
}
1815
}
1656
1816
1657
/*
1817
/*
Lines 1670-1676 Link Here
1670
	struct swblk *sb;
1832
	struct swblk *sb;
1671
	vm_object_t object;
1833
	vm_object_t object;
1672
	vm_pindex_t pi;
1834
	vm_pindex_t pi;
1673
	int i, retries;
1835
	int i, freedpages, offset, retries;
1674
1836
1675
	sx_assert(&swdev_syscall_lock, SA_XLOCKED);
1837
	sx_assert(&swdev_syscall_lock, SA_XLOCKED);
1676
1838
Lines 1700-1714 Link Here
1700
		if (object->type != OBJT_SWAP)
1862
		if (object->type != OBJT_SWAP)
1701
			goto next_obj;
1863
			goto next_obj;
1702
1864
1865
		freedpages = 0;
1703
		for (pi = 0; (sb = SWAP_PCTRIE_LOOKUP_GE(
1866
		for (pi = 0; (sb = SWAP_PCTRIE_LOOKUP_GE(
1704
		    &object->un_pager.swp.swp_blks, pi)) != NULL; ) {
1867
		    &object->un_pager.swp.swp_blks, pi)) != NULL; ) {
1705
			pi = sb->p + SWAP_META_PAGES;
1868
			pi = sb->p + SWAP_META_PAGES;
1706
			for (i = 0; i < SWAP_META_PAGES; i++) {
1869
			if (freedpages > SWAP_META_PAGES) {
1870
				freedpages -= SWAP_META_PAGES;
1871
				continue;
1872
			} else if (offset > 0) {
1873
				i = freedpages;
1874
				freedpages = 0;
1875
			} else
1876
				i = 0;
1877
			for (; i < SWAP_META_PAGES; i++) {
1707
				if (sb->d[i] == SWAPBLK_NONE)
1878
				if (sb->d[i] == SWAPBLK_NONE)
1708
					continue;
1879
					continue;
1709
				if (swp_pager_isondev(sb->d[i], sp))
1880
				if (swp_pager_isondev(sb->d[i], sp)) {
1710
					swp_pager_force_pagein(object,
1881
					freedpages = swp_pager_force_pagein(object,
1711
					    sb->p + i);
1882
					    sb->p + i);
1883
					offset = min(freedpages, SWAP_META_PAGES - i);
1884
					freedpages -= offset;
1885
					i += ( offset - 1 );
1886
				}
1712
			}
1887
			}
1713
		}
1888
		}
1714
next_obj:
1889
next_obj:

Return to bug 223831