btrfs: simplify percent calculation helpers, rename div_factor
authorDavid Sterba <dsterba@suse.com>
Wed, 26 Oct 2022 21:25:14 +0000 (23:25 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 5 Dec 2022 17:00:48 +0000 (18:00 +0100)
commit428c8e03109e717d90e0d1329dc3d926b9421ad3
treeff641f6749860e7305e4cf920d9596f1215b2912
parent20af93d97f46a824647326278df7d377ba3269ff
btrfs: simplify percent calculation helpers, rename div_factor

The div_factor* helpers calculate fraction or percentage fraction. The
name is a bit confusing, we use it only for percentage calculations and
there are two helpers.

There's a helper mult_frac that's for general fractions, that tries to
be accurate but we multiply and divide by small numbers so we can use
the div_u64 helper.

Rename the div_factor* helpers and use 1..100 percentage range, also drop
the case checking for percentage == 100, it's never hit.

The conversions:

* div_factor calculates tenths and the numbers need to be adjusted
* div_factor_fine is direct replacement

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c
fs/btrfs/block-rsv.c
fs/btrfs/block-rsv.h
fs/btrfs/free-space-cache.c
fs/btrfs/misc.h
fs/btrfs/space-info.c
fs/btrfs/sysfs.c
fs/btrfs/transaction.c
fs/btrfs/volumes.c