All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm-stripe: fix size test
@ 2012-06-19  0:57 Mikulas Patocka
  0 siblings, 0 replies; only message in thread
From: Mikulas Patocka @ 2012-06-19  0:57 UTC (permalink / raw)
  To: Alasdair G. Kergon, Mike Snitzer; +Cc: dm-devel

dm-stripe: fix size test

dm-stripe is supposed to test that all the stripes are fully used.
It tests that the number of sectors in the target si divisible by
chunk size and the number of stripes.

However, this check is not sufficient:
For example, suppose that we have target length 30 sectors and the
device consists of 6 stripes, each stripe with 15 sectors.

30 is divisible by both 6 and 15, so the test passes, but the stripes
are not fully used --- only the first two stripes are used.

We must actually test that the number of sectors is divisible by the
chunk size multiplied by the number of stripes.

This patch fixes the test --- it checks that device length is divisible
by the chunk size --- and checks that the resulting quotient is
divisible by the number of stripes (which is equivalent to testing if
device length is divisible by chunk_size * stripes).

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 drivers/md/dm-stripe.c |    1 -
 1 file changed, 1 deletion(-)

Index: linux-3.4.3-fast/drivers/md/dm-stripe.c
===================================================================
--- linux-3.4.3-fast.orig/drivers/md/dm-stripe.c	2012-06-19 02:42:05.000000000 +0200
+++ linux-3.4.3-fast/drivers/md/dm-stripe.c	2012-06-19 02:42:23.000000000 +0200
@@ -125,7 +125,6 @@ static int stripe_ctr(struct dm_target *
 		return -EINVAL;
 	}
 
-	width = ti->len;
 	if (sector_div(width, stripes)) {
 		ti->error = "Target length not divisible by "
 		    "number of stripes";

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-06-19  0:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-19  0:57 [PATCH] dm-stripe: fix size test Mikulas Patocka

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.