Skip to content

Commit dccb07f

Browse files
committed
Merge tag 'for-6.9-rc7-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fixes from David Sterba: "Two more fixes, both have some visible effects on user space: - add check if quotas are enabled when passing qgroup inheritance info, this affects snapper that could fail to create a snapshot - do check for leaf/node flag WRITTEN earlier so that nodes are completely validated before access, this used to be done by integrity checker but it's been removed and left an unhandled case" * tag 'for-6.9-rc7-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: make sure that WRITTEN is set on all metadata blocks btrfs: qgroup: do not check qgroup inherit if qgroup is disabled
2 parents 3628e03 + e03418a commit dccb07f

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

fs/btrfs/qgroup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3045,6 +3045,8 @@ int btrfs_qgroup_check_inherit(struct btrfs_fs_info *fs_info,
30453045
struct btrfs_qgroup_inherit *inherit,
30463046
size_t size)
30473047
{
3048+
if (!btrfs_qgroup_enabled(fs_info))
3049+
return 0;
30483050
if (inherit->flags & ~BTRFS_QGROUP_INHERIT_FLAGS_SUPP)
30493051
return -EOPNOTSUPP;
30503052
if (size < sizeof(*inherit) || size > PAGE_SIZE)

fs/btrfs/tree-checker.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,6 +1797,11 @@ enum btrfs_tree_block_status __btrfs_check_leaf(struct extent_buffer *leaf)
17971797
return BTRFS_TREE_BLOCK_INVALID_LEVEL;
17981798
}
17991799

1800+
if (unlikely(!btrfs_header_flag(leaf, BTRFS_HEADER_FLAG_WRITTEN))) {
1801+
generic_err(leaf, 0, "invalid flag for leaf, WRITTEN not set");
1802+
return BTRFS_TREE_BLOCK_WRITTEN_NOT_SET;
1803+
}
1804+
18001805
/*
18011806
* Extent buffers from a relocation tree have a owner field that
18021807
* corresponds to the subvolume tree they are based on. So just from an
@@ -1858,6 +1863,7 @@ enum btrfs_tree_block_status __btrfs_check_leaf(struct extent_buffer *leaf)
18581863
for (slot = 0; slot < nritems; slot++) {
18591864
u32 item_end_expected;
18601865
u64 item_data_end;
1866+
enum btrfs_tree_block_status ret;
18611867

18621868
btrfs_item_key_to_cpu(leaf, &key, slot);
18631869

@@ -1913,21 +1919,10 @@ enum btrfs_tree_block_status __btrfs_check_leaf(struct extent_buffer *leaf)
19131919
return BTRFS_TREE_BLOCK_INVALID_OFFSETS;
19141920
}
19151921

1916-
/*
1917-
* We only want to do this if WRITTEN is set, otherwise the leaf
1918-
* may be in some intermediate state and won't appear valid.
1919-
*/
1920-
if (btrfs_header_flag(leaf, BTRFS_HEADER_FLAG_WRITTEN)) {
1921-
enum btrfs_tree_block_status ret;
1922-
1923-
/*
1924-
* Check if the item size and content meet other
1925-
* criteria
1926-
*/
1927-
ret = check_leaf_item(leaf, &key, slot, &prev_key);
1928-
if (unlikely(ret != BTRFS_TREE_BLOCK_CLEAN))
1929-
return ret;
1930-
}
1922+
/* Check if the item size and content meet other criteria. */
1923+
ret = check_leaf_item(leaf, &key, slot, &prev_key);
1924+
if (unlikely(ret != BTRFS_TREE_BLOCK_CLEAN))
1925+
return ret;
19311926

19321927
prev_key.objectid = key.objectid;
19331928
prev_key.type = key.type;
@@ -1957,6 +1952,11 @@ enum btrfs_tree_block_status __btrfs_check_node(struct extent_buffer *node)
19571952
int level = btrfs_header_level(node);
19581953
u64 bytenr;
19591954

1955+
if (unlikely(!btrfs_header_flag(node, BTRFS_HEADER_FLAG_WRITTEN))) {
1956+
generic_err(node, 0, "invalid flag for node, WRITTEN not set");
1957+
return BTRFS_TREE_BLOCK_WRITTEN_NOT_SET;
1958+
}
1959+
19601960
if (unlikely(level <= 0 || level >= BTRFS_MAX_LEVEL)) {
19611961
generic_err(node, 0,
19621962
"invalid level for node, have %d expect [1, %d]",

fs/btrfs/tree-checker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ enum btrfs_tree_block_status {
5353
BTRFS_TREE_BLOCK_INVALID_BLOCKPTR,
5454
BTRFS_TREE_BLOCK_INVALID_ITEM,
5555
BTRFS_TREE_BLOCK_INVALID_OWNER,
56+
BTRFS_TREE_BLOCK_WRITTEN_NOT_SET,
5657
};
5758

5859
/*

0 commit comments

Comments
 (0)