Commit cc656619 authored by Scott Bauer's avatar Scott Bauer Committed by Mike Snitzer

dm unstripe: fix target length versus number of stripes size check

Since the unstripe target takes a target length which is the
size of *one* striped member we're trying to expose, not the
total size of *all* the striped members, the check does not
make sense and fails for some striped setups.

For example, say we have a 4TB striped device:
or 3907018496 sectors per underlying device:

if (sector_div(width, uc->stripes)) :
   3907018496 / 2(num stripes)  == 1953509248

tmp_len = width;
if (sector_div(tmp_len, uc->chunk_size)) :
   1953509248 / 256(chunk size) == 7630895.5
   (fails)

Fix this by removing the first check which isn't valid for unstriping.
Signed-off-by: default avatarScott Bauer <scott.bauer@intel.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent bd6d1e0a
...@@ -44,7 +44,7 @@ static void cleanup_unstripe(struct unstripe_c *uc, struct dm_target *ti) ...@@ -44,7 +44,7 @@ static void cleanup_unstripe(struct unstripe_c *uc, struct dm_target *ti)
static int unstripe_ctr(struct dm_target *ti, unsigned int argc, char **argv) static int unstripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
{ {
struct unstripe_c *uc; struct unstripe_c *uc;
sector_t width, tmp_len; sector_t tmp_len;
unsigned long long start; unsigned long long start;
char dummy; char dummy;
...@@ -100,13 +100,7 @@ static int unstripe_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -100,13 +100,7 @@ static int unstripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
uc->unstripe_width = (uc->stripes - 1) * uc->chunk_size; uc->unstripe_width = (uc->stripes - 1) * uc->chunk_size;
uc->chunk_shift = fls(uc->chunk_size) - 1; uc->chunk_shift = fls(uc->chunk_size) - 1;
width = ti->len; tmp_len = ti->len;
if (sector_div(width, uc->stripes)) {
ti->error = "Target length not divisible by number of stripes";
goto err;
}
tmp_len = width;
if (sector_div(tmp_len, uc->chunk_size)) { if (sector_div(tmp_len, uc->chunk_size)) {
ti->error = "Target length not divisible by chunk size"; ti->error = "Target length not divisible by chunk size";
goto err; goto err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment