linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jes.Sorensen@redhat.com
To: neilb@suse.de
Cc: dledford@redhat.com, linux-raid@vger.kernel.org
Subject: [PATCH 1/1] Avoid OOPS when reshaping raid1 to raid0
Date: Thu, 22 Mar 2012 17:15:53 +0100	[thread overview]
Message-ID: <1332432953-30091-2-git-send-email-Jes.Sorensen@redhat.com> (raw)
In-Reply-To: <1332432953-30091-1-git-send-email-Jes.Sorensen@redhat.com>

From: Jes Sorensen <Jes.Sorensen@redhat.com>

raid1 arrays do not have the notion of chunk size. Set the existing
chunk size of the new raid0 to the same as the proposed new chunk size
to avoid a divide by zero OOPS when aligning the size of the new array
to that of the chunk size.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 drivers/md/raid0.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 6f31f55..dff8d6b 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -639,6 +639,14 @@ static void *raid0_takeover_raid1(struct mddev *mddev)
 	mddev->new_level = 0;
 	mddev->new_layout = 0;
 	mddev->new_chunk_sectors = 128; /* by default set chunk size to 64k */
+	mddev->chunk_sectors = 128;	/*
+					 * a raid1 one doesn't have the
+					 * notion of chunk size, so set
+					 * existing chunk_sector to match the
+					 * new size to avoid divide by zero
+					 * when aligning the size of the new
+					 * raid0 to the existing chunk size.
+					 */
 	mddev->delta_disks = 1 - mddev->raid_disks;
 	mddev->raid_disks = 1;
 	/* make sure it will be not marked as dirty */
-- 
1.7.7.6


  reply	other threads:[~2012-03-22 16:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-22 16:15 [PATCH 0/1] Avoid OOPS when reshaping raid1 to raid0 Jes.Sorensen
2012-03-22 16:15 ` Jes.Sorensen [this message]
2012-03-22 16:19   ` [PATCH 1/1] " Doug Ledford
2012-03-25 22:29   ` NeilBrown
2012-03-26  8:29     ` Jes Sorensen

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=1332432953-30091-2-git-send-email-Jes.Sorensen@redhat.com \
    --to=jes.sorensen@redhat.com \
    --cc=dledford@redhat.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.de \
    /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).