All of lore.kernel.org
 help / color / mirror / Atom feed
From: JackieLiu <liuyun01@kylinos.cn>
To: songliubraving@fb.com
Cc: liuzhengyuan@kylinos.cn, linux-raid@vger.kernel.org,
	JackieLiu <liuyun01@kylinos.cn>
Subject: [PATCH 3/4] md/raid5-cache: release the stripe_head at the appropriate location
Date: Mon, 28 Nov 2016 16:19:20 +0800	[thread overview]
Message-ID: <20161128081921.5641-3-liuyun01@kylinos.cn> (raw)
In-Reply-To: <20161128081921.5641-1-liuyun01@kylinos.cn>

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>
Signed-off-by: JackieLiu <liuyun01@kylinos.cn>
---
 drivers/md/raid5-cache.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index 6d2b1da..9e72180 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -1950,7 +1950,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 */
@@ -1979,11 +1979,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++;
 	}
 
@@ -2063,7 +2061,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;
 
@@ -2075,7 +2073,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;
@@ -2121,6 +2119,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;
-- 
2.7.4




  parent reply	other threads:[~2016-11-28  8:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28  8:19 [PATCH 1/4] md/raid5-cache: remove unnecessary function parameters JackieLiu
2016-11-28  8:19 ` [PATCH 2/4] md/raid5-cache: use ring add to prevent overflow JackieLiu
2016-11-29 20:31   ` Song Liu
2016-11-28  8:19 ` JackieLiu [this message]
2016-11-29 20:33   ` [PATCH 3/4] md/raid5-cache: release the stripe_head at the appropriate location Song Liu
2016-11-28  8:19 ` [PATCH 4/4] md/raid5-cache: adjust the write position of the empty block and mark it as a checkpoint JackieLiu
2016-11-29 20:33   ` Song Liu
2016-11-29 22:31   ` Shaohua Li
2016-11-30  4:03     ` JackieLiu
2016-12-02 20:10       ` Shaohua Li
2016-12-05  3:58         ` JackieLiu
2016-12-06  1:00           ` Shaohua Li
2016-11-29 20:14 ` [PATCH 1/4] md/raid5-cache: remove unnecessary function parameters Song Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161128081921.5641-3-liuyun01@kylinos.cn \
    --to=liuyun01@kylinos.cn \
    --cc=linux-raid@vger.kernel.org \
    --cc=liuzhengyuan@kylinos.cn \
    --cc=songliubraving@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.