summaryrefslogtreecommitdiff
path: root/drivers/md
diff options
context:
space:
mode:
authorJackieLiu <liuyun01@kylinos.cn>2016-11-28 16:19:20 +0800
committerShaohua Li <shli@fb.com>2016-11-29 14:46:22 -0800
commitbc8f167f9c4656b7a972936237e9c38e6ab80c67 (patch)
tree5a8e38d74ff8ffb0e3916bbf977e2c34b4134e66 /drivers/md
parentfc833c2a2f4129c42efdaed64b9eb6e9ae5fdcee (diff)
md/raid5-cache: release the stripe_head at the appropriate location
If we released the 'stripe_head' in r5c_recovery_flush_log, ctx->cached_list will both release the data-parity stripes and data-only stripes, which will become empty. And we also need to use the data-only stripes in r5c_recovery_rewrite_data_only_stripes, so we should wait util rewrite data-only stripes is done before releasing them. Reviewed-by: Zhengyuan Liu <liuzhengyuan@kylinos.cn> Reviewed-by: Song Liu <songliubraving@fb.com> Signed-off-by: JackieLiu <liuyun01@kylinos.cn> Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/raid5-cache.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index 5ef20c57731f..7b9149ef685c 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -1948,7 +1948,7 @@ static void r5c_recovery_load_one_stripe(struct r5l_log *log,
static int r5c_recovery_flush_log(struct r5l_log *log,
struct r5l_recovery_ctx *ctx)
{
- struct stripe_head *sh, *next;
+ struct stripe_head *sh;
int ret = 0;
/* scan through the log */
@@ -1977,11 +1977,9 @@ static int r5c_recovery_flush_log(struct r5l_log *log,
r5c_recovery_replay_stripes(&ctx->cached_list, ctx);
/* load data-only stripes to stripe cache */
- list_for_each_entry_safe(sh, next, &ctx->cached_list, lru) {
+ list_for_each_entry(sh, &ctx->cached_list, lru) {
WARN_ON(!test_bit(STRIPE_R5C_CACHING, &sh->state));
r5c_recovery_load_one_stripe(log, sh);
- list_del_init(&sh->lru);
- raid5_release_stripe(sh);
ctx->data_only_stripes++;
}
@@ -2061,7 +2059,7 @@ static int
r5c_recovery_rewrite_data_only_stripes(struct r5l_log *log,
struct r5l_recovery_ctx *ctx)
{
- struct stripe_head *sh;
+ struct stripe_head *sh, *next;
struct mddev *mddev = log->rdev->mddev;
struct page *page;
@@ -2073,7 +2071,7 @@ r5c_recovery_rewrite_data_only_stripes(struct r5l_log *log,
}
ctx->seq += 10;
- list_for_each_entry(sh, &ctx->cached_list, lru) {
+ list_for_each_entry_safe(sh, next, &ctx->cached_list, lru) {
struct r5l_meta_block *mb;
int i;
int offset;
@@ -2119,6 +2117,9 @@ r5c_recovery_rewrite_data_only_stripes(struct r5l_log *log,
sh->log_start = ctx->pos;
ctx->pos = write_pos;
ctx->seq += 1;
+
+ list_del_init(&sh->lru);
+ raid5_release_stripe(sh);
}
__free_page(page);
return 0;