From 2d679fc75678551485df62274edaed452becd16d Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sat, 17 Aug 2013 02:13:15 -0700 Subject: bcache: Stripe size isn't necessarily a power of two Originally I got this right... except that the divides didn't use do_div(), which broke 32 bit kernels. When I went to fix that, I forgot that the raid stripe size usually isn't a power of two... doh Signed-off-by: Kent Overstreet --- drivers/md/bcache/writeback.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'drivers/md/bcache/writeback.h') diff --git a/drivers/md/bcache/writeback.h b/drivers/md/bcache/writeback.h index c91f61bb95b6..34961888b5a9 100644 --- a/drivers/md/bcache/writeback.h +++ b/drivers/md/bcache/writeback.h @@ -18,16 +18,18 @@ static inline bool bcache_dev_stripe_dirty(struct bcache_device *d, uint64_t offset, unsigned nr_sectors) { - uint64_t stripe = offset >> d->stripe_size_bits; + uint64_t stripe = offset; + + do_div(stripe, d->stripe_size); while (1) { if (atomic_read(d->stripe_sectors_dirty + stripe)) return true; - if (nr_sectors <= 1 << d->stripe_size_bits) + if (nr_sectors <= d->stripe_size) return false; - nr_sectors -= 1 << d->stripe_size_bits; + nr_sectors -= d->stripe_size; stripe++; } } -- cgit v1.2.3