linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Brassow <jbrassow@redhat.com>
To: linux-raid@vger.kernel.org
Cc: neilb@suse.de, agk@redhat.com, jbrassow@redhat.com
Subject: Re: [PATCH]  DM RAID:  Ensure the bitmap region_size is a power of 2
Date: Wed, 12 Dec 2012 08:53:32 -0600	[thread overview]
Message-ID: <1355324012.26828.9.camel@f16> (raw)
In-Reply-To: <1355261825.26828.6.camel@f16>

This is probably a better way to do it...

 brassow

DM RAID:  Ensure the bitmap region_size is a power of 2

If the user does not supply a region_size, a reasonable size is computed
automatically.  However, region_size needs to be a power of 2 and the
code was not properly ensuring that.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>

Index: linux-upstream/drivers/md/dm-raid.c
===================================================================
--- linux-upstream.orig/drivers/md/dm-raid.c
+++ linux-upstream/drivers/md/dm-raid.c
@@ -295,9 +295,11 @@ static int validate_region_size(struct r
 		 * Choose a reasonable default.  All figures in sectors.
 		 */
 		if (min_region_size > (1 << 13)) {
+			/* If not a power of 2, make it the next power of 2 */
+			if (min_region_size & (min_region_size - 1))
+				region_size = 1 << fls(region_size);
 			DMINFO("Choosing default region size of %lu sectors",
 			       region_size);
-			region_size = min_region_size;
 		} else {
 			DMINFO("Choosing default region size of 4MiB");
 			region_size = 1 << 13; /* sectors */



  parent reply	other threads:[~2012-12-12 14:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-11 21:37 [PATCH] DM RAID: Ensure the bitmap region_size is a power of 2 Jonathan Brassow
2012-12-11 21:49 ` Alasdair G Kergon
2012-12-12 14:53 ` Jonathan Brassow [this message]
2012-12-12 16:10   ` Alasdair G Kergon

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=1355324012.26828.9.camel@f16 \
    --to=jbrassow@redhat.com \
    --cc=agk@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).