mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-07 15:18:15 +00:00
btrfs: use has_single_bit_set for clarity
Replace is_power_of_2 with the helper that is self-documenting and remove the open coded call in alloc_profile_is_valid. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
79c8264e44
commit
c1499166d1
2 changed files with 9 additions and 13 deletions
|
@ -23,6 +23,7 @@
|
||||||
#include "disk-io.h"
|
#include "disk-io.h"
|
||||||
#include "compression.h"
|
#include "compression.h"
|
||||||
#include "volumes.h"
|
#include "volumes.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Error message should follow the following format:
|
* Error message should follow the following format:
|
||||||
|
@ -632,7 +633,7 @@ int btrfs_check_chunk_valid(struct extent_buffer *leaf,
|
||||||
return -EUCLEAN;
|
return -EUCLEAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_power_of_2(type & BTRFS_BLOCK_GROUP_PROFILE_MASK) &&
|
if (!has_single_bit_set(type & BTRFS_BLOCK_GROUP_PROFILE_MASK) &&
|
||||||
(type & BTRFS_BLOCK_GROUP_PROFILE_MASK) != 0) {
|
(type & BTRFS_BLOCK_GROUP_PROFILE_MASK) != 0) {
|
||||||
chunk_err(leaf, chunk, logical,
|
chunk_err(leaf, chunk, logical,
|
||||||
"invalid chunk profile flag: 0x%llx, expect 0 or 1 bit set",
|
"invalid chunk profile flag: 0x%llx, expect 0 or 1 bit set",
|
||||||
|
@ -808,11 +809,11 @@ static int check_inode_item(struct extent_buffer *leaf,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* S_IFMT is not bit mapped so we can't completely rely on is_power_of_2,
|
* S_IFMT is not bit mapped so we can't completely rely on
|
||||||
* but is_power_of_2() can save us from checking FIFO/CHR/DIR/REG.
|
* is_power_of_2/has_single_bit_set, but it can save us from checking
|
||||||
* Only needs to check BLK, LNK and SOCKS
|
* FIFO/CHR/DIR/REG. Only needs to check BLK, LNK and SOCKS
|
||||||
*/
|
*/
|
||||||
if (!is_power_of_2(mode & S_IFMT)) {
|
if (!has_single_bit_set(mode & S_IFMT)) {
|
||||||
if (!S_ISLNK(mode) && !S_ISBLK(mode) && !S_ISSOCK(mode)) {
|
if (!S_ISLNK(mode) && !S_ISBLK(mode) && !S_ISSOCK(mode)) {
|
||||||
inode_item_err(fs_info, leaf, slot,
|
inode_item_err(fs_info, leaf, slot,
|
||||||
"invalid mode: has 0%o expect valid S_IF* bit(s)",
|
"invalid mode: has 0%o expect valid S_IF* bit(s)",
|
||||||
|
@ -1033,7 +1034,7 @@ static int check_extent_item(struct extent_buffer *leaf,
|
||||||
btrfs_super_generation(fs_info->super_copy) + 1);
|
btrfs_super_generation(fs_info->super_copy) + 1);
|
||||||
return -EUCLEAN;
|
return -EUCLEAN;
|
||||||
}
|
}
|
||||||
if (!is_power_of_2(flags & (BTRFS_EXTENT_FLAG_DATA |
|
if (!has_single_bit_set(flags & (BTRFS_EXTENT_FLAG_DATA |
|
||||||
BTRFS_EXTENT_FLAG_TREE_BLOCK))) {
|
BTRFS_EXTENT_FLAG_TREE_BLOCK))) {
|
||||||
extent_err(leaf, slot,
|
extent_err(leaf, slot,
|
||||||
"invalid extent flag, have 0x%llx expect 1 bit set in 0x%llx",
|
"invalid extent flag, have 0x%llx expect 1 bit set in 0x%llx",
|
||||||
|
|
|
@ -3844,12 +3844,7 @@ static int alloc_profile_is_valid(u64 flags, int extended)
|
||||||
if (flags == 0)
|
if (flags == 0)
|
||||||
return !extended; /* "0" is valid for usual profiles */
|
return !extended; /* "0" is valid for usual profiles */
|
||||||
|
|
||||||
/* true if exactly one bit set */
|
return has_single_bit_set(flags);
|
||||||
/*
|
|
||||||
* Don't use is_power_of_2(unsigned long) because it won't work
|
|
||||||
* for the single profile (1ULL << 48) on 32-bit CPUs.
|
|
||||||
*/
|
|
||||||
return flags != 0 && (flags & (flags - 1)) == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int balance_need_close(struct btrfs_fs_info *fs_info)
|
static inline int balance_need_close(struct btrfs_fs_info *fs_info)
|
||||||
|
|
Loading…
Add table
Reference in a new issue