diff options
author | Shaohua Li <shli@fb.com> | 2017-02-10 19:18:09 -0500 |
---|---|---|
committer | Shaohua Li <shli@fb.com> | 2017-02-13 12:20:05 -0500 |
commit | e33fbb9cc73d6502e69eaf1c178e0c39059763ea (patch) | |
tree | 3a75c9e524eab2facb854a41e970dfb86fc538c1 | |
parent | e8fd52eec2cd25b917983b3f3aa738b722522376 (diff) |
md/raid5-cache: exclude reclaiming stripes in reclaim check
stripes which are being reclaimed are still accounted into cached
stripes. The reclaim takes time. r5c_do_reclaim isn't aware of the
stripes and does unnecessary stripe reclaim. In practice, I saw one
stripe is reclaimed one time. This will cause bad IO pattern. Fixing
this by excluding the reclaing stripes in the check.
Cc: Song Liu <songliubraving@fb.com>
Signed-off-by: Shaohua Li <shli@fb.com>
-rw-r--r-- | drivers/md/raid5-cache.c | 14 | ||||
-rw-r--r-- | drivers/md/raid5.c | 2 | ||||
-rw-r--r-- | drivers/md/raid5.h | 2 |
3 files changed, 16 insertions, 2 deletions
diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c index a01f4daeb390..3f307be01b10 100644 --- a/drivers/md/raid5-cache.c +++ b/drivers/md/raid5-cache.c | |||
@@ -1327,6 +1327,10 @@ static void r5c_flush_stripe(struct r5conf *conf, struct stripe_head *sh) | |||
1327 | atomic_inc(&conf->active_stripes); | 1327 | atomic_inc(&conf->active_stripes); |
1328 | r5c_make_stripe_write_out(sh); | 1328 | r5c_make_stripe_write_out(sh); |
1329 | 1329 | ||
1330 | if (test_bit(STRIPE_R5C_PARTIAL_STRIPE, &sh->state)) | ||
1331 | atomic_inc(&conf->r5c_flushing_partial_stripes); | ||
1332 | else | ||
1333 | atomic_inc(&conf->r5c_flushing_full_stripes); | ||
1330 | raid5_release_stripe(sh); | 1334 | raid5_release_stripe(sh); |
1331 | } | 1335 | } |
1332 | 1336 | ||
@@ -1369,12 +1373,16 @@ static void r5c_do_reclaim(struct r5conf *conf) | |||
1369 | unsigned long flags; | 1373 | unsigned long flags; |
1370 | int total_cached; | 1374 | int total_cached; |
1371 | int stripes_to_flush; | 1375 | int stripes_to_flush; |
1376 | int flushing_partial, flushing_full; | ||
1372 | 1377 | ||
1373 | if (!r5c_is_writeback(log)) | 1378 | if (!r5c_is_writeback(log)) |
1374 | return; | 1379 | return; |
1375 | 1380 | ||
1381 | flushing_partial = atomic_read(&conf->r5c_flushing_partial_stripes); | ||
1382 | flushing_full = atomic_read(&conf->r5c_flushing_full_stripes); | ||
1376 | total_cached = atomic_read(&conf->r5c_cached_partial_stripes) + | 1383 | total_cached = atomic_read(&conf->r5c_cached_partial_stripes) + |
1377 | atomic_read(&conf->r5c_cached_full_stripes); | 1384 | atomic_read(&conf->r5c_cached_full_stripes) - |
1385 | flushing_full - flushing_partial; | ||
1378 | 1386 | ||
1379 | if (total_cached > conf->min_nr_stripes * 3 / 4 || | 1387 | if (total_cached > conf->min_nr_stripes * 3 / 4 || |
1380 | atomic_read(&conf->empty_inactive_list_nr) > 0) | 1388 | atomic_read(&conf->empty_inactive_list_nr) > 0) |
@@ -1384,7 +1392,7 @@ static void r5c_do_reclaim(struct r5conf *conf) | |||
1384 | */ | 1392 | */ |
1385 | stripes_to_flush = R5C_RECLAIM_STRIPE_GROUP; | 1393 | stripes_to_flush = R5C_RECLAIM_STRIPE_GROUP; |
1386 | else if (total_cached > conf->min_nr_stripes * 1 / 2 || | 1394 | else if (total_cached > conf->min_nr_stripes * 1 / 2 || |
1387 | atomic_read(&conf->r5c_cached_full_stripes) > | 1395 | atomic_read(&conf->r5c_cached_full_stripes) - flushing_full > |
1388 | R5C_FULL_STRIPE_FLUSH_BATCH) | 1396 | R5C_FULL_STRIPE_FLUSH_BATCH) |
1389 | /* | 1397 | /* |
1390 | * if stripe cache pressure moderate, or if there is many full | 1398 | * if stripe cache pressure moderate, or if there is many full |
@@ -2601,11 +2609,13 @@ void r5c_finish_stripe_write_out(struct r5conf *conf, | |||
2601 | 2609 | ||
2602 | if (test_and_clear_bit(STRIPE_R5C_PARTIAL_STRIPE, &sh->state)) { | 2610 | if (test_and_clear_bit(STRIPE_R5C_PARTIAL_STRIPE, &sh->state)) { |
2603 | BUG_ON(atomic_read(&conf->r5c_cached_partial_stripes) == 0); | 2611 | BUG_ON(atomic_read(&conf->r5c_cached_partial_stripes) == 0); |
2612 | atomic_dec(&conf->r5c_flushing_partial_stripes); | ||
2604 | atomic_dec(&conf->r5c_cached_partial_stripes); | 2613 | atomic_dec(&conf->r5c_cached_partial_stripes); |
2605 | } | 2614 | } |
2606 | 2615 | ||
2607 | if (test_and_clear_bit(STRIPE_R5C_FULL_STRIPE, &sh->state)) { | 2616 | if (test_and_clear_bit(STRIPE_R5C_FULL_STRIPE, &sh->state)) { |
2608 | BUG_ON(atomic_read(&conf->r5c_cached_full_stripes) == 0); | 2617 | BUG_ON(atomic_read(&conf->r5c_cached_full_stripes) == 0); |
2618 | atomic_dec(&conf->r5c_flushing_full_stripes); | ||
2609 | atomic_dec(&conf->r5c_cached_full_stripes); | 2619 | atomic_dec(&conf->r5c_cached_full_stripes); |
2610 | } | 2620 | } |
2611 | } | 2621 | } |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index b0d1345c832c..e2fa88fc6a1b 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -6838,6 +6838,8 @@ static struct r5conf *setup_conf(struct mddev *mddev) | |||
6838 | INIT_LIST_HEAD(&conf->r5c_full_stripe_list); | 6838 | INIT_LIST_HEAD(&conf->r5c_full_stripe_list); |
6839 | atomic_set(&conf->r5c_cached_partial_stripes, 0); | 6839 | atomic_set(&conf->r5c_cached_partial_stripes, 0); |
6840 | INIT_LIST_HEAD(&conf->r5c_partial_stripe_list); | 6840 | INIT_LIST_HEAD(&conf->r5c_partial_stripe_list); |
6841 | atomic_set(&conf->r5c_flushing_full_stripes, 0); | ||
6842 | atomic_set(&conf->r5c_flushing_partial_stripes, 0); | ||
6841 | 6843 | ||
6842 | conf->level = mddev->new_level; | 6844 | conf->level = mddev->new_level; |
6843 | conf->chunk_sectors = mddev->new_chunk_sectors; | 6845 | conf->chunk_sectors = mddev->new_chunk_sectors; |
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h index c0687df5ba06..4bb27b97bf6b 100644 --- a/drivers/md/raid5.h +++ b/drivers/md/raid5.h | |||
@@ -663,6 +663,8 @@ struct r5conf { | |||
663 | struct list_head r5c_full_stripe_list; | 663 | struct list_head r5c_full_stripe_list; |
664 | atomic_t r5c_cached_partial_stripes; | 664 | atomic_t r5c_cached_partial_stripes; |
665 | struct list_head r5c_partial_stripe_list; | 665 | struct list_head r5c_partial_stripe_list; |
666 | atomic_t r5c_flushing_full_stripes; | ||
667 | atomic_t r5c_flushing_partial_stripes; | ||
666 | 668 | ||
667 | atomic_t empty_inactive_list_nr; | 669 | atomic_t empty_inactive_list_nr; |
668 | struct llist_head released_stripes; | 670 | struct llist_head released_stripes; |