All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yufen Yu <yuyufen@huawei.com>
To: song@kernel.org
Cc: linux-raid@vger.kernel.org, neilb@suse.com,
	guoqing.jiang@cloud.ionos.com, houtao1@huawei.com,
	yuyufen@huawei.com
Subject: [PATCH 11/12] md/raid5: resize stripe_head when reshape array
Date: Wed, 12 Aug 2020 08:49:30 -0400	[thread overview]
Message-ID: <20200812124931.2584743-12-yuyufen@huawei.com> (raw)
In-Reply-To: <20200812124931.2584743-1-yuyufen@huawei.com>

When reshape array, we try to reuse shared pages of old stripe_head,
and allocate more for the new one if needed.

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
---
 drivers/md/raid5.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 189ef51e853a..265d1c22309b 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2533,6 +2533,12 @@ static int resize_stripes(struct r5conf *conf, int newsize)
 		osh = get_free_stripe(conf, hash);
 		unlock_device_hash_lock(conf, hash);
 
+#if PAGE_SIZE != DEFAULT_STRIPE_SIZE
+	for (i = 0; i < osh->nr_pages; i++) {
+		nsh->pages[i] = osh->pages[i];
+		osh->pages[i] = NULL;
+	}
+#endif
 		for(i=0; i<conf->pool_size; i++) {
 			nsh->dev[i].page = osh->dev[i].page;
 			nsh->dev[i].orig_page = osh->dev[i].page;
@@ -2587,6 +2593,23 @@ static int resize_stripes(struct r5conf *conf, int newsize)
 		nsh = list_entry(newstripes.next, struct stripe_head, lru);
 		list_del_init(&nsh->lru);
 
+#if PAGE_SIZE != DEFAULT_STRIPE_SIZE
+		for (i = 0; i < nsh->nr_pages; i++) {
+			if (nsh->pages[i])
+				continue;
+			nsh->pages[i] = alloc_page(GFP_NOIO);
+			if (!nsh->pages[i])
+				err = -ENOMEM;
+		}
+
+		for (i = conf->raid_disks; i < newsize; i++) {
+			if (nsh->dev[i].page)
+				continue;
+			nsh->dev[i].page = raid5_get_dev_page(nsh, i);
+			nsh->dev[i].orig_page = nsh->dev[i].page;
+			nsh->dev[i].offset = raid5_get_page_offset(nsh, i);
+		}
+#else
 		for (i=conf->raid_disks; i < newsize; i++)
 			if (nsh->dev[i].page == NULL) {
 				struct page *p = alloc_page(GFP_NOIO);
@@ -2596,6 +2619,7 @@ static int resize_stripes(struct r5conf *conf, int newsize)
 				if (!p)
 					err = -ENOMEM;
 			}
+#endif
 		raid5_release_stripe(nsh);
 	}
 	/* critical section pass, GFP_NOIO no longer needed */
-- 
2.25.4

  parent reply	other threads:[~2020-08-12 12:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-12 12:49 [PATCH 00/12] Save memory for stripe_head buffer Yufen Yu
2020-08-12 12:49 ` [PATCH 01/12] md/raid5: add offset array in scribble buffer Yufen Yu
2020-08-12 12:49 ` [PATCH 02/12] md/raid5: add a new member of offset into r5dev Yufen Yu
2020-08-12 12:49 ` [PATCH 03/12] md/raid5: make async_copy_data() to support different page offset Yufen Yu
2020-08-12 12:49 ` [PATCH 04/12] md/raid5: add new xor function " Yufen Yu
2020-08-12 12:49 ` [PATCH 05/12] md/raid5: convert to new xor compution interface Yufen Yu
2020-08-12 12:49 ` [PATCH 06/12] md/raid6: let syndrome computor support different page offset Yufen Yu
2020-08-12 12:49 ` [PATCH 07/12] md/raid6: let async recovery function " Yufen Yu
2020-08-12 12:49 ` [PATCH 08/12] md/raid6: convert to new syndrome and recovery interface Yufen Yu
2020-08-12 12:49 ` [PATCH 09/12] raid6test: adaptation with new syndrome function Yufen Yu
2020-08-12 12:49 ` [PATCH 10/12] md/raid5: let multiple devices of stripe_head share page Yufen Yu
2020-08-12 12:49 ` Yufen Yu [this message]
2020-08-12 12:49 ` [PATCH 12/12] md/raid5: reallocate page array after setting new stripe_size Yufen Yu
2020-08-20  0:25 ` [PATCH 00/12] Save memory for stripe_head buffer Song Liu
2020-08-20  6:30   ` Yufen Yu

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=20200812124931.2584743-12-yuyufen@huawei.com \
    --to=yuyufen@huawei.com \
    --cc=guoqing.jiang@cloud.ionos.com \
    --cc=houtao1@huawei.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.com \
    --cc=song@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 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.