Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 269270
b: refs/heads/master
c: 34db0cd
h: refs/heads/master
v: v3
  • Loading branch information
NeilBrown committed Oct 11, 2011
1 parent f5d7a26 commit 0fcf043
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 84fc4b56db85cb9e05326424049973a2036c9940
refs/heads/master: 34db0cd60f8a1f4ab73d118a8be3797c20388223
20 changes: 20 additions & 0 deletions trunk/drivers/md/raid1.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
*/
#define NR_RAID1_BIOS 256

/* When there are this many requests queue to be written by
* the raid1 thread, we become 'congested' to provide back-pressure
* for writeback.
*/
static int max_queued_requests = 1024;

static void allow_barrier(struct r1conf *conf);
static void lower_barrier(struct r1conf *conf);
Expand Down Expand Up @@ -598,6 +603,10 @@ int md_raid1_congested(struct mddev *mddev, int bits)
struct r1conf *conf = mddev->private;
int i, ret = 0;

if ((bits & (1 << BDI_async_congested)) &&
conf->pending_count >= max_queued_requests)
return 1;

rcu_read_lock();
for (i = 0; i < mddev->raid_disks; i++) {
struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev);
Expand Down Expand Up @@ -638,10 +647,12 @@ static void flush_pending_writes(struct r1conf *conf)
if (conf->pending_bio_list.head) {
struct bio *bio;
bio = bio_list_get(&conf->pending_bio_list);
conf->pending_count = 0;
spin_unlock_irq(&conf->device_lock);
/* flush any pending bitmap writes to
* disk before proceeding w/ I/O */
bitmap_unplug(conf->mddev->bitmap);
wake_up(&conf->wait_barrier);

while (bio) { /* submit pending writes */
struct bio *next = bio->bi_next;
Expand Down Expand Up @@ -945,6 +956,11 @@ static int make_request(struct mddev *mddev, struct bio * bio)
/*
* WRITE:
*/
if (conf->pending_count >= max_queued_requests) {
md_wakeup_thread(mddev->thread);
wait_event(conf->wait_barrier,
conf->pending_count < max_queued_requests);
}
/* first select target devices under rcu_lock and
* inc refcount on their rdev. Record them by setting
* bios[x] to bio
Expand Down Expand Up @@ -1108,6 +1124,7 @@ static int make_request(struct mddev *mddev, struct bio * bio)
atomic_inc(&r1_bio->remaining);
spin_lock_irqsave(&conf->device_lock, flags);
bio_list_add(&conf->pending_bio_list, mbio);
conf->pending_count++;
spin_unlock_irqrestore(&conf->device_lock, flags);
}
/* Mustn't call r1_bio_write_done before this next test,
Expand Down Expand Up @@ -2418,6 +2435,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
init_waitqueue_head(&conf->wait_barrier);

bio_list_init(&conf->pending_bio_list);
conf->pending_count = 0;

conf->last_used = -1;
for (i = 0; i < conf->raid_disks; i++) {
Expand Down Expand Up @@ -2776,3 +2794,5 @@ MODULE_DESCRIPTION("RAID1 (mirroring) personality for MD");
MODULE_ALIAS("md-personality-3"); /* RAID1 */
MODULE_ALIAS("md-raid1");
MODULE_ALIAS("md-level-1");

module_param(max_queued_requests, int, S_IRUGO|S_IWUSR);
1 change: 1 addition & 0 deletions trunk/drivers/md/raid1.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct r1conf {

/* queue pending writes to be submitted on unplug */
struct bio_list pending_bio_list;
int pending_count;

/* for use when syncing mirrors:
* We don't allow both normal IO and resync/recovery IO at
Expand Down
20 changes: 20 additions & 0 deletions trunk/drivers/md/raid10.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
*/
#define NR_RAID10_BIOS 256

/* When there are this many requests queue to be written by
* the raid10 thread, we become 'congested' to provide back-pressure
* for writeback.
*/
static int max_queued_requests = 1024;

static void allow_barrier(struct r10conf *conf);
static void lower_barrier(struct r10conf *conf);

Expand Down Expand Up @@ -681,6 +687,10 @@ static int raid10_congested(void *data, int bits)
struct r10conf *conf = mddev->private;
int i, ret = 0;

if ((bits & (1 << BDI_async_congested)) &&
conf->pending_count >= max_queued_requests)
return 1;

if (mddev_congested(mddev, bits))
return 1;
rcu_read_lock();
Expand All @@ -706,10 +716,12 @@ static void flush_pending_writes(struct r10conf *conf)
if (conf->pending_bio_list.head) {
struct bio *bio;
bio = bio_list_get(&conf->pending_bio_list);
conf->pending_count = 0;
spin_unlock_irq(&conf->device_lock);
/* flush any pending bitmap writes to disk
* before proceeding w/ I/O */
bitmap_unplug(conf->mddev->bitmap);
wake_up(&conf->wait_barrier);

while (bio) { /* submit pending writes */
struct bio *next = bio->bi_next;
Expand Down Expand Up @@ -996,6 +1008,11 @@ static int make_request(struct mddev *mddev, struct bio * bio)
/*
* WRITE:
*/
if (conf->pending_count >= max_queued_requests) {
md_wakeup_thread(mddev->thread);
wait_event(conf->wait_barrier,
conf->pending_count < max_queued_requests);
}
/* first select target devices under rcu_lock and
* inc refcount on their rdev. Record them by setting
* bios[x] to bio
Expand Down Expand Up @@ -1129,6 +1146,7 @@ static int make_request(struct mddev *mddev, struct bio * bio)
atomic_inc(&r10_bio->remaining);
spin_lock_irqsave(&conf->device_lock, flags);
bio_list_add(&conf->pending_bio_list, mbio);
conf->pending_count++;
spin_unlock_irqrestore(&conf->device_lock, flags);
}

Expand Down Expand Up @@ -3086,3 +3104,5 @@ MODULE_DESCRIPTION("RAID10 (striped mirror) personality for MD");
MODULE_ALIAS("md-personality-9"); /* RAID10 */
MODULE_ALIAS("md-raid10");
MODULE_ALIAS("md-level-10");

module_param(max_queued_requests, int, S_IRUGO|S_IWUSR);
2 changes: 1 addition & 1 deletion trunk/drivers/md/raid10.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct r10conf {
struct list_head retry_list;
/* queue pending writes and submit them on unplug */
struct bio_list pending_bio_list;

int pending_count;

spinlock_t resync_lock;
int nr_pending;
Expand Down

0 comments on commit 0fcf043

Please sign in to comment.