Skip to contentSkip to conversation

bcache: Fix the bug about cal nr_stripes of backed device

PATCH In review majianpeng 2 participants 2 messages Jan 8, 2014 bcache (block layer cache)

lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH 3/3 bcache: Fix the bug about cal nr_stripes of backed device

In func bcache_device_init(),it use this expression to cal nr_stripes:
"d->nr_stripes = DIV_ROUND_UP_ULL(sectors, d->stripe_size)". But the unit of d->stripe_size is byte,the unit os sectors is sector. So we should replace sectors with "secotrs << 9".

---
 drivers/md/bcache/super.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/super.c +1 -1
index 21f77c1..6394dd6 100644
@@ -769,7 +769,7 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size,
 	if (!d->stripe_size)
 		d->stripe_size = min_t(unsigned, 1 << 31, q->limits.io_opt);
 
-	d->nr_stripes = DIV_ROUND_UP_ULL(sectors, d->stripe_size);
+	d->nr_stripes = DIV_ROUND_UP_ULL(sectors << 9, d->stripe_size);
 
 	if (!d->nr_stripes ||
 	    d->nr_stripes > INT_MAX ||
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 4 lines · majianpeng

In func bcache_device_init(),it use this expression to cal nr_stripes:
"d->nr_stripes = DIV_ROUND_UP_ULL(sectors, d->stripe_size)". But the unit of d->stripe_size is byte,the unit os sectors is sector. So we should replace sectors with "secotrs << 9".

Nope, d->stripe_size is definitely sectors.