@@ -1845,29 +1845,28 @@ int btrfs_check_leaf(struct extent_buffer *leaf)
1845
1845
}
1846
1846
ALLOW_ERROR_INJECTION (btrfs_check_leaf , ERRNO );
1847
1847
1848
- int btrfs_check_node (struct extent_buffer * node )
1848
+ enum btrfs_tree_block_status __btrfs_check_node (struct extent_buffer * node )
1849
1849
{
1850
1850
struct btrfs_fs_info * fs_info = node -> fs_info ;
1851
1851
unsigned long nr = btrfs_header_nritems (node );
1852
1852
struct btrfs_key key , next_key ;
1853
1853
int slot ;
1854
1854
int level = btrfs_header_level (node );
1855
1855
u64 bytenr ;
1856
- int ret = 0 ;
1857
1856
1858
1857
if (unlikely (level <= 0 || level >= BTRFS_MAX_LEVEL )) {
1859
1858
generic_err (node , 0 ,
1860
1859
"invalid level for node, have %d expect [1, %d]" ,
1861
1860
level , BTRFS_MAX_LEVEL - 1 );
1862
- return - EUCLEAN ;
1861
+ return BTRFS_TREE_BLOCK_INVALID_LEVEL ;
1863
1862
}
1864
1863
if (unlikely (nr == 0 || nr > BTRFS_NODEPTRS_PER_BLOCK (fs_info ))) {
1865
1864
btrfs_crit (fs_info ,
1866
1865
"corrupt node: root=%llu block=%llu, nritems too %s, have %lu expect range [1,%u]" ,
1867
1866
btrfs_header_owner (node ), node -> start ,
1868
1867
nr == 0 ? "small" : "large" , nr ,
1869
1868
BTRFS_NODEPTRS_PER_BLOCK (fs_info ));
1870
- return - EUCLEAN ;
1869
+ return BTRFS_TREE_BLOCK_INVALID_NRITEMS ;
1871
1870
}
1872
1871
1873
1872
for (slot = 0 ; slot < nr - 1 ; slot ++ ) {
@@ -1878,15 +1877,13 @@ int btrfs_check_node(struct extent_buffer *node)
1878
1877
if (unlikely (!bytenr )) {
1879
1878
generic_err (node , slot ,
1880
1879
"invalid NULL node pointer" );
1881
- ret = - EUCLEAN ;
1882
- goto out ;
1880
+ return BTRFS_TREE_BLOCK_INVALID_BLOCKPTR ;
1883
1881
}
1884
1882
if (unlikely (!IS_ALIGNED (bytenr , fs_info -> sectorsize ))) {
1885
1883
generic_err (node , slot ,
1886
1884
"unaligned pointer, have %llu should be aligned to %u" ,
1887
1885
bytenr , fs_info -> sectorsize );
1888
- ret = - EUCLEAN ;
1889
- goto out ;
1886
+ return BTRFS_TREE_BLOCK_INVALID_BLOCKPTR ;
1890
1887
}
1891
1888
1892
1889
if (unlikely (btrfs_comp_cpu_keys (& key , & next_key ) >= 0 )) {
@@ -1895,12 +1892,20 @@ int btrfs_check_node(struct extent_buffer *node)
1895
1892
key .objectid , key .type , key .offset ,
1896
1893
next_key .objectid , next_key .type ,
1897
1894
next_key .offset );
1898
- ret = - EUCLEAN ;
1899
- goto out ;
1895
+ return BTRFS_TREE_BLOCK_BAD_KEY_ORDER ;
1900
1896
}
1901
1897
}
1902
- out :
1903
- return ret ;
1898
+ return BTRFS_TREE_BLOCK_CLEAN ;
1899
+ }
1900
+
1901
+ int btrfs_check_node (struct extent_buffer * node )
1902
+ {
1903
+ enum btrfs_tree_block_status ret ;
1904
+
1905
+ ret = __btrfs_check_node (node );
1906
+ if (unlikely (ret != BTRFS_TREE_BLOCK_CLEAN ))
1907
+ return - EUCLEAN ;
1908
+ return 0 ;
1904
1909
}
1905
1910
ALLOW_ERROR_INJECTION (btrfs_check_node , ERRNO );
1906
1911
0 commit comments