These shift loops seem to be trying to avoid doing a
multiplication.
The same effect can be achieved more transparently using
rounddown_pow_of_two(). Even though there is a multiplication
in the C code, the resulting machine code just does a single shift.
As rounddown_pow_of_two() is not defined for 0, and as we cannot be
positively use the blk_size is non-zero, use blk_size ?: 1.
Change-Id: Ie4cec1ca3f30617df0022a9c0dd80fe7e755ed64
Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-on: https://review.whamcloud.com/35274
Tested-by: Jenkins
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Shaun Tancheff <stancheff@cray.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
u32 blk_size = osfs.os_bsize >> 10;
u64 result = osfs.os_blocks;
- while (blk_size >>= 1)
- result <<= 1;
-
+ result *= rounddown_pow_of_two(blk_size ?: 1);
return sprintf(buf, "%llu\n", result);
}