Skip to content

btrfs: re-define btrfs_raid_types

Qu Wenruo linux-btrfs 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 8 repliesIn review
  2. v22 patches 10 repliesSuperseded
  3. v12 patches 0 repliesSuperseded

Changes in v3 from the cover letter

- Introduce more static sanity checks
They are kinda overkilled, but they are only compile time checks, it should be fine.

- Keep btrfs_bg_flags_to_raid_index() as regular function

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2btrfs: move definition of btrfs_raid_types to volumes.hfs/btrfs/space-info.h fs/btrfs/volumes.h include/uapi/linux/btrfs_tree.h+15 -131 reply
2/2btrfs: use ilog2() to replace if () branches for btrfs_bg_flags_to_raid_index()fs/btrfs/volumes.c fs/btrfs/volumes.h+37 -276 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchJohannes Thumshirn
1/2R-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/2] btrfs: re-define btrfs_raid_types

[CHANGELOG]
Changelog:
v2:
- Fix the start value of BTRFS_RAID_RAID0

v3:
- Introduce more static sanity checks
They are kinda overkilled, but they are only compile time checks, it should be fine.

- Keep btrfs_bg_flags_to_raid_index() as regular function

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

- Extra static_assert()s to make sure RAID0 is always the least significant bit in PROFILE_MASK

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              | 24 ++++++----------------
 fs/btrfs/volumes.h              | 35 +++++++++++++++++++++++++++++++++
 include/uapi/linux/btrfs_tree.h | 13 ------------
 4 files changed, 43 insertions(+), 31 deletions(-)
Signature · 1 line
2.35.1