diff options
author | David Sterba <dsterba@suse.com> | 2017-03-31 18:02:48 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-08-21 17:47:42 +0200 |
commit | 7736b0a4313c936dc8ccb87e8acf447e12ae2fd1 (patch) | |
tree | d244bd9fa4e13519f964754bfb1d0a268513f45f /fs | |
parent | btrfs: scrub: use bool for flush_all_writes (diff) | |
download | linux-7736b0a4313c936dc8ccb87e8acf447e12ae2fd1.tar.xz linux-7736b0a4313c936dc8ccb87e8acf447e12ae2fd1.zip |
btrfs: scrub: clean up division in __scrub_mark_bitmap
Use proper helpers for 64bit division and then cast to narrower type.
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/scrub.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 810fce240489..99f3a7e9eb61 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -2620,7 +2620,8 @@ static inline void __scrub_mark_bitmap(struct scrub_parity *sparity, u64 start, u64 len) { u64 offset; - int nsectors; + u64 nsectors64; + u32 nsectors; int sectorsize = sparity->sctx->fs_info->sectorsize; if (len >= sparity->stripe_len) { @@ -2631,7 +2632,10 @@ static inline void __scrub_mark_bitmap(struct scrub_parity *sparity, start -= sparity->logic_start; start = div64_u64_rem(start, sparity->stripe_len, &offset); offset = div_u64(offset, sectorsize); - nsectors = (int)len / sectorsize; + nsectors64 = div_u64(len, sectorsize); + + ASSERT(nsectors64 < UINT_MAX); + nsectors = (u32)nsectors64; if (offset + nsectors <= sparity->nsectors) { bitmap_set(bitmap, offset, nsectors); |