From: Zhilong Liu <zlliu@suse.com>
To: shli@kernel.org
Cc: linux-raid@vger.kernel.org, neilb@suse.com, Zhilong Liu <zlliu@suse.com>
Subject: [PATCH] md: ensure sectors is nonzero when change component size
Date: Thu, 12 Oct 2017 16:30:51 +0800 [thread overview]
Message-ID: <1507797051-18545-1-git-send-email-zlliu@suse.com> (raw)
Against the raids which chunk_size is meaningful, the component_size
must be >= chunk_size when require resize. If "new_size < chunk_size"
has required, the "mddev->pers->resize" will set sectors as '0', and
then the raids isn't meaningful any more due to mddev->dev_sectors is
'0'.
Cc: Neil Brown <neilb@suse.com>
Signed-off-by: Zhilong Liu <zlliu@suse.com>
---
drivers/md/raid10.c | 2 ++
drivers/md/raid5.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 374df57..f3891f6 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3871,6 +3871,8 @@ static int raid10_resize(struct mddev *mddev, sector_t sectors)
oldsize = raid10_size(mddev, 0, 0);
size = raid10_size(mddev, sectors, 0);
+ if (size == 0)
+ return -EINVAL;
if (mddev->external_size &&
mddev->array_sectors > size)
return -EINVAL;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 928e24a..768767c 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -7725,6 +7725,8 @@ static int raid5_resize(struct mddev *mddev, sector_t sectors)
if (conf->log || raid5_has_ppl(conf))
return -EINVAL;
sectors &= ~((sector_t)conf->chunk_sectors - 1);
+ if (sectors == 0)
+ return -EINVAL;
newsize = raid5_size(mddev, sectors, mddev->raid_disks);
if (mddev->external_size &&
mddev->array_sectors > newsize)
--
2.6.6
next reply other threads:[~2017-10-12 8:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-12 8:30 Zhilong Liu [this message]
2017-10-12 17:37 ` [PATCH] md: ensure sectors is nonzero when change component size Shaohua Li
2017-10-13 2:47 ` Zhilong Liu
2017-10-13 19:05 ` Shaohua Li
2017-10-16 7:31 ` Zhilong Liu
2017-10-17 0:21 ` NeilBrown
2017-10-23 9:23 ` Zhilong 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=1507797051-18545-1-git-send-email-zlliu@suse.com \
--to=zlliu@suse.com \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.com \
--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).