From: Kevin Corry <kevcorry@us.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: Roland Dreier <roland@topspin.com>,
Benjamin LaHaise <bcrl@kvack.org>,
Alasdair G Kergon <agk@redhat.com>, Andrew Morton <akpm@osdl.org>
Subject: Re: device-mapper: fix TB stripe data corruption
Date: Fri, 21 Jan 2005 15:57:38 -0600 [thread overview]
Message-ID: <200501211557.38764.kevcorry@us.ibm.com> (raw)
In-Reply-To: <52651qqy1s.fsf@topspin.com>
On Friday 21 January 2005 3:20 pm, Roland Dreier wrote:
> Kevin> We have to take a mod of the chunk value and the number of
> Kevin> stripes (which can be a non-power-of-2, so a shift won't
> Kevin> work). It's been my understanding that you couldn't mod a
> Kevin> 64-bit value with a 32-bit value in the kernel.
>
> If I understand you correctly, do_div() (defined in <asm/div64.h>)
> does what you need. Look at asm-generic/div64.h for a good
> description of the precise semantics of do_div().
Thanks for the tip, Roland. That seems to be exactly what we needed. Here's a
different version of Alasdair's patch that changes chunk to 64-bit and uses
do_div().
--
Kevin Corry
kevcorry@us.ibm.com
http://evms.sourceforge.net/
In stripe_map(), change chunk to 64-bit and use do_div to divide and mod by
the number of stripes.
--- diff/drivers/md/dm-stripe.c 2005-01-21 15:55:02.093379864 -0600
+++ source/drivers/md/dm-stripe.c 2005-01-21 15:54:25.400957960 -0600
@@ -173,9 +173,8 @@
struct stripe_c *sc = (struct stripe_c *) ti->private;
sector_t offset = bio->bi_sector - ti->begin;
- uint32_t chunk = (uint32_t) (offset >> sc->chunk_shift);
- uint32_t stripe = chunk % sc->stripes; /* 32bit modulus */
- chunk = chunk / sc->stripes;
+ sector_t chunk = offset >> sc->chunk_shift;
+ uint32_t stripe = do_div(chunk, sc->stripes);
bio->bi_bdev = sc->stripe[stripe].dev->bdev;
bio->bi_sector = sc->stripe[stripe].physical_start +
@@ -210,7 +209,7 @@
static struct target_type stripe_target = {
.name = "striped",
- .version= {1, 0, 1},
+ .version= {1, 0, 2},
.module = THIS_MODULE,
.ctr = stripe_ctr,
.dtr = stripe_dtr,
next prev parent reply other threads:[~2005-01-21 22:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-21 18:12 device-mapper: fix TB stripe data corruption Alasdair G Kergon
2005-01-21 20:33 ` Benjamin LaHaise
2005-01-21 21:12 ` Kevin Corry
2005-01-21 21:20 ` Roland Dreier
2005-01-21 21:57 ` Kevin Corry [this message]
2005-01-22 22:35 ` Alasdair G Kergon
[not found] <41F6A093.1020606@meditprofi.ru>
[not found] ` <200501251448.31769.kevcorry@us.ibm.com>
2005-01-28 0:06 ` Kevin Corry
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=200501211557.38764.kevcorry@us.ibm.com \
--to=kevcorry@us.ibm.com \
--cc=agk@redhat.com \
--cc=akpm@osdl.org \
--cc=bcrl@kvack.org \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@topspin.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.