All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Corry <kevcorry@us.ibm.com>
To: agk@redhat.com, Dmitry Yurtaev <yurtaev@meditprofi.ru>
Cc: DevMapper <dm-devel@redhat.com>
Subject: Re: device-mapper: fix TB stripe data corruption
Date: Thu, 27 Jan 2005 18:06:44 -0600	[thread overview]
Message-ID: <200501271806.44988.kevcorry@us.ibm.com> (raw)
In-Reply-To: <200501251448.31769.kevcorry@us.ibm.com>

On Tuesday 25 January 2005 2:48 pm, Kevin Corry wrote:
> On Tuesday 25 January 2005 1:40 pm, Dmitry Yurtaev wrote:
> > i'm sorry for mailing you directly. i was trying to get lvm2 working
> > with 2 striped 1.8T volumes and came across your patch in the lklm. but
> > it didn't help. after some digging i've found few suspicious functions
> > in dm.h, especially this one:
> >
> > --- file: drivers/md/dm.h
> > static inline unsigned long dm_round_up(unsigned long n, unsigned long
> > size) {
> >          unsigned long r = n % size;
> >          return n + (r ? (size - r) : 0);
> > }
> >
> > it is called from drivers/md/dm.c:max_io_len() with two arguments of
> > sector_t type... i've made an ugly fix:
> >
> > static inline sector_t dm_round_up(sector_t n, unsigned long size)
> > {
> >          sector_t q = n;
> >          sector_t r = sector_div(q, size);
> >          return n + (r ? (size - r) : 0);
> > }
> >
> > and that plus your patch eliminated my problem with data corruption.
> >
> > it would be nice if someone knowlegeable will audit dm.[hc]... also it
> > looks to me like there're few places in dm-stripe.c which assume that a
> > stripe size is <2T...
>
> Here's a patch to implement the above change that you suggested. Thanks for
> the feedback!

Here's a corrected version of the dm.h patch from Tuesday. The previous 
version was missing another sector_div() in dm_div_up(). When I compiled it 
the first time, I had DM built as modules, and it all seemed to build 
correctly. Today I switched DM back to statically built and then noticed a 
compile error.

-- 
Kevin Corry
kevcorry@us.ibm.com
http://evms.sourceforge.net/



Make dm_round_up() and dm_div_up() 64-bit safe.

--- diff/drivers/md/dm.h 2005-01-27 18:00:17.918379224 -0600
+++ source/drivers/md/dm.h 2005-01-27 18:00:37.034473136 -0600
@@ -145,18 +145,21 @@
 /*
  * ceiling(n / size) * size
  */
-static inline unsigned long dm_round_up(unsigned long n, unsigned long size)
+static inline sector_t dm_round_up(sector_t n, unsigned long size)
 {
- unsigned long r = n % size;
+ sector_t q = n;
+ sector_t r = sector_div(q, size);
  return n + (r ? (size - r) : 0);
 }
 
 /*
  * Ceiling(n / size)
  */
-static inline unsigned long dm_div_up(unsigned long n, unsigned long size)
+static inline sector_t dm_div_up(sector_t n, unsigned long size)
 {
- return dm_round_up(n, size) / size;
+ sector_t r = dm_round_up(n, size);
+ sector_div(r, size);
+ return r;
 }
 
 static inline sector_t to_sector(unsigned long n)

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

       reply	other threads:[~2005-01-28  0:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <41F6A093.1020606@meditprofi.ru>
     [not found] ` <200501251448.31769.kevcorry@us.ibm.com>
2005-01-28  0:06   ` Kevin Corry [this message]
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
2005-01-22 22:35         ` 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=200501271806.44988.kevcorry@us.ibm.com \
    --to=kevcorry@us.ibm.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=yurtaev@meditprofi.ru \
    /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.