mirror of https://gitee.com/openkylin/linux.git
btrfs: tree-checker: get fs_info from eb in chunk_err
We can read fs_info from extent buffer and can drop it from the parameters. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
e2ccd361ef
commit
d001e4a3fe
|
@ -447,13 +447,13 @@ static int check_block_group_item(struct extent_buffer *leaf,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
__printf(5, 6)
|
__printf(4, 5)
|
||||||
__cold
|
__cold
|
||||||
static void chunk_err(const struct btrfs_fs_info *fs_info,
|
static void chunk_err(const struct extent_buffer *leaf,
|
||||||
const struct extent_buffer *leaf,
|
|
||||||
const struct btrfs_chunk *chunk, u64 logical,
|
const struct btrfs_chunk *chunk, u64 logical,
|
||||||
const char *fmt, ...)
|
const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
const struct btrfs_fs_info *fs_info = leaf->fs_info;
|
||||||
bool is_sb;
|
bool is_sb;
|
||||||
struct va_format vaf;
|
struct va_format vaf;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
@ -517,37 +517,37 @@ int btrfs_check_chunk_valid(struct btrfs_fs_info *fs_info,
|
||||||
type = btrfs_chunk_type(leaf, chunk);
|
type = btrfs_chunk_type(leaf, chunk);
|
||||||
|
|
||||||
if (!num_stripes) {
|
if (!num_stripes) {
|
||||||
chunk_err(fs_info, leaf, chunk, logical,
|
chunk_err(leaf, chunk, logical,
|
||||||
"invalid chunk num_stripes, have %u", num_stripes);
|
"invalid chunk num_stripes, have %u", num_stripes);
|
||||||
return -EUCLEAN;
|
return -EUCLEAN;
|
||||||
}
|
}
|
||||||
if (!IS_ALIGNED(logical, fs_info->sectorsize)) {
|
if (!IS_ALIGNED(logical, fs_info->sectorsize)) {
|
||||||
chunk_err(fs_info, leaf, chunk, logical,
|
chunk_err(leaf, chunk, logical,
|
||||||
"invalid chunk logical, have %llu should aligned to %u",
|
"invalid chunk logical, have %llu should aligned to %u",
|
||||||
logical, fs_info->sectorsize);
|
logical, fs_info->sectorsize);
|
||||||
return -EUCLEAN;
|
return -EUCLEAN;
|
||||||
}
|
}
|
||||||
if (btrfs_chunk_sector_size(leaf, chunk) != fs_info->sectorsize) {
|
if (btrfs_chunk_sector_size(leaf, chunk) != fs_info->sectorsize) {
|
||||||
chunk_err(fs_info, leaf, chunk, logical,
|
chunk_err(leaf, chunk, logical,
|
||||||
"invalid chunk sectorsize, have %u expect %u",
|
"invalid chunk sectorsize, have %u expect %u",
|
||||||
btrfs_chunk_sector_size(leaf, chunk),
|
btrfs_chunk_sector_size(leaf, chunk),
|
||||||
fs_info->sectorsize);
|
fs_info->sectorsize);
|
||||||
return -EUCLEAN;
|
return -EUCLEAN;
|
||||||
}
|
}
|
||||||
if (!length || !IS_ALIGNED(length, fs_info->sectorsize)) {
|
if (!length || !IS_ALIGNED(length, fs_info->sectorsize)) {
|
||||||
chunk_err(fs_info, leaf, chunk, logical,
|
chunk_err(leaf, chunk, logical,
|
||||||
"invalid chunk length, have %llu", length);
|
"invalid chunk length, have %llu", length);
|
||||||
return -EUCLEAN;
|
return -EUCLEAN;
|
||||||
}
|
}
|
||||||
if (!is_power_of_2(stripe_len) || stripe_len != BTRFS_STRIPE_LEN) {
|
if (!is_power_of_2(stripe_len) || stripe_len != BTRFS_STRIPE_LEN) {
|
||||||
chunk_err(fs_info, leaf, chunk, logical,
|
chunk_err(leaf, chunk, logical,
|
||||||
"invalid chunk stripe length: %llu",
|
"invalid chunk stripe length: %llu",
|
||||||
stripe_len);
|
stripe_len);
|
||||||
return -EUCLEAN;
|
return -EUCLEAN;
|
||||||
}
|
}
|
||||||
if (~(BTRFS_BLOCK_GROUP_TYPE_MASK | BTRFS_BLOCK_GROUP_PROFILE_MASK) &
|
if (~(BTRFS_BLOCK_GROUP_TYPE_MASK | BTRFS_BLOCK_GROUP_PROFILE_MASK) &
|
||||||
type) {
|
type) {
|
||||||
chunk_err(fs_info, leaf, chunk, logical,
|
chunk_err(leaf, chunk, logical,
|
||||||
"unrecognized chunk type: 0x%llx",
|
"unrecognized chunk type: 0x%llx",
|
||||||
~(BTRFS_BLOCK_GROUP_TYPE_MASK |
|
~(BTRFS_BLOCK_GROUP_TYPE_MASK |
|
||||||
BTRFS_BLOCK_GROUP_PROFILE_MASK) &
|
BTRFS_BLOCK_GROUP_PROFILE_MASK) &
|
||||||
|
@ -557,13 +557,13 @@ int btrfs_check_chunk_valid(struct btrfs_fs_info *fs_info,
|
||||||
|
|
||||||
if (!is_power_of_2(type & BTRFS_BLOCK_GROUP_PROFILE_MASK) &&
|
if (!is_power_of_2(type & BTRFS_BLOCK_GROUP_PROFILE_MASK) &&
|
||||||
(type & BTRFS_BLOCK_GROUP_PROFILE_MASK) != 0) {
|
(type & BTRFS_BLOCK_GROUP_PROFILE_MASK) != 0) {
|
||||||
chunk_err(fs_info, 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",
|
||||||
type & BTRFS_BLOCK_GROUP_PROFILE_MASK);
|
type & BTRFS_BLOCK_GROUP_PROFILE_MASK);
|
||||||
return -EUCLEAN;
|
return -EUCLEAN;
|
||||||
}
|
}
|
||||||
if ((type & BTRFS_BLOCK_GROUP_TYPE_MASK) == 0) {
|
if ((type & BTRFS_BLOCK_GROUP_TYPE_MASK) == 0) {
|
||||||
chunk_err(fs_info, leaf, chunk, logical,
|
chunk_err(leaf, chunk, logical,
|
||||||
"missing chunk type flag, have 0x%llx one bit must be set in 0x%llx",
|
"missing chunk type flag, have 0x%llx one bit must be set in 0x%llx",
|
||||||
type, BTRFS_BLOCK_GROUP_TYPE_MASK);
|
type, BTRFS_BLOCK_GROUP_TYPE_MASK);
|
||||||
return -EUCLEAN;
|
return -EUCLEAN;
|
||||||
|
@ -571,7 +571,7 @@ int btrfs_check_chunk_valid(struct btrfs_fs_info *fs_info,
|
||||||
|
|
||||||
if ((type & BTRFS_BLOCK_GROUP_SYSTEM) &&
|
if ((type & BTRFS_BLOCK_GROUP_SYSTEM) &&
|
||||||
(type & (BTRFS_BLOCK_GROUP_METADATA | BTRFS_BLOCK_GROUP_DATA))) {
|
(type & (BTRFS_BLOCK_GROUP_METADATA | BTRFS_BLOCK_GROUP_DATA))) {
|
||||||
chunk_err(fs_info, leaf, chunk, logical,
|
chunk_err(leaf, chunk, logical,
|
||||||
"system chunk with data or metadata type: 0x%llx",
|
"system chunk with data or metadata type: 0x%llx",
|
||||||
type);
|
type);
|
||||||
return -EUCLEAN;
|
return -EUCLEAN;
|
||||||
|
@ -584,7 +584,7 @@ int btrfs_check_chunk_valid(struct btrfs_fs_info *fs_info,
|
||||||
if (!mixed) {
|
if (!mixed) {
|
||||||
if ((type & BTRFS_BLOCK_GROUP_METADATA) &&
|
if ((type & BTRFS_BLOCK_GROUP_METADATA) &&
|
||||||
(type & BTRFS_BLOCK_GROUP_DATA)) {
|
(type & BTRFS_BLOCK_GROUP_DATA)) {
|
||||||
chunk_err(fs_info, leaf, chunk, logical,
|
chunk_err(leaf, chunk, logical,
|
||||||
"mixed chunk type in non-mixed mode: 0x%llx", type);
|
"mixed chunk type in non-mixed mode: 0x%llx", type);
|
||||||
return -EUCLEAN;
|
return -EUCLEAN;
|
||||||
}
|
}
|
||||||
|
@ -596,7 +596,7 @@ int btrfs_check_chunk_valid(struct btrfs_fs_info *fs_info,
|
||||||
(type & BTRFS_BLOCK_GROUP_RAID6 && num_stripes < 3) ||
|
(type & BTRFS_BLOCK_GROUP_RAID6 && num_stripes < 3) ||
|
||||||
(type & BTRFS_BLOCK_GROUP_DUP && num_stripes != 2) ||
|
(type & BTRFS_BLOCK_GROUP_DUP && num_stripes != 2) ||
|
||||||
((type & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0 && num_stripes != 1)) {
|
((type & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0 && num_stripes != 1)) {
|
||||||
chunk_err(fs_info, leaf, chunk, logical,
|
chunk_err(leaf, chunk, logical,
|
||||||
"invalid num_stripes:sub_stripes %u:%u for profile %llu",
|
"invalid num_stripes:sub_stripes %u:%u for profile %llu",
|
||||||
num_stripes, sub_stripes,
|
num_stripes, sub_stripes,
|
||||||
type & BTRFS_BLOCK_GROUP_PROFILE_MASK);
|
type & BTRFS_BLOCK_GROUP_PROFILE_MASK);
|
||||||
|
|
Loading…
Reference in New Issue