Skip to content

Commit dabc4ec

Browse files
shli@kernel.orgneilbrown
authored andcommitted
raid5: handle expansion/resync case with stripe batching
expansion/resync can grab a stripe when the stripe is in batch list. Since all stripes in batch list must be in the same state, we can't allow some stripes run into expansion/resync. So we delay expansion/resync for stripe in batch list. Signed-off-by: Shaohua Li <shli@fusionio.com> Signed-off-by: NeilBrown <neilb@suse.de>
1 parent 72ac733 commit dabc4ec

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

‎drivers/md/raid5.c‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3440,8 +3440,10 @@ static void handle_stripe_clean_event(struct r5conf *conf,
34403440
struct stripe_head, batch_list);
34413441
list_del_init(&sh->batch_list);
34423442

3443-
sh->state = head_sh->state & (~((1 << STRIPE_ACTIVE) |
3444-
(1 << STRIPE_PREREAD_ACTIVE)));
3443+
set_mask_bits(&sh->state, ~STRIPE_EXPAND_SYNC_FLAG,
3444+
head_sh->state & ~((1 << STRIPE_ACTIVE) |
3445+
(1 << STRIPE_PREREAD_ACTIVE) |
3446+
STRIPE_EXPAND_SYNC_FLAG));
34453447
sh->check_state = head_sh->check_state;
34463448
sh->reconstruct_state = head_sh->reconstruct_state;
34473449
for (i = 0; i < sh->disks; i++) {
@@ -3453,13 +3455,17 @@ static void handle_stripe_clean_event(struct r5conf *conf,
34533455
spin_lock_irq(&sh->stripe_lock);
34543456
sh->batch_head = NULL;
34553457
spin_unlock_irq(&sh->stripe_lock);
3458+
if (sh->state & STRIPE_EXPAND_SYNC_FLAG)
3459+
set_bit(STRIPE_HANDLE, &sh->state);
34563460
release_stripe(sh);
34573461
}
34583462

34593463
spin_lock_irq(&head_sh->stripe_lock);
34603464
head_sh->batch_head = NULL;
34613465
spin_unlock_irq(&head_sh->stripe_lock);
34623466
wake_up_nr(&conf->wait_for_overlap, wakeup_nr);
3467+
if (head_sh->state & STRIPE_EXPAND_SYNC_FLAG)
3468+
set_bit(STRIPE_HANDLE, &head_sh->state);
34633469
}
34643470

34653471
static void handle_stripe_dirtying(struct r5conf *conf,
@@ -3927,8 +3933,8 @@ static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s)
39273933

39283934
memset(s, 0, sizeof(*s));
39293935

3930-
s->expanding = test_bit(STRIPE_EXPAND_SOURCE, &sh->state);
3931-
s->expanded = test_bit(STRIPE_EXPAND_READY, &sh->state);
3936+
s->expanding = test_bit(STRIPE_EXPAND_SOURCE, &sh->state) && !sh->batch_head;
3937+
s->expanded = test_bit(STRIPE_EXPAND_READY, &sh->state) && !sh->batch_head;
39323938
s->failed_num[0] = -1;
39333939
s->failed_num[1] = -1;
39343940

@@ -4150,9 +4156,11 @@ static void check_break_stripe_batch_list(struct stripe_head *sh)
41504156
struct stripe_head, batch_list);
41514157
list_del_init(&sh->batch_list);
41524158

4153-
sh->state = head_sh->state & ~((1 << STRIPE_ACTIVE) |
4154-
(1 << STRIPE_PREREAD_ACTIVE) |
4155-
(1 << STRIPE_DEGRADED));
4159+
set_mask_bits(&sh->state, ~STRIPE_EXPAND_SYNC_FLAG,
4160+
head_sh->state & ~((1 << STRIPE_ACTIVE) |
4161+
(1 << STRIPE_PREREAD_ACTIVE) |
4162+
(1 << STRIPE_DEGRADED) |
4163+
STRIPE_EXPAND_SYNC_FLAG));
41564164
sh->check_state = head_sh->check_state;
41574165
sh->reconstruct_state = head_sh->reconstruct_state;
41584166
for (i = 0; i < sh->disks; i++)
@@ -4194,7 +4202,7 @@ static void handle_stripe(struct stripe_head *sh)
41944202

41954203
check_break_stripe_batch_list(sh);
41964204

4197-
if (test_bit(STRIPE_SYNC_REQUESTED, &sh->state)) {
4205+
if (test_bit(STRIPE_SYNC_REQUESTED, &sh->state) && !sh->batch_head) {
41984206
spin_lock(&sh->stripe_lock);
41994207
/* Cannot process 'sync' concurrently with 'discard' */
42004208
if (!test_bit(STRIPE_DISCARD, &sh->state) &&

‎drivers/md/raid5.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ enum {
339339
STRIPE_BATCH_ERR,
340340
};
341341

342+
#define STRIPE_EXPAND_SYNC_FLAG \
343+
((1 << STRIPE_EXPAND_SOURCE) |\
344+
(1 << STRIPE_EXPAND_READY) |\
345+
(1 << STRIPE_EXPANDING) |\
346+
(1 << STRIPE_SYNC_REQUESTED))
342347
/*
343348
* Operation request flags
344349
*/

0 commit comments

Comments
 (0)