diff options
author | Joe Thornber <ejt@redhat.com> | 2013-03-20 13:21:25 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2013-03-20 13:21:25 -0400 |
commit | 414dd67d50a6b9a11af23bbb68e8fae13d726c8b (patch) | |
tree | 3a8978760d54eb1f50f524ca66f1273c4d864c82 /drivers/md | |
parent | 3b6b7813b198b578aa7e04e4047ddb8225c37b7f (diff) |
dm cache: avoid 64 bit division on 32 bit
Squash various 32bit link errors.
>> on i386:
>> drivers/built-in.o: In function `is_discarded_oblock':
>> dm-cache-target.c:(.text+0x1ea28e): undefined reference to `__udivdi3'
...
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/dm-cache-target.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c index 0f4e84b15c30..5ad227f0cea3 100644 --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c | |||
@@ -158,7 +158,7 @@ struct cache { | |||
158 | /* | 158 | /* |
159 | * origin_blocks entries, discarded if set. | 159 | * origin_blocks entries, discarded if set. |
160 | */ | 160 | */ |
161 | sector_t discard_block_size; /* a power of 2 times sectors per block */ | 161 | uint32_t discard_block_size; /* a power of 2 times sectors per block */ |
162 | dm_dblock_t discard_nr_blocks; | 162 | dm_dblock_t discard_nr_blocks; |
163 | unsigned long *discard_bitset; | 163 | unsigned long *discard_bitset; |
164 | 164 | ||
@@ -412,17 +412,24 @@ static bool block_size_is_power_of_two(struct cache *cache) | |||
412 | return cache->sectors_per_block_shift >= 0; | 412 | return cache->sectors_per_block_shift >= 0; |
413 | } | 413 | } |
414 | 414 | ||
415 | static dm_block_t block_div(dm_block_t b, uint32_t n) | ||
416 | { | ||
417 | do_div(b, n); | ||
418 | |||
419 | return b; | ||
420 | } | ||
421 | |||
415 | static dm_dblock_t oblock_to_dblock(struct cache *cache, dm_oblock_t oblock) | 422 | static dm_dblock_t oblock_to_dblock(struct cache *cache, dm_oblock_t oblock) |
416 | { | 423 | { |
417 | sector_t discard_blocks = cache->discard_block_size; | 424 | uint32_t discard_blocks = cache->discard_block_size; |
418 | dm_block_t b = from_oblock(oblock); | 425 | dm_block_t b = from_oblock(oblock); |
419 | 426 | ||
420 | if (!block_size_is_power_of_two(cache)) | 427 | if (!block_size_is_power_of_two(cache)) |
421 | (void) sector_div(discard_blocks, cache->sectors_per_block); | 428 | discard_blocks = discard_blocks / cache->sectors_per_block; |
422 | else | 429 | else |
423 | discard_blocks >>= cache->sectors_per_block_shift; | 430 | discard_blocks >>= cache->sectors_per_block_shift; |
424 | 431 | ||
425 | (void) sector_div(b, discard_blocks); | 432 | b = block_div(b, discard_blocks); |
426 | 433 | ||
427 | return to_dblock(b); | 434 | return to_dblock(b); |
428 | } | 435 | } |
@@ -1002,7 +1009,7 @@ static void process_discard_bio(struct cache *cache, struct bio *bio) | |||
1002 | dm_block_t end_block = bio->bi_sector + bio_sectors(bio); | 1009 | dm_block_t end_block = bio->bi_sector + bio_sectors(bio); |
1003 | dm_block_t b; | 1010 | dm_block_t b; |
1004 | 1011 | ||
1005 | (void) sector_div(end_block, cache->discard_block_size); | 1012 | end_block = block_div(end_block, cache->discard_block_size); |
1006 | 1013 | ||
1007 | for (b = start_block; b < end_block; b++) | 1014 | for (b = start_block; b < end_block; b++) |
1008 | set_discard(cache, to_dblock(b)); | 1015 | set_discard(cache, to_dblock(b)); |
@@ -1835,7 +1842,7 @@ static int cache_create(struct cache_args *ca, struct cache **result) | |||
1835 | 1842 | ||
1836 | /* FIXME: factor out this whole section */ | 1843 | /* FIXME: factor out this whole section */ |
1837 | origin_blocks = cache->origin_sectors = ca->origin_sectors; | 1844 | origin_blocks = cache->origin_sectors = ca->origin_sectors; |
1838 | (void) sector_div(origin_blocks, ca->block_size); | 1845 | origin_blocks = block_div(origin_blocks, ca->block_size); |
1839 | cache->origin_blocks = to_oblock(origin_blocks); | 1846 | cache->origin_blocks = to_oblock(origin_blocks); |
1840 | 1847 | ||
1841 | cache->sectors_per_block = ca->block_size; | 1848 | cache->sectors_per_block = ca->block_size; |
@@ -1848,7 +1855,7 @@ static int cache_create(struct cache_args *ca, struct cache **result) | |||
1848 | dm_block_t cache_size = ca->cache_sectors; | 1855 | dm_block_t cache_size = ca->cache_sectors; |
1849 | 1856 | ||
1850 | cache->sectors_per_block_shift = -1; | 1857 | cache->sectors_per_block_shift = -1; |
1851 | (void) sector_div(cache_size, ca->block_size); | 1858 | cache_size = block_div(cache_size, ca->block_size); |
1852 | cache->cache_size = to_cblock(cache_size); | 1859 | cache->cache_size = to_cblock(cache_size); |
1853 | } else { | 1860 | } else { |
1854 | cache->sectors_per_block_shift = __ffs(ca->block_size); | 1861 | cache->sectors_per_block_shift = __ffs(ca->block_size); |