Commit bc8f167f authored by JackieLiu's avatar JackieLiu Committed by Shaohua Li

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: default avatarZhengyuan Liu <liuzhengyuan@kylinos.cn>
Reviewed-by: default avatarSong Liu <songliubraving@fb.com>
Signed-off-by: default avatarJackieLiu <liuyun01@kylinos.cn>
Signed-off-by: default avatarShaohua Li <shli@fb.com>
parent fc833c2a
...@@ -1948,7 +1948,7 @@ static void r5c_recovery_load_one_stripe(struct r5l_log *log, ...@@ -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, static int r5c_recovery_flush_log(struct r5l_log *log,
struct r5l_recovery_ctx *ctx) struct r5l_recovery_ctx *ctx)
{ {
struct stripe_head *sh, *next; struct stripe_head *sh;
int ret = 0; int ret = 0;
/* scan through the log */ /* scan through the log */
...@@ -1977,11 +1977,9 @@ static int r5c_recovery_flush_log(struct r5l_log *log, ...@@ -1977,11 +1977,9 @@ static int r5c_recovery_flush_log(struct r5l_log *log,
r5c_recovery_replay_stripes(&ctx->cached_list, ctx); r5c_recovery_replay_stripes(&ctx->cached_list, ctx);
/* load data-only stripes to stripe cache */ /* 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)); WARN_ON(!test_bit(STRIPE_R5C_CACHING, &sh->state));
r5c_recovery_load_one_stripe(log, sh); r5c_recovery_load_one_stripe(log, sh);
list_del_init(&sh->lru);
raid5_release_stripe(sh);
ctx->data_only_stripes++; ctx->data_only_stripes++;
} }
...@@ -2061,7 +2059,7 @@ static int ...@@ -2061,7 +2059,7 @@ static int
r5c_recovery_rewrite_data_only_stripes(struct r5l_log *log, r5c_recovery_rewrite_data_only_stripes(struct r5l_log *log,
struct r5l_recovery_ctx *ctx) struct r5l_recovery_ctx *ctx)
{ {
struct stripe_head *sh; struct stripe_head *sh, *next;
struct mddev *mddev = log->rdev->mddev; struct mddev *mddev = log->rdev->mddev;
struct page *page; struct page *page;
...@@ -2073,7 +2071,7 @@ r5c_recovery_rewrite_data_only_stripes(struct r5l_log *log, ...@@ -2073,7 +2071,7 @@ r5c_recovery_rewrite_data_only_stripes(struct r5l_log *log,
} }
ctx->seq += 10; 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; struct r5l_meta_block *mb;
int i; int i;
int offset; int offset;
...@@ -2119,6 +2117,9 @@ r5c_recovery_rewrite_data_only_stripes(struct r5l_log *log, ...@@ -2119,6 +2117,9 @@ r5c_recovery_rewrite_data_only_stripes(struct r5l_log *log,
sh->log_start = ctx->pos; sh->log_start = ctx->pos;
ctx->pos = write_pos; ctx->pos = write_pos;
ctx->seq += 1; ctx->seq += 1;
list_del_init(&sh->lru);
raid5_release_stripe(sh);
} }
__free_page(page); __free_page(page);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment