Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F168469670
D21093.id60211.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D21093.id60211.diff
View Options
Index: swap_pager.c
===================================================================
--- swap_pager.c
+++ swap_pager.c
@@ -1339,23 +1339,20 @@
swap_pager_putpages(vm_object_t object, vm_page_t *ma, int count,
int flags, int *rtvals)
{
- int i, n;
- boolean_t sync;
- daddr_t addr, n_free, s_free;
+ struct buf *bp;
+ daddr_t addr, blk, n_free, s_free;
+ vm_page_t mreq;
+ int i, j, n;
+ bool async;
- swp_pager_init_freerange(&s_free, &n_free);
- if (count && ma[0]->object != object) {
- panic("swap_pager_putpages: object mismatch %p/%p",
- object,
- ma[0]->object
- );
- }
+ KASSERT(count == 0 || ma[0]->object == object,
+ ("%s: object mismatch %p/%p",
+ __func__, object, ma[0]->object));
/*
* Step 1
*
* Turn object into OBJT_SWAP
- * check for bogus sysops
* force sync if not pageout process
*/
if (object->type != OBJT_SWAP) {
@@ -1364,13 +1361,9 @@
("unexpected object swap block"));
}
VM_OBJECT_WUNLOCK(object);
+ async = curproc == pageproc && (flags & VM_PAGER_PUT_SYNC) == 0;
+ swp_pager_init_freerange(&s_free, &n_free);
- n = 0;
- if (curproc != pageproc)
- sync = TRUE;
- else
- sync = (flags & VM_PAGER_PUT_SYNC) != 0;
-
/*
* Step 2
*
@@ -1379,10 +1372,6 @@
* successfully.
*/
for (i = 0; i < count; i += n) {
- int j;
- struct buf *bp;
- daddr_t blk;
-
/* Maximum I/O size is limited by maximum swap block size. */
n = min(count - i, nsw_cluster_max);
@@ -1390,7 +1379,7 @@
blk = swp_pager_getswapspace(&n, 4);
if (blk == SWAPBLK_NONE) {
for (j = 0; j < n; ++j)
- rtvals[i+j] = VM_PAGER_FAIL;
+ rtvals[i + j] = VM_PAGER_FAIL;
continue;
}
@@ -1398,7 +1387,7 @@
* All I/O parameters have been satisfied, build the I/O
* request and assign the swap space.
*/
- if (sync != TRUE) {
+ if (async) {
mtx_lock(&swbuf_mtx);
while (nsw_wcount_async == 0)
msleep(&nsw_wcount_async, &swbuf_mtx, PVM,
@@ -1407,7 +1396,7 @@
mtx_unlock(&swbuf_mtx);
}
bp = uma_zalloc(swwbuf_zone, M_WAITOK);
- if (sync != TRUE)
+ if (async)
bp->b_flags = B_ASYNC;
bp->b_flags |= B_PAGING;
bp->b_iocmd = BIO_WRITE;
@@ -1420,8 +1409,7 @@
VM_OBJECT_WLOCK(object);
for (j = 0; j < n; ++j) {
- vm_page_t mreq = ma[i+j];
-
+ mreq = ma[i + j];
addr = swp_pager_meta_build(mreq->object, mreq->pindex,
blk + j);
if (addr != SWAPBLK_NONE)
@@ -1457,7 +1445,7 @@
*
* NOTE: b_blkno is destroyed by the call to swapdev_strategy
*/
- if (sync == FALSE) {
+ if (async) {
bp->b_iodone = swp_pager_async_iodone;
BUF_KERNPROC(bp);
swp_pager_strategy(bp);
@@ -1483,8 +1471,8 @@
*/
swp_pager_async_iodone(bp);
}
+ swp_pager_freeswapspace(s_free, n_free);
VM_OBJECT_WLOCK(object);
- swp_pager_freeswapspace(s_free, n_free);
}
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Aug 29, 1:38 PM (7 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37504855
Default Alt Text
D21093.id60211.diff (2 KB)
Attached To
Mode
D21093: tidy up swap_pager_putpages
Attached
Detach File
Event Timeline
Log In to Comment