Skip to content

btrfs: enhance BTRFS_ORDERED_* flags sanity checks

Qu Wenruo linux-btrfs 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 1 replyIn review
  2. v12 patches 3 repliesSuperseded

Changes in v2 from the cover letter

- Minor grammar fixes
- Change the output message when overlapping OEs are found
- Use has_single_bit_set() to replace hweight*()

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2btrfs: check type flags in alloc_ordered_extent()fs/btrfs/ordered-data.c fs/btrfs/ordered-data.h+44 -240 replies
2/2btrfs: output more info when duplicated ordered extent is foundfs/btrfs/ordered-data.c+8 -30 replies

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchDavid Sterba
SeriesR-b
1/2
2/2

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

Read the v2 thread

Cover letter [PATCH v2 0/2] btrfs: enhance BTRFS_ORDERED_* flags sanity checks

[CHANGELOG]
v2:
- Minor grammar fixes
- Change the output message when overlapping OEs are found
- Use has_single_bit_set() to replace hweight*()

During my development of introduce a new DELAYED type, I incorrectly called something like:

	oe = alloc_ordered_extent(.., BTRFS_ORDERED_DELAYED, ..);

That doesn't trigger any warning at runtime, but will cause unexpected bugs due to the fact that, BTRFS_ORDERED_* can not be directly used as a flag. They are only bit numbers, thus should be utilized with bit operations like "test_bit(BTRFS_ORDERED_DELAYED, ..)".

My stupid bug inspired me to enhance the @flags sanity checks in alloc_ordered_extent().

The first one is to make sure that my stupid bug can always be caught early.

The second one is to enhance the error message when a duplicated OE is found during insert_ordered_extent().

Qu Wenruo (2):
btrfs: check type flags in alloc_ordered_extent()
btrfs: output more info when duplicated ordered extent is found

 fs/btrfs/ordered-data.c | 24 +++++++++++++++---
 fs/btrfs/ordered-data.h | 55 +++++++++++++++++++++++------------------
 2 files changed, 52 insertions(+), 27 deletions(-)
Signature · 1 line
2.53.0