From: Guoqing Jiang <gqjiang@suse.com>
To: shli@kernel.org
Cc: neilb@suse.de, linux-raid@vger.kernel.org,
Guoqing Jiang <gqjiang@suse.com>
Subject: [V2 PATCH 08/13] md-cluster: always setup in-memory bitmap
Date: Mon, 2 May 2016 11:50:11 -0400 [thread overview]
Message-ID: <1462204216-2269-1-git-send-email-gqjiang@suse.com> (raw)
In-Reply-To: <1462203200-1375-1-git-send-email-gqjiang@suse.com>
The in-memory bitmap for raid is allocated on demand,
then for cluster scenario, it is possible that slave
node which received RESYNCING message doesn't have the
in-memory bitmap when master node is perform resyncing,
so we can't make bitmap is match up well among each
nodes.
So for cluster scenario, we need always preserve the
bitmap, and ensure the page will not be freed. And a
no_hijack flag is introduced to both bitmap_checkpage
and bitmap_get_counter, which makes cluster raid returns
fail once allocate failed.
And the next patch is relied on this change since it
keeps sync bitmap among each nodes during resyncing
stage.
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
---
drivers/md/bitmap.c | 37 +++++++++++++++++++++++++++++++++++--
1 file changed, 35 insertions(+), 2 deletions(-)
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 3fe86b5..431da21 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -46,7 +46,7 @@ static inline char *bmname(struct bitmap *bitmap)
* allocated while we're using it
*/
static int bitmap_checkpage(struct bitmap_counts *bitmap,
- unsigned long page, int create)
+ unsigned long page, int create, int no_hijack)
__releases(bitmap->lock)
__acquires(bitmap->lock)
{
@@ -90,6 +90,9 @@ __acquires(bitmap->lock)
if (mappage == NULL) {
pr_debug("md/bitmap: map page allocation failed, hijacking\n");
+ /* We don't support hijack for cluster raid */
+ if (no_hijack)
+ return -ENOMEM;
/* failed - set the hijacked flag so that we can use the
* pointer as a counter */
if (!bitmap->bp[page].map)
@@ -1321,7 +1324,7 @@ __acquires(bitmap->lock)
sector_t csize;
int err;
- err = bitmap_checkpage(bitmap, page, create);
+ err = bitmap_checkpage(bitmap, page, create, 0);
if (bitmap->bp[page].hijacked ||
bitmap->bp[page].map == NULL)
@@ -2032,6 +2035,36 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
chunks << chunkshift);
spin_lock_irq(&bitmap->counts.lock);
+ /* For cluster raid, need to pre-allocate bitmap */
+ if (mddev_is_clustered(bitmap->mddev)) {
+ unsigned long page;
+ for (page = 0; page < pages; page++) {
+ ret = bitmap_checkpage(&bitmap->counts, page, 1, 1);
+ if (ret) {
+ unsigned long k;
+
+ /* deallocate the page memory */
+ for (k = 0; k < page; k++) {
+ if (new_bp[k].map)
+ kfree(new_bp[k].map);
+ }
+
+ /* restore some fields from old_counts */
+ bitmap->counts.bp = old_counts.bp;
+ bitmap->counts.pages = old_counts.pages;
+ bitmap->counts.missing_pages = old_counts.pages;
+ bitmap->counts.chunkshift = old_counts.chunkshift;
+ bitmap->counts.chunks = old_counts.chunks;
+ bitmap->mddev->bitmap_info.chunksize = 1 << (old_counts.chunkshift +
+ BITMAP_BLOCK_SHIFT);
+ blocks = old_counts.chunks << old_counts.chunkshift;
+ pr_err("Could not pre-allocate in-memory bitmap for cluster raid\n");
+ break;
+ } else
+ bitmap->counts.bp[page].count += 1;
+ }
+ }
+
for (block = 0; block < blocks; ) {
bitmap_counter_t *bmc_old, *bmc_new;
int set;
--
2.6.6
next prev parent reply other threads:[~2016-05-02 15:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-02 15:33 [V2 PATCH 00/13] The latest patches for md-cluster Guoqing Jiang
2016-05-02 15:33 ` [V2 PATCH 01/13] md-cluster: change resync lock from asynchronous to synchronous Guoqing Jiang
2016-05-02 15:33 ` [V2 PATCH 02/13] md-cluser: make resync_finish only called after pers->sync_request Guoqing Jiang
2016-05-02 15:33 ` [V2 PATCH 03/13] md-cluster: wake up thread to continue recovery Guoqing Jiang
2016-05-02 15:33 ` [V2 PATCH 04/13] md-cluster: unregister thread if err happened Guoqing Jiang
2016-05-02 15:33 ` [V2 PATCH 05/13] md-cluster: fix locking when node joins cluster during message broadcast Guoqing Jiang
2016-05-02 15:33 ` [V2 PATCH 06/13] md-cluster: change array_sectors and update size are not supported Guoqing Jiang
2016-05-02 15:33 ` [V2 PATCH 07/13] md-cluster: wakeup thread if activated a spare disk Guoqing Jiang
2016-05-02 15:50 ` Guoqing Jiang [this message]
2016-05-02 15:50 ` [V2 PATCH 09/13] md-cluster: sync bitmap when node received RESYNCING msg Guoqing Jiang
2016-05-02 15:50 ` [V2 PATCH 10/13] md-cluster/bitmap: fix wrong calcuation of offset Guoqing Jiang
2016-05-02 15:50 ` [V2 PATCH 11/13] md-cluster/bitmap: fix wrong page num in bitmap_file_clear_bit and bitmap_file_set_bit Guoqing Jiang
2016-05-02 15:50 ` [V2 PATCH 12/13] md-cluster/bitmap: unplug bitmap to sync dirty pages to disk Guoqing Jiang
2016-05-02 15:50 ` [V2 PATCH 13/13] md-cluster: fix ifnullfree.cocci warnings Guoqing Jiang
2016-05-02 17:49 ` [V2 PATCH 00/13] The latest patches for md-cluster Shaohua Li
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=1462204216-2269-1-git-send-email-gqjiang@suse.com \
--to=gqjiang@suse.com \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
--cc=shli@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).