Fix congestion_wait() sync/async vs read/write confusion
Commit 1faa16d228
accidentally broke
the bdi congestion wait queue logic, causing us to wait on congestion
for WRITE (== 1) when we really wanted BLK_RW_ASYNC (== 0) instead.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
This commit is contained in:
@@ -283,7 +283,6 @@ static wait_queue_head_t congestion_wqh[2] = {
|
||||
__WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[1])
|
||||
};
|
||||
|
||||
|
||||
void clear_bdi_congested(struct backing_dev_info *bdi, int sync)
|
||||
{
|
||||
enum bdi_state bit;
|
||||
@@ -308,18 +307,18 @@ EXPORT_SYMBOL(set_bdi_congested);
|
||||
|
||||
/**
|
||||
* congestion_wait - wait for a backing_dev to become uncongested
|
||||
* @rw: READ or WRITE
|
||||
* @sync: SYNC or ASYNC IO
|
||||
* @timeout: timeout in jiffies
|
||||
*
|
||||
* Waits for up to @timeout jiffies for a backing_dev (any backing_dev) to exit
|
||||
* write congestion. If no backing_devs are congested then just wait for the
|
||||
* next write to be completed.
|
||||
*/
|
||||
long congestion_wait(int rw, long timeout)
|
||||
long congestion_wait(int sync, long timeout)
|
||||
{
|
||||
long ret;
|
||||
DEFINE_WAIT(wait);
|
||||
wait_queue_head_t *wqh = &congestion_wqh[rw];
|
||||
wait_queue_head_t *wqh = &congestion_wqh[sync];
|
||||
|
||||
prepare_to_wait(wqh, &wait, TASK_UNINTERRUPTIBLE);
|
||||
ret = io_schedule_timeout(timeout);
|
||||
|
@@ -1973,7 +1973,7 @@ try_to_free:
|
||||
if (!progress) {
|
||||
nr_retries--;
|
||||
/* maybe some writeback is necessary */
|
||||
congestion_wait(WRITE, HZ/10);
|
||||
congestion_wait(BLK_RW_ASYNC, HZ/10);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -575,7 +575,7 @@ static void balance_dirty_pages(struct address_space *mapping)
|
||||
if (pages_written >= write_chunk)
|
||||
break; /* We've done our duty */
|
||||
|
||||
congestion_wait(WRITE, HZ/10);
|
||||
congestion_wait(BLK_RW_ASYNC, HZ/10);
|
||||
}
|
||||
|
||||
if (bdi_nr_reclaimable + bdi_nr_writeback < bdi_thresh &&
|
||||
@@ -669,7 +669,7 @@ void throttle_vm_writeout(gfp_t gfp_mask)
|
||||
if (global_page_state(NR_UNSTABLE_NFS) +
|
||||
global_page_state(NR_WRITEBACK) <= dirty_thresh)
|
||||
break;
|
||||
congestion_wait(WRITE, HZ/10);
|
||||
congestion_wait(BLK_RW_ASYNC, HZ/10);
|
||||
|
||||
/*
|
||||
* The caller might hold locks which can prevent IO completion
|
||||
@@ -715,7 +715,7 @@ static void background_writeout(unsigned long _min_pages)
|
||||
if (wbc.nr_to_write > 0 || wbc.pages_skipped > 0) {
|
||||
/* Wrote less than expected */
|
||||
if (wbc.encountered_congestion || wbc.more_io)
|
||||
congestion_wait(WRITE, HZ/10);
|
||||
congestion_wait(BLK_RW_ASYNC, HZ/10);
|
||||
else
|
||||
break;
|
||||
}
|
||||
@@ -787,7 +787,7 @@ static void wb_kupdate(unsigned long arg)
|
||||
writeback_inodes(&wbc);
|
||||
if (wbc.nr_to_write > 0) {
|
||||
if (wbc.encountered_congestion || wbc.more_io)
|
||||
congestion_wait(WRITE, HZ/10);
|
||||
congestion_wait(BLK_RW_ASYNC, HZ/10);
|
||||
else
|
||||
break; /* All the old data is written */
|
||||
}
|
||||
|
@@ -1666,7 +1666,7 @@ __alloc_pages_high_priority(gfp_t gfp_mask, unsigned int order,
|
||||
preferred_zone, migratetype);
|
||||
|
||||
if (!page && gfp_mask & __GFP_NOFAIL)
|
||||
congestion_wait(WRITE, HZ/50);
|
||||
congestion_wait(BLK_RW_ASYNC, HZ/50);
|
||||
} while (!page && (gfp_mask & __GFP_NOFAIL));
|
||||
|
||||
return page;
|
||||
@@ -1831,7 +1831,7 @@ rebalance:
|
||||
pages_reclaimed += did_some_progress;
|
||||
if (should_alloc_retry(gfp_mask, order, pages_reclaimed)) {
|
||||
/* Wait for some write requests to complete then retry */
|
||||
congestion_wait(WRITE, HZ/50);
|
||||
congestion_wait(BLK_RW_ASYNC, HZ/50);
|
||||
goto rebalance;
|
||||
}
|
||||
|
||||
|
@@ -1104,7 +1104,7 @@ static unsigned long shrink_inactive_list(unsigned long max_scan,
|
||||
*/
|
||||
if (nr_freed < nr_taken && !current_is_kswapd() &&
|
||||
lumpy_reclaim) {
|
||||
congestion_wait(WRITE, HZ/10);
|
||||
congestion_wait(BLK_RW_ASYNC, HZ/10);
|
||||
|
||||
/*
|
||||
* The attempt at page out may have made some
|
||||
@@ -1721,7 +1721,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
|
||||
|
||||
/* Take a nap, wait for some writeback to complete */
|
||||
if (sc->nr_scanned && priority < DEF_PRIORITY - 2)
|
||||
congestion_wait(WRITE, HZ/10);
|
||||
congestion_wait(BLK_RW_ASYNC, HZ/10);
|
||||
}
|
||||
/* top priority shrink_zones still had more to do? don't OOM, then */
|
||||
if (!sc->all_unreclaimable && scanning_global_lru(sc))
|
||||
@@ -1960,7 +1960,7 @@ loop_again:
|
||||
* another pass across the zones.
|
||||
*/
|
||||
if (total_scanned && priority < DEF_PRIORITY - 2)
|
||||
congestion_wait(WRITE, HZ/10);
|
||||
congestion_wait(BLK_RW_ASYNC, HZ/10);
|
||||
|
||||
/*
|
||||
* We do this so kswapd doesn't build up large priorities for
|
||||
@@ -2233,7 +2233,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)
|
||||
goto out;
|
||||
|
||||
if (sc.nr_scanned && prio < DEF_PRIORITY - 2)
|
||||
congestion_wait(WRITE, HZ / 10);
|
||||
congestion_wait(BLK_RW_ASYNC, HZ / 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user