Skip to content

Commit c8d5421

Browse files
josefbacikkdave
authored andcommitted
btrfs: use btrfs_tree_block_status for leaf item errors
We have a variety of item specific errors that can occur. For now simply put these under the umbrella of BTRFS_TREE_BLOCK_INVALID_ITEM, this can be fleshed out as we need in the future. Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent a7b4e6c commit c8d5421

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

fs/btrfs/tree-checker.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,9 +1620,10 @@ static int check_inode_ref(struct extent_buffer *leaf,
16201620
/*
16211621
* Common point to switch the item-specific validation.
16221622
*/
1623-
static int check_leaf_item(struct extent_buffer *leaf,
1624-
struct btrfs_key *key, int slot,
1625-
struct btrfs_key *prev_key)
1623+
static enum btrfs_tree_block_status check_leaf_item(struct extent_buffer *leaf,
1624+
struct btrfs_key *key,
1625+
int slot,
1626+
struct btrfs_key *prev_key)
16261627
{
16271628
int ret = 0;
16281629
struct btrfs_chunk *chunk;
@@ -1671,7 +1672,10 @@ static int check_leaf_item(struct extent_buffer *leaf,
16711672
ret = check_extent_data_ref(leaf, key, slot);
16721673
break;
16731674
}
1674-
return ret;
1675+
1676+
if (ret)
1677+
return BTRFS_TREE_BLOCK_INVALID_ITEM;
1678+
return BTRFS_TREE_BLOCK_CLEAN;
16751679
}
16761680

16771681
int btrfs_check_leaf(struct extent_buffer *leaf)
@@ -1751,7 +1755,6 @@ int btrfs_check_leaf(struct extent_buffer *leaf)
17511755
for (slot = 0; slot < nritems; slot++) {
17521756
u32 item_end_expected;
17531757
u64 item_data_end;
1754-
int ret;
17551758

17561759
btrfs_item_key_to_cpu(leaf, &key, slot);
17571760

@@ -1812,13 +1815,15 @@ int btrfs_check_leaf(struct extent_buffer *leaf)
18121815
* may be in some intermediate state and won't appear valid.
18131816
*/
18141817
if (btrfs_header_flag(leaf, BTRFS_HEADER_FLAG_WRITTEN)) {
1818+
enum btrfs_tree_block_status ret;
1819+
18151820
/*
18161821
* Check if the item size and content meet other
18171822
* criteria
18181823
*/
18191824
ret = check_leaf_item(leaf, &key, slot, &prev_key);
1820-
if (unlikely(ret < 0))
1821-
return ret;
1825+
if (unlikely(ret != BTRFS_TREE_BLOCK_CLEAN))
1826+
return -EUCLEAN;
18221827
}
18231828

18241829
prev_key.objectid = key.objectid;

0 commit comments

Comments
 (0)