aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormajianpeng <majianpeng@gmail.com>2013-11-13 23:16:18 -0500
committerNeilBrown <neilb@suse.de>2013-11-18 23:19:18 -0500
commitb364e3d048e49b1d177eb7ee7853e77aa0560464 (patch)
tree5d13c7e1a010f3976567bfbc3a1b6226b9db96d6
parent82592c38a85889fc9b52bf67afd4f6a336858a96 (diff)
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: Jianpeng Ma <majianpeng@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--drivers/md/raid1.c15
-rw-r--r--drivers/md/raid1.h1
2 files changed, 8 insertions, 8 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index aacf6bf352d8..729db21dc829 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -829,6 +829,7 @@ static void raise_barrier(struct r1conf *conf)
829 829
830 /* Now wait for all pending IO to complete */ 830 /* Now wait for all pending IO to complete */
831 wait_event_lock_irq(conf->wait_barrier, 831 wait_event_lock_irq(conf->wait_barrier,
832 !conf->array_frozen &&
832 !conf->nr_pending && conf->barrier < RESYNC_DEPTH, 833 !conf->nr_pending && conf->barrier < RESYNC_DEPTH,
833 conf->resync_lock); 834 conf->resync_lock);
834 835
@@ -860,10 +861,11 @@ static void wait_barrier(struct r1conf *conf)
860 * count down. 861 * count down.
861 */ 862 */
862 wait_event_lock_irq(conf->wait_barrier, 863 wait_event_lock_irq(conf->wait_barrier,
863 !conf->barrier || 864 !conf->array_frozen &&
865 (!conf->barrier ||
864 (conf->nr_pending && 866 (conf->nr_pending &&
865 current->bio_list && 867 current->bio_list &&
866 !bio_list_empty(current->bio_list)), 868 !bio_list_empty(current->bio_list))),
867 conf->resync_lock); 869 conf->resync_lock);
868 conf->nr_waiting--; 870 conf->nr_waiting--;
869 } 871 }
@@ -884,8 +886,7 @@ static void freeze_array(struct r1conf *conf, int extra)
884{ 886{
885 /* stop syncio and normal IO and wait for everything to 887 /* stop syncio and normal IO and wait for everything to
886 * go quite. 888 * go quite.
887 * We increment barrier and nr_waiting, and then 889 * We wait until nr_pending match nr_queued+extra
888 * wait until nr_pending match nr_queued+extra
889 * This is called in the context of one normal IO request 890 * This is called in the context of one normal IO request
890 * that has failed. Thus any sync request that might be pending 891 * that has failed. Thus any sync request that might be pending
891 * will be blocked by nr_pending, and we need to wait for 892 * 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 * we continue. 896 * we continue.
896 */ 897 */
897 spin_lock_irq(&conf->resync_lock); 898 spin_lock_irq(&conf->resync_lock);
898 conf->barrier++; 899 conf->array_frozen = 1;
899 conf->nr_waiting++;
900 wait_event_lock_irq_cmd(conf->wait_barrier, 900 wait_event_lock_irq_cmd(conf->wait_barrier,
901 conf->nr_pending == conf->nr_queued+extra, 901 conf->nr_pending == conf->nr_queued+extra,
902 conf->resync_lock, 902 conf->resync_lock,
@@ -907,8 +907,7 @@ static void unfreeze_array(struct r1conf *conf)
907{ 907{
908 /* reverse the effect of the freeze */ 908 /* reverse the effect of the freeze */
909 spin_lock_irq(&conf->resync_lock); 909 spin_lock_irq(&conf->resync_lock);
910 conf->barrier--; 910 conf->array_frozen = 0;
911 conf->nr_waiting--;
912 wake_up(&conf->wait_barrier); 911 wake_up(&conf->wait_barrier);
913 spin_unlock_irq(&conf->resync_lock); 912 spin_unlock_irq(&conf->resync_lock);
914} 913}
diff --git a/drivers/md/raid1.h b/drivers/md/raid1.h
index 0ff3715fb7eb..331a98a231b4 100644
--- a/drivers/md/raid1.h
+++ b/drivers/md/raid1.h
@@ -65,6 +65,7 @@ struct r1conf {
65 int nr_waiting; 65 int nr_waiting;
66 int nr_queued; 66 int nr_queued;
67 int barrier; 67 int barrier;
68 int array_frozen;
68 69
69 /* Set to 1 if a full sync is needed, (fresh device added). 70 /* Set to 1 if a full sync is needed, (fresh device added).
70 * Cleared when a sync completes. 71 * Cleared when a sync completes.