From: NeilBrown <neilb@suse.de>
To: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Cc: linux-raid@vger.kernel.org, dan.j.williams@intel.com,
marcin.labun@intel.com, ed.ciechanowski@intel.com
Subject: Re: [PATCH] imsm: fix: does not allow to use invalid chunk size
Date: Tue, 6 Dec 2011 11:56:13 +1100 [thread overview]
Message-ID: <20111206115613.77736d93@notabene.brown> (raw)
In-Reply-To: <20111125121204.662.4111.stgit@linux.site>
[-- Attachment #1: Type: text/plain, Size: 1410 bytes --]
On Fri, 25 Nov 2011 13:12:04 +0100 Przemyslaw Czarnowski
<przemyslaw.hawrylewicz.czarnowski@intel.com> wrote:
> Only least significant bit of chunk size provided by user has been used
> in test with OROM capabilities. This way user could pass value which is
> not a power of 2.
>
> Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
> ---
> platform-intel.h | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/platform-intel.h b/platform-intel.h
> index 6c094d7..99450ba 100644
> --- a/platform-intel.h
> +++ b/platform-intel.h
> @@ -124,11 +124,13 @@ static inline int imsm_orom_has_raid5(const struct imsm_orom *orom)
> static inline int imsm_orom_has_chunk(const struct imsm_orom *orom, int chunk)
> {
> int fs = ffs(chunk);
> + int orom_chunk_bit;
>
> if (!fs)
> return 0;
> fs--; /* bit num to bit index */
> - return !!(orom->sss & (1 << (fs - 1)));
> + orom_chunk_bit = (orom->sss & (1 << (fs - 1)));
> + return orom_chunk_bit && 1 << orom_chunk_bit == chunk;
> }
>
>
applied, thanks.
However it feels a bit clumsy, though maybe that is just me.
I would use a separate explicit test for "is a power of 2".
ie.
if (chunk & (chunk-1))
return 0; /* not a power of 2 */
fs = ffs(chunk);
return !!(orom->sss & (1 << (fs-2)));
or something like that.
NeilBrown
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
next prev parent reply other threads:[~2011-12-06 0:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-25 12:12 [PATCH] imsm: fix: does not allow to use invalid chunk size Przemyslaw Czarnowski
2011-12-06 0:56 ` NeilBrown [this message]
2011-12-06 15:49 ` Hawrylewicz Czarnowski, Przemyslaw
2011-12-07 1:16 ` NeilBrown
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=20111206115613.77736d93@notabene.brown \
--to=neilb@suse.de \
--cc=dan.j.williams@intel.com \
--cc=ed.ciechanowski@intel.com \
--cc=linux-raid@vger.kernel.org \
--cc=marcin.labun@intel.com \
--cc=przemyslaw.hawrylewicz.czarnowski@intel.com \
/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.