Skip to content

Commit b364e3d

Browse files
majianpengneilbrown
authored andcommitted
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>
1 parent 82592c3 commit b364e3d

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎drivers/md/raid1.c‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ static void raise_barrier(struct r1conf *conf)
829829

830830
/* Now wait for all pending IO to complete */
831831
wait_event_lock_irq(conf->wait_barrier,
832+
!conf->array_frozen &&
832833
!conf->nr_pending && conf->barrier < RESYNC_DEPTH,
833834
conf->resync_lock);
834835

@@ -860,10 +861,11 @@ static void wait_barrier(struct r1conf *conf)
860861
* count down.
861862
*/
862863
wait_event_lock_irq(conf->wait_barrier,
863-
!conf->barrier ||
864+
!conf->array_frozen &&
865+
(!conf->barrier ||
864866
(conf->nr_pending &&
865867
current->bio_list &&
866-
!bio_list_empty(current->bio_list)),
868+
!bio_list_empty(current->bio_list))),
867869
conf->resync_lock);
868870
conf->nr_waiting--;
869871
}
@@ -884,8 +886,7 @@ static void freeze_array(struct r1conf *conf, int extra)
884886
{
885887
/* stop syncio and normal IO and wait for everything to
886888
* go quite.
887-
* We increment barrier and nr_waiting, and then
888-
* wait until nr_pending match nr_queued+extra
889+
* We wait until nr_pending match nr_queued+extra
889890
* This is called in the context of one normal IO request
890891
* that has failed. Thus any sync request that might be pending
891892
* 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)
895896
* we continue.
896897
*/
897898
spin_lock_irq(&conf->resync_lock);
898-
conf->barrier++;
899-
conf->nr_waiting++;
899+
conf->array_frozen = 1;
900900
wait_event_lock_irq_cmd(conf->wait_barrier,
901901
conf->nr_pending == conf->nr_queued+extra,
902902
conf->resync_lock,
@@ -907,8 +907,7 @@ static void unfreeze_array(struct r1conf *conf)
907907
{
908908
/* reverse the effect of the freeze */
909909
spin_lock_irq(&conf->resync_lock);
910-
conf->barrier--;
911-
conf->nr_waiting--;
910+
conf->array_frozen = 0;
912911
wake_up(&conf->wait_barrier);
913912
spin_unlock_irq(&conf->resync_lock);
914913
}

‎drivers/md/raid1.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct r1conf {
6565
int nr_waiting;
6666
int nr_queued;
6767
int barrier;
68+
int array_frozen;
6869

6970
/* Set to 1 if a full sync is needed, (fresh device added).
7071
* Cleared when a sync completes.

0 commit comments

Comments
 (0)