[PATCH] dm: era: use do_div for 64-bit division

From: Arnd Bergmann
Date: Tue Mar 11 2014 - 04:31:49 EST


Commit 983043be0c1de "dm era: support non power-of-2 blocksize"
introduced the use of sector_div to divide a variable of type
dm_block_t by an integer. This fails on 32-bit machines when
CONFIG_LBDAF is not set, because that assumes that the first
argument is a 32-bit number.

To allow building this driver in all configurations, we either
have to cast the dm_block_t to sector_t or use do_div(), which
always takes a 64-bit argument. This patch uses the second
approach in order to cope with theoretical configurations where
dm_block_t contains a number that does not fit into sector_t.

Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
Cc: Mike Snitzer <snitzer@xxxxxxxxxx>
Cc: Joe Thornber <ejt@xxxxxxxxxx>
Cc: Alasdair Kergon <agk@xxxxxxxxxx>
Cc: dm-devel@xxxxxxxxxx
---
This currently only occurs in linux-next. Please apply.

diff --git a/drivers/md/dm-era-target.c b/drivers/md/dm-era-target.c
index d7bd7b3..3383423 100644
--- a/drivers/md/dm-era-target.c
+++ b/drivers/md/dm-era-target.c
@@ -1123,7 +1123,7 @@ static dm_block_t get_block(struct era *era, struct bio *bio)
dm_block_t block_nr = bio->bi_iter.bi_sector;

if (!block_size_is_power_of_two(era))
- (void) sector_div(block_nr, era->sectors_per_block);
+ (void) do_div(block_nr, era->sectors_per_block);
else
block_nr >>= era->sectors_per_block_shift;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/