All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] btrfs: re-define btrfs_raid_types
@ 2021-10-27  5:28 Qu Wenruo
  2021-10-27  5:28 ` [PATCH v2 1/2] btrfs: move definition of btrfs_raid_types to volumes.h Qu Wenruo
  2021-10-27  5:28 ` [PATCH v2 2/2] btrfs: use ilog2() to replace if () branches for btrfs_bg_flags_to_raid_index() Qu Wenruo
  0 siblings, 2 replies; 13+ messages in thread
From: Qu Wenruo @ 2021-10-27  5:28 UTC (permalink / raw)
  To: linux-btrfs

By the nature of BTRFS_BLOCK_GROUP_* profiles, converting the flag into
an index should only need one bits AND, one if () check for SINGLE
profile, one right shift to align the values, one ilog2() call which is
normally converted into ffs() assembly code.

But we're using a lot of if () branches to do the convert.

This patch will re-define btrfs_raid_types by:

- Move it to volumes.h
  btrfs_raid_types are only used internally, no need to be exposed
  through UAPI.

- Re-order btrfs_raid_types
  To make them match their value order

- Use ilog2() to convert them into index

- Inline btrfs_bg_flags_to_raid_index()
  It's just 5 assembly commands now.

Changelog:
v2:
- Fix the start value of BTRFS_RAID_RAID0

Qu Wenruo (2):
  btrfs: move definition of btrfs_raid_types to volumes.h
  btrfs: use ilog2() to replace if () branches for
    btrfs_bg_flags_to_raid_index()

 fs/btrfs/space-info.h           |  2 ++
 fs/btrfs/volumes.c              | 26 -----------------------
 fs/btrfs/volumes.h              | 37 ++++++++++++++++++++++++++++++++-
 include/uapi/linux/btrfs_tree.h | 13 ------------
 4 files changed, 38 insertions(+), 40 deletions(-)

-- 
2.33.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-11-02 17:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27  5:28 [PATCH v2 0/2] btrfs: re-define btrfs_raid_types Qu Wenruo
2021-10-27  5:28 ` [PATCH v2 1/2] btrfs: move definition of btrfs_raid_types to volumes.h Qu Wenruo
2021-10-27  5:28 ` [PATCH v2 2/2] btrfs: use ilog2() to replace if () branches for btrfs_bg_flags_to_raid_index() Qu Wenruo
2021-10-27  6:37   ` Nikolay Borisov
2021-10-27  7:41     ` Qu Wenruo
2021-10-27  9:23   ` Anand Jain
2021-10-27 10:41     ` Qu Wenruo
2021-10-28  1:04       ` Anand Jain
2021-10-28  7:10         ` Qu Wenruo
2021-10-28 21:53           ` Anand Jain
2021-10-29 14:11   ` David Sterba
2021-10-29 23:38     ` Qu Wenruo
2021-11-02 17:16       ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.