forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PATCH] separate bdi congestion functions from queue congestion funct…
…ions Separate out the concept of "queue congestion" from "backing-dev congestion". Congestion is a backing-dev concept, not a queue concept. The blk_* congestion functions are retained, as wrappers around the core backing-dev congestion functions. This proper layering is needed so that NFS can cleanly use the congestion functions, and so that CONFIG_BLOCK=n actually links. Cc: "Thomas Maier" <[email protected]> Cc: "Jens Axboe" <[email protected]> Cc: Trond Myklebust <[email protected]> Cc: David Howells <[email protected]> Cc: Peter Osterlund <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
- Loading branch information
Andrew Morton
authored and
Linus Torvalds
committed
Oct 20, 2006
1 parent
79e2de4
commit 3fcfab1
Showing
17 changed files
with
126 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
|
||
#include <linux/wait.h> | ||
#include <linux/backing-dev.h> | ||
#include <linux/fs.h> | ||
#include <linux/sched.h> | ||
#include <linux/module.h> | ||
|
||
static wait_queue_head_t congestion_wqh[2] = { | ||
__WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[0]), | ||
__WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[1]) | ||
}; | ||
|
||
|
||
void clear_bdi_congested(struct backing_dev_info *bdi, int rw) | ||
{ | ||
enum bdi_state bit; | ||
wait_queue_head_t *wqh = &congestion_wqh[rw]; | ||
|
||
bit = (rw == WRITE) ? BDI_write_congested : BDI_read_congested; | ||
clear_bit(bit, &bdi->state); | ||
smp_mb__after_clear_bit(); | ||
if (waitqueue_active(wqh)) | ||
wake_up(wqh); | ||
} | ||
EXPORT_SYMBOL(clear_bdi_congested); | ||
|
||
void set_bdi_congested(struct backing_dev_info *bdi, int rw) | ||
{ | ||
enum bdi_state bit; | ||
|
||
bit = (rw == WRITE) ? BDI_write_congested : BDI_read_congested; | ||
set_bit(bit, &bdi->state); | ||
} | ||
EXPORT_SYMBOL(set_bdi_congested); | ||
|
||
/** | ||
* congestion_wait - wait for a backing_dev to become uncongested | ||
* @rw: READ or WRITE | ||
* @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 ret; | ||
DEFINE_WAIT(wait); | ||
wait_queue_head_t *wqh = &congestion_wqh[rw]; | ||
|
||
prepare_to_wait(wqh, &wait, TASK_UNINTERRUPTIBLE); | ||
ret = io_schedule_timeout(timeout); | ||
finish_wait(wqh, &wait); | ||
return ret; | ||
} | ||
EXPORT_SYMBOL(congestion_wait); | ||
|
||
/** | ||
* congestion_end - wake up sleepers on a congested backing_dev_info | ||
* @rw: READ or WRITE | ||
*/ | ||
void congestion_end(int rw) | ||
{ | ||
wait_queue_head_t *wqh = &congestion_wqh[rw]; | ||
|
||
if (waitqueue_active(wqh)) | ||
wake_up(wqh); | ||
} | ||
EXPORT_SYMBOL(congestion_end); |
Oops, something went wrong.