Whitespace cleanup.
This commit is contained in:
parent
3a59a28395
commit
71dbd73468
@ -50,7 +50,7 @@
|
|||||||
*
|
*
|
||||||
* - on the fly reallocation of swap during putpages. The new system
|
* - on the fly reallocation of swap during putpages. The new system
|
||||||
* does not try to keep previously allocated swap blocks for dirty
|
* does not try to keep previously allocated swap blocks for dirty
|
||||||
* pages.
|
* pages.
|
||||||
*
|
*
|
||||||
* - on the fly deallocation of swap
|
* - on the fly deallocation of swap
|
||||||
*
|
*
|
||||||
@ -154,13 +154,13 @@ int swap_pager_avail;
|
|||||||
static int swdev_syscall_active = 0; /* serialize swap(on|off) */
|
static int swdev_syscall_active = 0; /* serialize swap(on|off) */
|
||||||
|
|
||||||
static vm_ooffset_t swap_total;
|
static vm_ooffset_t swap_total;
|
||||||
SYSCTL_QUAD(_vm, OID_AUTO, swap_total, CTLFLAG_RD, &swap_total, 0,
|
SYSCTL_QUAD(_vm, OID_AUTO, swap_total, CTLFLAG_RD, &swap_total, 0,
|
||||||
"Total amount of available swap storage.");
|
"Total amount of available swap storage.");
|
||||||
static vm_ooffset_t swap_reserved;
|
static vm_ooffset_t swap_reserved;
|
||||||
SYSCTL_QUAD(_vm, OID_AUTO, swap_reserved, CTLFLAG_RD, &swap_reserved, 0,
|
SYSCTL_QUAD(_vm, OID_AUTO, swap_reserved, CTLFLAG_RD, &swap_reserved, 0,
|
||||||
"Amount of swap storage needed to back all allocated anonymous memory.");
|
"Amount of swap storage needed to back all allocated anonymous memory.");
|
||||||
static int overcommit = 0;
|
static int overcommit = 0;
|
||||||
SYSCTL_INT(_vm, OID_AUTO, overcommit, CTLFLAG_RW, &overcommit, 0,
|
SYSCTL_INT(_vm, OID_AUTO, overcommit, CTLFLAG_RW, &overcommit, 0,
|
||||||
"Configure virtual memory overcommit behavior. See tuning(7) "
|
"Configure virtual memory overcommit behavior. See tuning(7) "
|
||||||
"for details.");
|
"for details.");
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ swap_reserve_by_cred(vm_ooffset_t incr, struct ucred *cred)
|
|||||||
static int curfail;
|
static int curfail;
|
||||||
static struct timeval lastfail;
|
static struct timeval lastfail;
|
||||||
struct uidinfo *uip;
|
struct uidinfo *uip;
|
||||||
|
|
||||||
uip = cred->cr_ruidinfo;
|
uip = cred->cr_ruidinfo;
|
||||||
|
|
||||||
if (incr & PAGE_MASK)
|
if (incr & PAGE_MASK)
|
||||||
@ -285,7 +285,7 @@ void
|
|||||||
swap_release_by_cred(vm_ooffset_t decr, struct ucred *cred)
|
swap_release_by_cred(vm_ooffset_t decr, struct ucred *cred)
|
||||||
{
|
{
|
||||||
struct uidinfo *uip;
|
struct uidinfo *uip;
|
||||||
|
|
||||||
uip = cred->cr_ruidinfo;
|
uip = cred->cr_ruidinfo;
|
||||||
|
|
||||||
if (decr & PAGE_MASK)
|
if (decr & PAGE_MASK)
|
||||||
@ -328,7 +328,7 @@ static struct sx sw_alloc_sx;
|
|||||||
|
|
||||||
|
|
||||||
SYSCTL_INT(_vm, OID_AUTO, swap_async_max,
|
SYSCTL_INT(_vm, OID_AUTO, swap_async_max,
|
||||||
CTLFLAG_RW, &swap_async_max, 0, "Maximum running async swap ops");
|
CTLFLAG_RW, &swap_async_max, 0, "Maximum running async swap ops");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "named" and "unnamed" anon region objects. Try to reduce the overhead
|
* "named" and "unnamed" anon region objects. Try to reduce the overhead
|
||||||
@ -340,7 +340,7 @@ SYSCTL_INT(_vm, OID_AUTO, swap_async_max,
|
|||||||
#define NOBJLIST(handle) \
|
#define NOBJLIST(handle) \
|
||||||
(&swap_pager_object_list[((int)(intptr_t)handle >> 4) & (NOBJLISTS-1)])
|
(&swap_pager_object_list[((int)(intptr_t)handle >> 4) & (NOBJLISTS-1)])
|
||||||
|
|
||||||
static struct mtx sw_alloc_mtx; /* protect list manipulation */
|
static struct mtx sw_alloc_mtx; /* protect list manipulation */
|
||||||
static struct pagerlst swap_pager_object_list[NOBJLISTS];
|
static struct pagerlst swap_pager_object_list[NOBJLISTS];
|
||||||
static uma_zone_t swap_zone;
|
static uma_zone_t swap_zone;
|
||||||
static struct vm_object swap_zone_obj;
|
static struct vm_object swap_zone_obj;
|
||||||
@ -419,7 +419,7 @@ swp_pager_free_nrpage(vm_page_t m)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* SWP_SIZECHECK() - update swap_pager_full indication
|
* SWP_SIZECHECK() - update swap_pager_full indication
|
||||||
*
|
*
|
||||||
* update the swap_pager_almost_full indication and warn when we are
|
* update the swap_pager_almost_full indication and warn when we are
|
||||||
* about to run out of swap space, using lowat/hiwat hysteresis.
|
* about to run out of swap space, using lowat/hiwat hysteresis.
|
||||||
*
|
*
|
||||||
@ -474,7 +474,7 @@ swp_pager_hash(vm_object_t object, vm_pindex_t index)
|
|||||||
/*
|
/*
|
||||||
* SWAP_PAGER_INIT() - initialize the swap pager!
|
* SWAP_PAGER_INIT() - initialize the swap pager!
|
||||||
*
|
*
|
||||||
* Expected to be started from system init. NOTE: This code is run
|
* Expected to be started from system init. NOTE: This code is run
|
||||||
* before much else so be careful what you depend on. Most of the VM
|
* before much else so be careful what you depend on. Most of the VM
|
||||||
* system has yet to be initialized at this point.
|
* system has yet to be initialized at this point.
|
||||||
*/
|
*/
|
||||||
@ -519,7 +519,7 @@ swap_pager_swap_init(void)
|
|||||||
* MAX_PAGEOUT_CLUSTER. Also be aware that swap ops are
|
* MAX_PAGEOUT_CLUSTER. Also be aware that swap ops are
|
||||||
* constrained by the swap device interleave stripe size.
|
* constrained by the swap device interleave stripe size.
|
||||||
*
|
*
|
||||||
* Currently we hardwire nsw_wcount_async to 4. This limit is
|
* Currently we hardwire nsw_wcount_async to 4. This limit is
|
||||||
* designed to prevent other I/O from having high latencies due to
|
* designed to prevent other I/O from having high latencies due to
|
||||||
* our pageout I/O. The value 4 works well for one or two active swap
|
* our pageout I/O. The value 4 works well for one or two active swap
|
||||||
* devices but is probably a little low if you have more. Even so,
|
* devices but is probably a little low if you have more. Even so,
|
||||||
@ -568,7 +568,7 @@ swap_pager_swap_init(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize our meta-data hash table. The swapper does not need to
|
* Initialize our meta-data hash table. The swapper does not need to
|
||||||
* be quite as efficient as the VM system, so we do not use an
|
* be quite as efficient as the VM system, so we do not use an
|
||||||
* oversized hash table.
|
* oversized hash table.
|
||||||
*
|
*
|
||||||
* n: size of hash table, must be power of 2
|
* n: size of hash table, must be power of 2
|
||||||
@ -654,7 +654,7 @@ swap_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
|
|||||||
/*
|
/*
|
||||||
* SWAP_PAGER_DEALLOC() - remove swap metadata from object
|
* SWAP_PAGER_DEALLOC() - remove swap metadata from object
|
||||||
*
|
*
|
||||||
* The swap backing for the object is destroyed. The code is
|
* The swap backing for the object is destroyed. The code is
|
||||||
* designed such that we can reinstantiate it later, but this
|
* designed such that we can reinstantiate it later, but this
|
||||||
* routine is typically called only when the entire object is
|
* routine is typically called only when the entire object is
|
||||||
* about to be destroyed.
|
* about to be destroyed.
|
||||||
@ -679,7 +679,7 @@ swap_pager_dealloc(vm_object_t object)
|
|||||||
vm_object_pip_wait(object, "swpdea");
|
vm_object_pip_wait(object, "swpdea");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Free all remaining metadata. We only bother to free it from
|
* Free all remaining metadata. We only bother to free it from
|
||||||
* the swap meta data. We do not attempt to free swapblk's still
|
* the swap meta data. We do not attempt to free swapblk's still
|
||||||
* associated with vm_page_t's for this object. We do not care
|
* associated with vm_page_t's for this object. We do not care
|
||||||
* if paging is still in progress on some objects.
|
* if paging is still in progress on some objects.
|
||||||
@ -748,7 +748,7 @@ swp_pager_isondev(daddr_t blk, struct swdevt *sp)
|
|||||||
|
|
||||||
return (blk >= sp->sw_first && blk < sp->sw_end);
|
return (blk >= sp->sw_first && blk < sp->sw_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
swp_pager_strategy(struct buf *bp)
|
swp_pager_strategy(struct buf *bp)
|
||||||
{
|
{
|
||||||
@ -764,10 +764,10 @@ swp_pager_strategy(struct buf *bp)
|
|||||||
}
|
}
|
||||||
panic("Swapdev not found");
|
panic("Swapdev not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SWP_PAGER_FREESWAPSPACE() - free raw swap space
|
* SWP_PAGER_FREESWAPSPACE() - free raw swap space
|
||||||
*
|
*
|
||||||
* This routine returns the specified swap blocks back to the bitmap.
|
* This routine returns the specified swap blocks back to the bitmap.
|
||||||
*
|
*
|
||||||
@ -785,7 +785,7 @@ swp_pager_freeswapspace(daddr_t blk, int npages)
|
|||||||
/*
|
/*
|
||||||
* If we are attempting to stop swapping on
|
* If we are attempting to stop swapping on
|
||||||
* this device, we don't want to mark any
|
* this device, we don't want to mark any
|
||||||
* blocks free lest they be reused.
|
* blocks free lest they be reused.
|
||||||
*/
|
*/
|
||||||
if ((sp->sw_flags & SW_CLOSING) == 0) {
|
if ((sp->sw_flags & SW_CLOSING) == 0) {
|
||||||
blist_free(sp->sw_blist, blk - sp->sw_first,
|
blist_free(sp->sw_blist, blk - sp->sw_first,
|
||||||
@ -808,8 +808,8 @@ swp_pager_freeswapspace(daddr_t blk, int npages)
|
|||||||
*
|
*
|
||||||
* This routine removes swapblk assignments from swap metadata.
|
* This routine removes swapblk assignments from swap metadata.
|
||||||
*
|
*
|
||||||
* The external callers of this routine typically have already destroyed
|
* The external callers of this routine typically have already destroyed
|
||||||
* or renamed vm_page_t's associated with this range in the object so
|
* or renamed vm_page_t's associated with this range in the object so
|
||||||
* we should be ok.
|
* we should be ok.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
@ -823,7 +823,7 @@ swap_pager_freespace(vm_object_t object, vm_pindex_t start, vm_size_t size)
|
|||||||
/*
|
/*
|
||||||
* SWAP_PAGER_RESERVE() - reserve swap blocks in object
|
* SWAP_PAGER_RESERVE() - reserve swap blocks in object
|
||||||
*
|
*
|
||||||
* Assigns swap blocks to the specified range within the object. The
|
* Assigns swap blocks to the specified range within the object. The
|
||||||
* swap blocks are not zerod. Any previous swap assignment is destroyed.
|
* swap blocks are not zerod. Any previous swap assignment is destroyed.
|
||||||
*
|
*
|
||||||
* Returns 0 on success, -1 on failure.
|
* Returns 0 on success, -1 on failure.
|
||||||
@ -869,7 +869,7 @@ swap_pager_reserve(vm_object_t object, vm_pindex_t start, vm_size_t size)
|
|||||||
*
|
*
|
||||||
* This routine is allowed to sleep. It may sleep allocating metadata
|
* This routine is allowed to sleep. It may sleep allocating metadata
|
||||||
* indirectly through swp_pager_meta_build() or if paging is still in
|
* indirectly through swp_pager_meta_build() or if paging is still in
|
||||||
* progress on the source.
|
* progress on the source.
|
||||||
*
|
*
|
||||||
* The source object contains no vm_page_t's (which is just as well)
|
* The source object contains no vm_page_t's (which is just as well)
|
||||||
*
|
*
|
||||||
@ -888,8 +888,8 @@ swap_pager_copy(vm_object_t srcobject, vm_object_t dstobject,
|
|||||||
VM_OBJECT_LOCK_ASSERT(dstobject, MA_OWNED);
|
VM_OBJECT_LOCK_ASSERT(dstobject, MA_OWNED);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If destroysource is set, we remove the source object from the
|
* If destroysource is set, we remove the source object from the
|
||||||
* swap_pager internal queue now.
|
* swap_pager internal queue now.
|
||||||
*/
|
*/
|
||||||
if (destroysource) {
|
if (destroysource) {
|
||||||
if (srcobject->handle != NULL) {
|
if (srcobject->handle != NULL) {
|
||||||
@ -925,7 +925,7 @@ swap_pager_copy(vm_object_t srcobject, vm_object_t dstobject,
|
|||||||
daddr_t srcaddr;
|
daddr_t srcaddr;
|
||||||
|
|
||||||
srcaddr = swp_pager_meta_ctl(
|
srcaddr = swp_pager_meta_ctl(
|
||||||
srcobject,
|
srcobject,
|
||||||
i + offset,
|
i + offset,
|
||||||
SWM_POP
|
SWM_POP
|
||||||
);
|
);
|
||||||
@ -947,7 +947,7 @@ swap_pager_copy(vm_object_t srcobject, vm_object_t dstobject,
|
|||||||
* Destination has valid swapblk or it is represented
|
* Destination has valid swapblk or it is represented
|
||||||
* by a resident page. We destroy the sourceblock.
|
* by a resident page. We destroy the sourceblock.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
swp_pager_meta_ctl(srcobject, i + offset, SWM_FREE);
|
swp_pager_meta_ctl(srcobject, i + offset, SWM_FREE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1042,7 +1042,7 @@ swap_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *before, int *aft
|
|||||||
* SWAP_PAGER_PAGE_UNSWAPPED() - remove swap backing store related to page
|
* SWAP_PAGER_PAGE_UNSWAPPED() - remove swap backing store related to page
|
||||||
*
|
*
|
||||||
* This removes any associated swap backing store, whether valid or
|
* This removes any associated swap backing store, whether valid or
|
||||||
* not, from the page.
|
* not, from the page.
|
||||||
*
|
*
|
||||||
* This routine is typically called when a page is made dirty, at
|
* This routine is typically called when a page is made dirty, at
|
||||||
* which point any associated swap can be freed. MADV_FREE also
|
* which point any associated swap can be freed. MADV_FREE also
|
||||||
@ -1071,7 +1071,7 @@ swap_pager_unswapped(vm_page_t m)
|
|||||||
* a chunk surrounding m[reqpage] as is contiguous in swap and which
|
* a chunk surrounding m[reqpage] as is contiguous in swap and which
|
||||||
* belongs to the same object.
|
* belongs to the same object.
|
||||||
*
|
*
|
||||||
* The code is designed for asynchronous operation and
|
* The code is designed for asynchronous operation and
|
||||||
* immediate-notification of 'reqpage' but tends not to be
|
* immediate-notification of 'reqpage' but tends not to be
|
||||||
* used that way. Please do not optimize-out this algorithmic
|
* used that way. Please do not optimize-out this algorithmic
|
||||||
* feature, I intend to improve on it in the future.
|
* feature, I intend to improve on it in the future.
|
||||||
@ -1101,7 +1101,7 @@ swap_pager_getpages(vm_object_t object, vm_page_t *m, int count, int reqpage)
|
|||||||
* Calculate range to retrieve. The pages have already been assigned
|
* Calculate range to retrieve. The pages have already been assigned
|
||||||
* their swapblks. We require a *contiguous* range but we know it to
|
* their swapblks. We require a *contiguous* range but we know it to
|
||||||
* not span devices. If we do not supply it, bad things
|
* not span devices. If we do not supply it, bad things
|
||||||
* happen. Note that blk, iblk & jblk can be SWAPBLK_NONE, but the
|
* happen. Note that blk, iblk & jblk can be SWAPBLK_NONE, but the
|
||||||
* loops are set up such that the case(s) are handled implicitly.
|
* loops are set up such that the case(s) are handled implicitly.
|
||||||
*
|
*
|
||||||
* The swp_*() calls must be made with the object locked.
|
* The swp_*() calls must be made with the object locked.
|
||||||
@ -1139,7 +1139,7 @@ swap_pager_getpages(vm_object_t object, vm_page_t *m, int count, int reqpage)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return VM_PAGER_FAIL if we have nothing to do. Return mreq
|
* Return VM_PAGER_FAIL if we have nothing to do. Return mreq
|
||||||
* still busy, but the others unbusied.
|
* still busy, but the others unbusied.
|
||||||
*/
|
*/
|
||||||
if (blk == SWAPBLK_NONE)
|
if (blk == SWAPBLK_NONE)
|
||||||
@ -1234,21 +1234,21 @@ swap_pager_getpages(vm_object_t object, vm_page_t *m, int count, int reqpage)
|
|||||||
/*
|
/*
|
||||||
* A final note: in a low swap situation, we cannot deallocate swap
|
* A final note: in a low swap situation, we cannot deallocate swap
|
||||||
* and mark a page dirty here because the caller is likely to mark
|
* and mark a page dirty here because the caller is likely to mark
|
||||||
* the page clean when we return, causing the page to possibly revert
|
* the page clean when we return, causing the page to possibly revert
|
||||||
* to all-zero's later.
|
* to all-zero's later.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* swap_pager_putpages:
|
* swap_pager_putpages:
|
||||||
*
|
*
|
||||||
* Assign swap (if necessary) and initiate I/O on the specified pages.
|
* Assign swap (if necessary) and initiate I/O on the specified pages.
|
||||||
*
|
*
|
||||||
* We support both OBJT_DEFAULT and OBJT_SWAP objects. DEFAULT objects
|
* We support both OBJT_DEFAULT and OBJT_SWAP objects. DEFAULT objects
|
||||||
* are automatically converted to SWAP objects.
|
* are automatically converted to SWAP objects.
|
||||||
*
|
*
|
||||||
* In a low memory situation we may block in VOP_STRATEGY(), but the new
|
* In a low memory situation we may block in VOP_STRATEGY(), but the new
|
||||||
* vm_page reservation system coupled with properly written VFS devices
|
* vm_page reservation system coupled with properly written VFS devices
|
||||||
* should ensure that no low-memory deadlock occurs. This is an area
|
* should ensure that no low-memory deadlock occurs. This is an area
|
||||||
* which needs work.
|
* which needs work.
|
||||||
*
|
*
|
||||||
@ -1269,8 +1269,8 @@ swap_pager_putpages(vm_object_t object, vm_page_t *m, int count,
|
|||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
if (count && m[0]->object != object) {
|
if (count && m[0]->object != object) {
|
||||||
panic("swap_pager_putpages: object mismatch %p/%p",
|
panic("swap_pager_putpages: object mismatch %p/%p",
|
||||||
object,
|
object,
|
||||||
m[0]->object
|
m[0]->object
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1292,7 +1292,7 @@ swap_pager_putpages(vm_object_t object, vm_page_t *m, int count,
|
|||||||
/*
|
/*
|
||||||
* Step 2
|
* Step 2
|
||||||
*
|
*
|
||||||
* Update nsw parameters from swap_async_max sysctl values.
|
* Update nsw parameters from swap_async_max sysctl values.
|
||||||
* Do not let the sysop crash the machine with bogus numbers.
|
* Do not let the sysop crash the machine with bogus numbers.
|
||||||
*/
|
*/
|
||||||
mtx_lock(&pbuf_mtx);
|
mtx_lock(&pbuf_mtx);
|
||||||
@ -1384,7 +1384,7 @@ swap_pager_putpages(vm_object_t object, vm_page_t *m, int count,
|
|||||||
vm_page_t mreq = m[i+j];
|
vm_page_t mreq = m[i+j];
|
||||||
|
|
||||||
swp_pager_meta_build(
|
swp_pager_meta_build(
|
||||||
mreq->object,
|
mreq->object,
|
||||||
mreq->pindex,
|
mreq->pindex,
|
||||||
blk + j
|
blk + j
|
||||||
);
|
);
|
||||||
@ -1453,10 +1453,10 @@ swap_pager_putpages(vm_object_t object, vm_page_t *m, int count,
|
|||||||
* Completion routine for asynchronous reads and writes from/to swap.
|
* Completion routine for asynchronous reads and writes from/to swap.
|
||||||
* Also called manually by synchronous code to finish up a bp.
|
* Also called manually by synchronous code to finish up a bp.
|
||||||
*
|
*
|
||||||
* For READ operations, the pages are VPO_BUSY'd. For WRITE operations,
|
* For READ operations, the pages are VPO_BUSY'd. For WRITE operations,
|
||||||
* the pages are vm_page_t->busy'd. For READ operations, we VPO_BUSY
|
* the pages are vm_page_t->busy'd. For READ operations, we VPO_BUSY
|
||||||
* unbusy all pages except the 'main' request page. For WRITE
|
* unbusy all pages except the 'main' request page. For WRITE
|
||||||
* operations, we vm_page_t->busy'd unbusy all pages ( we can do this
|
* operations, we vm_page_t->busy'd unbusy all pages ( we can do this
|
||||||
* because we marked them all VM_PAGER_PEND on return from putpages ).
|
* because we marked them all VM_PAGER_PEND on return from putpages ).
|
||||||
*
|
*
|
||||||
* This routine may not sleep.
|
* This routine may not sleep.
|
||||||
@ -1475,7 +1475,7 @@ swp_pager_async_iodone(struct buf *bp)
|
|||||||
"swap_pager: I/O error - %s failed; blkno %ld,"
|
"swap_pager: I/O error - %s failed; blkno %ld,"
|
||||||
"size %ld, error %d\n",
|
"size %ld, error %d\n",
|
||||||
((bp->b_iocmd == BIO_READ) ? "pagein" : "pageout"),
|
((bp->b_iocmd == BIO_READ) ? "pagein" : "pageout"),
|
||||||
(long)bp->b_blkno,
|
(long)bp->b_blkno,
|
||||||
(long)bp->b_bcount,
|
(long)bp->b_bcount,
|
||||||
bp->b_error
|
bp->b_error
|
||||||
);
|
);
|
||||||
@ -1495,7 +1495,7 @@ swp_pager_async_iodone(struct buf *bp)
|
|||||||
* cleanup pages. If an error occurs writing to swap, we are in
|
* cleanup pages. If an error occurs writing to swap, we are in
|
||||||
* very serious trouble. If it happens to be a disk error, though,
|
* very serious trouble. If it happens to be a disk error, though,
|
||||||
* we may be able to recover by reassigning the swap later on. So
|
* we may be able to recover by reassigning the swap later on. So
|
||||||
* in this case we remove the m->swapblk assignment for the page
|
* in this case we remove the m->swapblk assignment for the page
|
||||||
* but do not free it in the rlist. The errornous block(s) are thus
|
* but do not free it in the rlist. The errornous block(s) are thus
|
||||||
* never reallocated as swap. Redirty the page and continue.
|
* never reallocated as swap. Redirty the page and continue.
|
||||||
*/
|
*/
|
||||||
@ -1508,7 +1508,7 @@ swp_pager_async_iodone(struct buf *bp)
|
|||||||
/*
|
/*
|
||||||
* If an error occurs I'd love to throw the swapblk
|
* If an error occurs I'd love to throw the swapblk
|
||||||
* away without freeing it back to swapspace, so it
|
* away without freeing it back to swapspace, so it
|
||||||
* can never be used again. But I can't from an
|
* can never be used again. But I can't from an
|
||||||
* interrupt.
|
* interrupt.
|
||||||
*/
|
*/
|
||||||
if (bp->b_iocmd == BIO_READ) {
|
if (bp->b_iocmd == BIO_READ) {
|
||||||
@ -1517,7 +1517,7 @@ swp_pager_async_iodone(struct buf *bp)
|
|||||||
* locked for the parent, but all other
|
* locked for the parent, but all other
|
||||||
* pages can be freed. We still want to
|
* pages can be freed. We still want to
|
||||||
* wakeup the parent waiting on the page,
|
* wakeup the parent waiting on the page,
|
||||||
* though. ( also: pg_reqpage can be -1 and
|
* though. ( also: pg_reqpage can be -1 and
|
||||||
* not match anything ).
|
* not match anything ).
|
||||||
*
|
*
|
||||||
* We have to wake specifically requested pages
|
* We have to wake specifically requested pages
|
||||||
@ -1534,7 +1534,7 @@ swp_pager_async_iodone(struct buf *bp)
|
|||||||
else
|
else
|
||||||
vm_page_flash(m);
|
vm_page_flash(m);
|
||||||
/*
|
/*
|
||||||
* If i == bp->b_pager.pg_reqpage, do not wake
|
* If i == bp->b_pager.pg_reqpage, do not wake
|
||||||
* the page up. The caller needs to.
|
* the page up. The caller needs to.
|
||||||
*/
|
*/
|
||||||
} else {
|
} else {
|
||||||
@ -1551,7 +1551,7 @@ swp_pager_async_iodone(struct buf *bp)
|
|||||||
}
|
}
|
||||||
} else if (bp->b_iocmd == BIO_READ) {
|
} else if (bp->b_iocmd == BIO_READ) {
|
||||||
/*
|
/*
|
||||||
* NOTE: for reads, m->dirty will probably be
|
* NOTE: for reads, m->dirty will probably be
|
||||||
* overridden by the original caller of getpages so
|
* overridden by the original caller of getpages so
|
||||||
* we cannot set them in order to free the underlying
|
* we cannot set them in order to free the underlying
|
||||||
* swap in a low-swap situation. I don't think we'd
|
* swap in a low-swap situation. I don't think we'd
|
||||||
@ -1563,7 +1563,7 @@ swp_pager_async_iodone(struct buf *bp)
|
|||||||
*
|
*
|
||||||
* Note that the requested page, reqpage, is left
|
* Note that the requested page, reqpage, is left
|
||||||
* busied, but we still have to wake it up. The
|
* busied, but we still have to wake it up. The
|
||||||
* other pages are released (unbusied) by
|
* other pages are released (unbusied) by
|
||||||
* vm_page_wakeup().
|
* vm_page_wakeup().
|
||||||
*/
|
*/
|
||||||
KASSERT(!pmap_page_is_mapped(m),
|
KASSERT(!pmap_page_is_mapped(m),
|
||||||
@ -1577,7 +1577,7 @@ swp_pager_async_iodone(struct buf *bp)
|
|||||||
* up too because we cleared VPO_SWAPINPROG and
|
* up too because we cleared VPO_SWAPINPROG and
|
||||||
* could be waiting for it in getpages. However,
|
* could be waiting for it in getpages. However,
|
||||||
* be sure to not unbusy getpages specifically
|
* be sure to not unbusy getpages specifically
|
||||||
* requested page - getpages expects it to be
|
* requested page - getpages expects it to be
|
||||||
* left busy.
|
* left busy.
|
||||||
*/
|
*/
|
||||||
if (i != bp->b_pager.pg_reqpage) {
|
if (i != bp->b_pager.pg_reqpage) {
|
||||||
@ -1590,7 +1590,7 @@ swp_pager_async_iodone(struct buf *bp)
|
|||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* For write success, clear the dirty
|
* For write success, clear the dirty
|
||||||
* status, then finish the I/O ( which decrements the
|
* status, then finish the I/O ( which decrements the
|
||||||
* busy count and possibly wakes waiter's up ).
|
* busy count and possibly wakes waiter's up ).
|
||||||
*/
|
*/
|
||||||
KASSERT(!pmap_page_is_write_mapped(m),
|
KASSERT(!pmap_page_is_write_mapped(m),
|
||||||
@ -1615,8 +1615,8 @@ swp_pager_async_iodone(struct buf *bp)
|
|||||||
VM_OBJECT_UNLOCK(object);
|
VM_OBJECT_UNLOCK(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* swapdev_strategy() manually sets b_vp and b_bufobj before calling
|
* swapdev_strategy() manually sets b_vp and b_bufobj before calling
|
||||||
* bstrategy(). Set them back to NULL now we're done with it, or we'll
|
* bstrategy(). Set them back to NULL now we're done with it, or we'll
|
||||||
* trigger a KASSERT in relpbuf().
|
* trigger a KASSERT in relpbuf().
|
||||||
*/
|
*/
|
||||||
@ -1628,10 +1628,10 @@ swp_pager_async_iodone(struct buf *bp)
|
|||||||
* release the physical I/O buffer
|
* release the physical I/O buffer
|
||||||
*/
|
*/
|
||||||
relpbuf(
|
relpbuf(
|
||||||
bp,
|
bp,
|
||||||
((bp->b_iocmd == BIO_READ) ? &nsw_rcount :
|
((bp->b_iocmd == BIO_READ) ? &nsw_rcount :
|
||||||
((bp->b_flags & B_ASYNC) ?
|
((bp->b_flags & B_ASYNC) ?
|
||||||
&nsw_wcount_async :
|
&nsw_wcount_async :
|
||||||
&nsw_wcount_sync
|
&nsw_wcount_sync
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -1744,8 +1744,8 @@ restart:
|
|||||||
for (swap = swhash[i]; swap != NULL; swap = swap->swb_hnext) {
|
for (swap = swhash[i]; swap != NULL; swap = swap->swb_hnext) {
|
||||||
vm_object_t object = swap->swb_object;
|
vm_object_t object = swap->swb_object;
|
||||||
vm_pindex_t pindex = swap->swb_index;
|
vm_pindex_t pindex = swap->swb_index;
|
||||||
for (j = 0; j < SWAP_META_PAGES; ++j) {
|
for (j = 0; j < SWAP_META_PAGES; ++j) {
|
||||||
if (swp_pager_isondev(swap->swb_pages[j], sp)) {
|
if (swp_pager_isondev(swap->swb_pages[j], sp)) {
|
||||||
/* avoid deadlock */
|
/* avoid deadlock */
|
||||||
if (!VM_OBJECT_TRYLOCK(object)) {
|
if (!VM_OBJECT_TRYLOCK(object)) {
|
||||||
break;
|
break;
|
||||||
@ -1758,7 +1758,7 @@ restart:
|
|||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mtx_unlock(&swhash_mtx);
|
mtx_unlock(&swhash_mtx);
|
||||||
@ -1783,7 +1783,7 @@ restart:
|
|||||||
* SWAP META DATA *
|
* SWAP META DATA *
|
||||||
************************************************************************
|
************************************************************************
|
||||||
*
|
*
|
||||||
* These routines manipulate the swap metadata stored in the
|
* These routines manipulate the swap metadata stored in the
|
||||||
* OBJT_SWAP object.
|
* OBJT_SWAP object.
|
||||||
*
|
*
|
||||||
* Swap metadata is implemented with a global hash and not directly
|
* Swap metadata is implemented with a global hash and not directly
|
||||||
@ -1821,13 +1821,13 @@ swp_pager_meta_build(vm_object_t object, vm_pindex_t pindex, daddr_t swapblk)
|
|||||||
mtx_lock(&sw_alloc_mtx);
|
mtx_lock(&sw_alloc_mtx);
|
||||||
TAILQ_INSERT_TAIL(
|
TAILQ_INSERT_TAIL(
|
||||||
NOBJLIST(object->handle),
|
NOBJLIST(object->handle),
|
||||||
object,
|
object,
|
||||||
pager_object_list
|
pager_object_list
|
||||||
);
|
);
|
||||||
mtx_unlock(&sw_alloc_mtx);
|
mtx_unlock(&sw_alloc_mtx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Locate hash entry. If not found create, but if we aren't adding
|
* Locate hash entry. If not found create, but if we aren't adding
|
||||||
* anything just return. If we run out of space in the map we wait
|
* anything just return. If we run out of space in the map we wait
|
||||||
@ -1896,10 +1896,10 @@ done:
|
|||||||
/*
|
/*
|
||||||
* SWP_PAGER_META_FREE() - free a range of blocks in the object's swap metadata
|
* SWP_PAGER_META_FREE() - free a range of blocks in the object's swap metadata
|
||||||
*
|
*
|
||||||
* The requested range of blocks is freed, with any associated swap
|
* The requested range of blocks is freed, with any associated swap
|
||||||
* returned to the swap bitmap.
|
* returned to the swap bitmap.
|
||||||
*
|
*
|
||||||
* This routine will free swap metadata structures as they are cleaned
|
* This routine will free swap metadata structures as they are cleaned
|
||||||
* out. This routine does *NOT* operate on swap metadata associated
|
* out. This routine does *NOT* operate on swap metadata associated
|
||||||
* with resident pages.
|
* with resident pages.
|
||||||
*/
|
*/
|
||||||
@ -1991,14 +1991,14 @@ swp_pager_meta_free_all(vm_object_t object)
|
|||||||
* swapblk assignments in the swap meta data or in the vm_page_t.
|
* swapblk assignments in the swap meta data or in the vm_page_t.
|
||||||
* The routine typically returns the swapblk being looked-up, or popped,
|
* The routine typically returns the swapblk being looked-up, or popped,
|
||||||
* or SWAPBLK_NONE if the block was freed, or SWAPBLK_NONE if the block
|
* or SWAPBLK_NONE if the block was freed, or SWAPBLK_NONE if the block
|
||||||
* was invalid. This routine will automatically free any invalid
|
* was invalid. This routine will automatically free any invalid
|
||||||
* meta-data swapblks.
|
* meta-data swapblks.
|
||||||
*
|
*
|
||||||
* It is not possible to store invalid swapblks in the swap meta data
|
* It is not possible to store invalid swapblks in the swap meta data
|
||||||
* (other then a literal 'SWAPBLK_NONE'), so we don't bother checking.
|
* (other then a literal 'SWAPBLK_NONE'), so we don't bother checking.
|
||||||
*
|
*
|
||||||
* When acting on a busy resident page and paging is in progress, we
|
* When acting on a busy resident page and paging is in progress, we
|
||||||
* have to wait until paging is complete but otherwise can act on the
|
* have to wait until paging is complete but otherwise can act on the
|
||||||
* busy page.
|
* busy page.
|
||||||
*
|
*
|
||||||
* SWM_FREE remove and free swap block from metadata
|
* SWM_FREE remove and free swap block from metadata
|
||||||
@ -2014,7 +2014,7 @@ swp_pager_meta_ctl(vm_object_t object, vm_pindex_t pindex, int flags)
|
|||||||
|
|
||||||
VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
|
VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
|
||||||
/*
|
/*
|
||||||
* The meta data only exists of the object is OBJT_SWAP
|
* The meta data only exists of the object is OBJT_SWAP
|
||||||
* and even then might not be allocated yet.
|
* and even then might not be allocated yet.
|
||||||
*/
|
*/
|
||||||
if (object->type != OBJT_SWAP)
|
if (object->type != OBJT_SWAP)
|
||||||
@ -2040,7 +2040,7 @@ swp_pager_meta_ctl(vm_object_t object, vm_pindex_t pindex, int flags)
|
|||||||
uma_zfree(swap_zone, swap);
|
uma_zfree(swap_zone, swap);
|
||||||
--object->un_pager.swp.swp_bcount;
|
--object->un_pager.swp.swp_bcount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mtx_unlock(&swhash_mtx);
|
mtx_unlock(&swhash_mtx);
|
||||||
@ -2058,7 +2058,7 @@ struct swapon_args {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MPSAFE
|
* MPSAFE
|
||||||
*/
|
*/
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
@ -2153,7 +2153,7 @@ swaponsomething(struct vnode *vp, void *id, u_long nblks, sw_strategy_t *strateg
|
|||||||
/*
|
/*
|
||||||
* nblks is in DEV_BSIZE'd chunks, convert to PAGE_SIZE'd chunks.
|
* nblks is in DEV_BSIZE'd chunks, convert to PAGE_SIZE'd chunks.
|
||||||
* First chop nblks off to page-align it, then convert.
|
* First chop nblks off to page-align it, then convert.
|
||||||
*
|
*
|
||||||
* sw->sw_nblks is in page-sized chunks now too.
|
* sw->sw_nblks is in page-sized chunks now too.
|
||||||
*/
|
*/
|
||||||
nblks &= ~(ctodb(1) - 1);
|
nblks &= ~(ctodb(1) - 1);
|
||||||
@ -2342,12 +2342,12 @@ swapoff_all(void)
|
|||||||
struct swdevt *sp, *spt;
|
struct swdevt *sp, *spt;
|
||||||
const char *devname;
|
const char *devname;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
mtx_lock(&Giant);
|
mtx_lock(&Giant);
|
||||||
while (swdev_syscall_active)
|
while (swdev_syscall_active)
|
||||||
tsleep(&swdev_syscall_active, PUSER - 1, "swpoff", 0);
|
tsleep(&swdev_syscall_active, PUSER - 1, "swpoff", 0);
|
||||||
swdev_syscall_active = 1;
|
swdev_syscall_active = 1;
|
||||||
|
|
||||||
mtx_lock(&sw_dev_mtx);
|
mtx_lock(&sw_dev_mtx);
|
||||||
TAILQ_FOREACH_SAFE(sp, &swtailq, sw_list, spt) {
|
TAILQ_FOREACH_SAFE(sp, &swtailq, sw_list, spt) {
|
||||||
mtx_unlock(&sw_dev_mtx);
|
mtx_unlock(&sw_dev_mtx);
|
||||||
@ -2365,7 +2365,7 @@ swapoff_all(void)
|
|||||||
mtx_lock(&sw_dev_mtx);
|
mtx_lock(&sw_dev_mtx);
|
||||||
}
|
}
|
||||||
mtx_unlock(&sw_dev_mtx);
|
mtx_unlock(&sw_dev_mtx);
|
||||||
|
|
||||||
swdev_syscall_active = 0;
|
swdev_syscall_active = 0;
|
||||||
wakeup_one(&swdev_syscall_active);
|
wakeup_one(&swdev_syscall_active);
|
||||||
mtx_unlock(&Giant);
|
mtx_unlock(&Giant);
|
||||||
@ -2709,7 +2709,7 @@ swaponvp(struct thread *td, struct vnode *vp, u_long nblks)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mtx_unlock(&sw_dev_mtx);
|
mtx_unlock(&sw_dev_mtx);
|
||||||
|
|
||||||
(void) vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
(void) vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||||
#ifdef MAC
|
#ifdef MAC
|
||||||
error = mac_system_check_swapon(td->td_ucred, vp);
|
error = mac_system_check_swapon(td->td_ucred, vp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user