Commit b364e3d0 authored by majianpeng's avatar majianpeng Committed by NeilBrown

raid1: Add a field array_frozen to indicate whether raid in freeze state.

Because the following patch will rewrite the content between normal IO
and resync IO. So we used a parameter to indicate whether raid is in freeze
array.
Signed-off-by: default avatarJianpeng Ma <majianpeng@gmail.com>
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent 82592c38
...@@ -829,6 +829,7 @@ static void raise_barrier(struct r1conf *conf) ...@@ -829,6 +829,7 @@ static void raise_barrier(struct r1conf *conf)
/* Now wait for all pending IO to complete */ /* Now wait for all pending IO to complete */
wait_event_lock_irq(conf->wait_barrier, wait_event_lock_irq(conf->wait_barrier,
!conf->array_frozen &&
!conf->nr_pending && conf->barrier < RESYNC_DEPTH, !conf->nr_pending && conf->barrier < RESYNC_DEPTH,
conf->resync_lock); conf->resync_lock);
...@@ -860,10 +861,11 @@ static void wait_barrier(struct r1conf *conf) ...@@ -860,10 +861,11 @@ static void wait_barrier(struct r1conf *conf)
* count down. * count down.
*/ */
wait_event_lock_irq(conf->wait_barrier, wait_event_lock_irq(conf->wait_barrier,
!conf->barrier || !conf->array_frozen &&
(!conf->barrier ||
(conf->nr_pending && (conf->nr_pending &&
current->bio_list && current->bio_list &&
!bio_list_empty(current->bio_list)), !bio_list_empty(current->bio_list))),
conf->resync_lock); conf->resync_lock);
conf->nr_waiting--; conf->nr_waiting--;
} }
...@@ -884,8 +886,7 @@ static void freeze_array(struct r1conf *conf, int extra) ...@@ -884,8 +886,7 @@ static void freeze_array(struct r1conf *conf, int extra)
{ {
/* stop syncio and normal IO and wait for everything to /* stop syncio and normal IO and wait for everything to
* go quite. * go quite.
* We increment barrier and nr_waiting, and then * We wait until nr_pending match nr_queued+extra
* wait until nr_pending match nr_queued+extra
* This is called in the context of one normal IO request * This is called in the context of one normal IO request
* that has failed. Thus any sync request that might be pending * that has failed. Thus any sync request that might be pending
* will be blocked by nr_pending, and we need to wait for * will be blocked by nr_pending, and we need to wait for
...@@ -895,8 +896,7 @@ static void freeze_array(struct r1conf *conf, int extra) ...@@ -895,8 +896,7 @@ static void freeze_array(struct r1conf *conf, int extra)
* we continue. * we continue.
*/ */
spin_lock_irq(&conf->resync_lock); spin_lock_irq(&conf->resync_lock);
conf->barrier++; conf->array_frozen = 1;
conf->nr_waiting++;
wait_event_lock_irq_cmd(conf->wait_barrier, wait_event_lock_irq_cmd(conf->wait_barrier,
conf->nr_pending == conf->nr_queued+extra, conf->nr_pending == conf->nr_queued+extra,
conf->resync_lock, conf->resync_lock,
...@@ -907,8 +907,7 @@ static void unfreeze_array(struct r1conf *conf) ...@@ -907,8 +907,7 @@ static void unfreeze_array(struct r1conf *conf)
{ {
/* reverse the effect of the freeze */ /* reverse the effect of the freeze */
spin_lock_irq(&conf->resync_lock); spin_lock_irq(&conf->resync_lock);
conf->barrier--; conf->array_frozen = 0;
conf->nr_waiting--;
wake_up(&conf->wait_barrier); wake_up(&conf->wait_barrier);
spin_unlock_irq(&conf->resync_lock); spin_unlock_irq(&conf->resync_lock);
} }
......
...@@ -65,6 +65,7 @@ struct r1conf { ...@@ -65,6 +65,7 @@ struct r1conf {
int nr_waiting; int nr_waiting;
int nr_queued; int nr_queued;
int barrier; int barrier;
int array_frozen;
/* Set to 1 if a full sync is needed, (fresh device added). /* Set to 1 if a full sync is needed, (fresh device added).
* Cleared when a sync completes. * Cleared when a sync completes.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment