@@ -442,7 +442,7 @@ static int __ext4_ext_check(const char *function, unsigned int line,
442442 int depth , ext4_fsblk_t pblk )
443443{
444444 const char * error_msg ;
445- int max = 0 ;
445+ int max = 0 , err = - EFSCORRUPTED ;
446446
447447 if (unlikely (eh -> eh_magic != EXT4_EXT_MAGIC )) {
448448 error_msg = "invalid magic" ;
@@ -473,6 +473,7 @@ static int __ext4_ext_check(const char *function, unsigned int line,
473473 if (ext_depth (inode ) != depth &&
474474 !ext4_extent_block_csum_verify (inode , eh )) {
475475 error_msg = "extent tree corrupted" ;
476+ err = - EFSBADCRC ;
476477 goto corrupted ;
477478 }
478479 return 0 ;
@@ -485,7 +486,7 @@ static int __ext4_ext_check(const char *function, unsigned int line,
485486 le16_to_cpu (eh -> eh_magic ),
486487 le16_to_cpu (eh -> eh_entries ), le16_to_cpu (eh -> eh_max ),
487488 max , le16_to_cpu (eh -> eh_depth ), depth );
488- return - EIO ;
489+ return err ;
489490}
490491
491492#define ext4_ext_check (inode , eh , depth , pblk ) \
@@ -910,7 +911,7 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block,
910911 put_bh (bh );
911912 EXT4_ERROR_INODE (inode ,
912913 "ppos %d > depth %d" , ppos , depth );
913- ret = - EIO ;
914+ ret = - EFSCORRUPTED ;
914915 goto err ;
915916 }
916917 path [ppos ].p_bh = bh ;
@@ -959,7 +960,7 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
959960 EXT4_ERROR_INODE (inode ,
960961 "logical %d == ei_block %d!" ,
961962 logical , le32_to_cpu (curp -> p_idx -> ei_block ));
962- return - EIO ;
963+ return - EFSCORRUPTED ;
963964 }
964965
965966 if (unlikely (le16_to_cpu (curp -> p_hdr -> eh_entries )
@@ -968,7 +969,7 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
968969 "eh_entries %d >= eh_max %d!" ,
969970 le16_to_cpu (curp -> p_hdr -> eh_entries ),
970971 le16_to_cpu (curp -> p_hdr -> eh_max ));
971- return - EIO ;
972+ return - EFSCORRUPTED ;
972973 }
973974
974975 if (logical > le32_to_cpu (curp -> p_idx -> ei_block )) {
@@ -992,7 +993,7 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
992993
993994 if (unlikely (ix > EXT_MAX_INDEX (curp -> p_hdr ))) {
994995 EXT4_ERROR_INODE (inode , "ix > EXT_MAX_INDEX!" );
995- return - EIO ;
996+ return - EFSCORRUPTED ;
996997 }
997998
998999 ix -> ei_block = cpu_to_le32 (logical );
@@ -1001,7 +1002,7 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
10011002
10021003 if (unlikely (ix > EXT_LAST_INDEX (curp -> p_hdr ))) {
10031004 EXT4_ERROR_INODE (inode , "ix > EXT_LAST_INDEX!" );
1004- return - EIO ;
1005+ return - EFSCORRUPTED ;
10051006 }
10061007
10071008 err = ext4_ext_dirty (handle , inode , curp );
@@ -1042,7 +1043,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
10421043 * border from split point */
10431044 if (unlikely (path [depth ].p_ext > EXT_MAX_EXTENT (path [depth ].p_hdr ))) {
10441045 EXT4_ERROR_INODE (inode , "p_ext > EXT_MAX_EXTENT!" );
1045- return - EIO ;
1046+ return - EFSCORRUPTED ;
10461047 }
10471048 if (path [depth ].p_ext != EXT_MAX_EXTENT (path [depth ].p_hdr )) {
10481049 border = path [depth ].p_ext [1 ].ee_block ;
@@ -1086,7 +1087,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
10861087 newblock = ablocks [-- a ];
10871088 if (unlikely (newblock == 0 )) {
10881089 EXT4_ERROR_INODE (inode , "newblock == 0!" );
1089- err = - EIO ;
1090+ err = - EFSCORRUPTED ;
10901091 goto cleanup ;
10911092 }
10921093 bh = sb_getblk_gfp (inode -> i_sb , newblock , __GFP_MOVABLE | GFP_NOFS );
@@ -1112,7 +1113,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
11121113 EXT4_ERROR_INODE (inode , "eh_entries %d != eh_max %d!" ,
11131114 path [depth ].p_hdr -> eh_entries ,
11141115 path [depth ].p_hdr -> eh_max );
1115- err = - EIO ;
1116+ err = - EFSCORRUPTED ;
11161117 goto cleanup ;
11171118 }
11181119 /* start copy from next extent */
@@ -1151,7 +1152,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
11511152 k = depth - at - 1 ;
11521153 if (unlikely (k < 0 )) {
11531154 EXT4_ERROR_INODE (inode , "k %d < 0!" , k );
1154- err = - EIO ;
1155+ err = - EFSCORRUPTED ;
11551156 goto cleanup ;
11561157 }
11571158 if (k )
@@ -1191,7 +1192,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
11911192 EXT4_ERROR_INODE (inode ,
11921193 "EXT_MAX_INDEX != EXT_LAST_INDEX ee_block %d!" ,
11931194 le32_to_cpu (path [i ].p_ext -> ee_block ));
1194- err = - EIO ;
1195+ err = - EFSCORRUPTED ;
11951196 goto cleanup ;
11961197 }
11971198 /* start copy indexes */
@@ -1425,7 +1426,7 @@ static int ext4_ext_search_left(struct inode *inode,
14251426
14261427 if (unlikely (path == NULL )) {
14271428 EXT4_ERROR_INODE (inode , "path == NULL *logical %d!" , * logical );
1428- return - EIO ;
1429+ return - EFSCORRUPTED ;
14291430 }
14301431 depth = path -> p_depth ;
14311432 * phys = 0 ;
@@ -1444,7 +1445,7 @@ static int ext4_ext_search_left(struct inode *inode,
14441445 EXT4_ERROR_INODE (inode ,
14451446 "EXT_FIRST_EXTENT != ex *logical %d ee_block %d!" ,
14461447 * logical , le32_to_cpu (ex -> ee_block ));
1447- return - EIO ;
1448+ return - EFSCORRUPTED ;
14481449 }
14491450 while (-- depth >= 0 ) {
14501451 ix = path [depth ].p_idx ;
@@ -1455,7 +1456,7 @@ static int ext4_ext_search_left(struct inode *inode,
14551456 EXT_FIRST_INDEX (path [depth ].p_hdr ) != NULL ?
14561457 le32_to_cpu (EXT_FIRST_INDEX (path [depth ].p_hdr )-> ei_block ) : 0 ,
14571458 depth );
1458- return - EIO ;
1459+ return - EFSCORRUPTED ;
14591460 }
14601461 }
14611462 return 0 ;
@@ -1465,7 +1466,7 @@ static int ext4_ext_search_left(struct inode *inode,
14651466 EXT4_ERROR_INODE (inode ,
14661467 "logical %d < ee_block %d + ee_len %d!" ,
14671468 * logical , le32_to_cpu (ex -> ee_block ), ee_len );
1468- return - EIO ;
1469+ return - EFSCORRUPTED ;
14691470 }
14701471
14711472 * logical = le32_to_cpu (ex -> ee_block ) + ee_len - 1 ;
@@ -1495,7 +1496,7 @@ static int ext4_ext_search_right(struct inode *inode,
14951496
14961497 if (unlikely (path == NULL )) {
14971498 EXT4_ERROR_INODE (inode , "path == NULL *logical %d!" , * logical );
1498- return - EIO ;
1499+ return - EFSCORRUPTED ;
14991500 }
15001501 depth = path -> p_depth ;
15011502 * phys = 0 ;
@@ -1514,15 +1515,15 @@ static int ext4_ext_search_right(struct inode *inode,
15141515 EXT4_ERROR_INODE (inode ,
15151516 "first_extent(path[%d].p_hdr) != ex" ,
15161517 depth );
1517- return - EIO ;
1518+ return - EFSCORRUPTED ;
15181519 }
15191520 while (-- depth >= 0 ) {
15201521 ix = path [depth ].p_idx ;
15211522 if (unlikely (ix != EXT_FIRST_INDEX (path [depth ].p_hdr ))) {
15221523 EXT4_ERROR_INODE (inode ,
15231524 "ix != EXT_FIRST_INDEX *logical %d!" ,
15241525 * logical );
1525- return - EIO ;
1526+ return - EFSCORRUPTED ;
15261527 }
15271528 }
15281529 goto found_extent ;
@@ -1532,7 +1533,7 @@ static int ext4_ext_search_right(struct inode *inode,
15321533 EXT4_ERROR_INODE (inode ,
15331534 "logical %d < ee_block %d + ee_len %d!" ,
15341535 * logical , le32_to_cpu (ex -> ee_block ), ee_len );
1535- return - EIO ;
1536+ return - EFSCORRUPTED ;
15361537 }
15371538
15381539 if (ex != EXT_LAST_EXTENT (path [depth ].p_hdr )) {
@@ -1670,7 +1671,7 @@ static int ext4_ext_correct_indexes(handle_t *handle, struct inode *inode,
16701671 if (unlikely (ex == NULL || eh == NULL )) {
16711672 EXT4_ERROR_INODE (inode ,
16721673 "ex %p == NULL or eh %p == NULL" , ex , eh );
1673- return - EIO ;
1674+ return - EFSCORRUPTED ;
16741675 }
16751676
16761677 if (depth == 0 ) {
@@ -1938,14 +1939,14 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode,
19381939 mb_flags |= EXT4_MB_DELALLOC_RESERVED ;
19391940 if (unlikely (ext4_ext_get_actual_len (newext ) == 0 )) {
19401941 EXT4_ERROR_INODE (inode , "ext4_ext_get_actual_len(newext) == 0" );
1941- return - EIO ;
1942+ return - EFSCORRUPTED ;
19421943 }
19431944 depth = ext_depth (inode );
19441945 ex = path [depth ].p_ext ;
19451946 eh = path [depth ].p_hdr ;
19461947 if (unlikely (path [depth ].p_hdr == NULL )) {
19471948 EXT4_ERROR_INODE (inode , "path[%d].p_hdr == NULL" , depth );
1948- return - EIO ;
1949+ return - EFSCORRUPTED ;
19491950 }
19501951
19511952 /* try to insert block into found extent and return */
@@ -2172,7 +2173,7 @@ static int ext4_fill_fiemap_extents(struct inode *inode,
21722173 if (unlikely (path [depth ].p_hdr == NULL )) {
21732174 up_read (& EXT4_I (inode )-> i_data_sem );
21742175 EXT4_ERROR_INODE (inode , "path[%d].p_hdr == NULL" , depth );
2175- err = - EIO ;
2176+ err = - EFSCORRUPTED ;
21762177 break ;
21772178 }
21782179 ex = path [depth ].p_ext ;
@@ -2241,7 +2242,7 @@ static int ext4_fill_fiemap_extents(struct inode *inode,
22412242
22422243 if (unlikely (es .es_len == 0 )) {
22432244 EXT4_ERROR_INODE (inode , "es.es_len == 0" );
2244- err = - EIO ;
2245+ err = - EFSCORRUPTED ;
22452246 break ;
22462247 }
22472248
@@ -2264,7 +2265,7 @@ static int ext4_fill_fiemap_extents(struct inode *inode,
22642265 "next extent == %u, next "
22652266 "delalloc extent = %u" ,
22662267 next , next_del );
2267- err = - EIO ;
2268+ err = - EFSCORRUPTED ;
22682269 break ;
22692270 }
22702271 }
@@ -2363,7 +2364,7 @@ static int ext4_ext_rm_idx(handle_t *handle, struct inode *inode,
23632364 leaf = ext4_idx_pblock (path -> p_idx );
23642365 if (unlikely (path -> p_hdr -> eh_entries == 0 )) {
23652366 EXT4_ERROR_INODE (inode , "path->p_hdr->eh_entries == 0" );
2366- return - EIO ;
2367+ return - EFSCORRUPTED ;
23672368 }
23682369 err = ext4_ext_get_access (handle , inode , path );
23692370 if (err )
@@ -2612,7 +2613,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
26122613 eh = path [depth ].p_hdr ;
26132614 if (unlikely (path [depth ].p_hdr == NULL )) {
26142615 EXT4_ERROR_INODE (inode , "path[%d].p_hdr == NULL" , depth );
2615- return - EIO ;
2616+ return - EFSCORRUPTED ;
26162617 }
26172618 /* find where to start removing */
26182619 ex = path [depth ].p_ext ;
@@ -2666,7 +2667,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
26662667 "on extent %u:%u" ,
26672668 start , end , ex_ee_block ,
26682669 ex_ee_block + ex_ee_len - 1 );
2669- err = - EIO ;
2670+ err = - EFSCORRUPTED ;
26702671 goto out ;
26712672 } else if (a != ex_ee_block ) {
26722673 /* remove tail of the extent */
@@ -2841,7 +2842,7 @@ int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
28412842 EXT4_ERROR_INODE (inode ,
28422843 "path[%d].p_hdr == NULL" ,
28432844 depth );
2844- err = - EIO ;
2845+ err = - EFSCORRUPTED ;
28452846 }
28462847 goto out ;
28472848 }
@@ -2920,7 +2921,7 @@ int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
29202921 i = 0 ;
29212922
29222923 if (ext4_ext_check (inode , path [0 ].p_hdr , depth , 0 )) {
2923- err = - EIO ;
2924+ err = - EFSCORRUPTED ;
29242925 goto out ;
29252926 }
29262927 }
@@ -2978,7 +2979,7 @@ int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
29782979 * Should be a no-op if we did IO above. */
29792980 cond_resched ();
29802981 if (WARN_ON (i + 1 > depth )) {
2981- err = - EIO ;
2982+ err = - EFSCORRUPTED ;
29822983 break ;
29832984 }
29842985 path [i + 1 ].p_bh = bh ;
@@ -3345,7 +3346,7 @@ static int ext4_split_extent(handle_t *handle,
33453346 if (!ex ) {
33463347 EXT4_ERROR_INODE (inode , "unexpected hole at %lu" ,
33473348 (unsigned long ) map -> m_lblk );
3348- return - EIO ;
3349+ return - EFSCORRUPTED ;
33493350 }
33503351 unwritten = ext4_ext_is_unwritten (ex );
33513352 split_flag1 = 0 ;
@@ -3973,7 +3974,7 @@ convert_initialized_extent(handle_t *handle, struct inode *inode,
39733974 if (!ex ) {
39743975 EXT4_ERROR_INODE (inode , "unexpected hole at %lu" ,
39753976 (unsigned long ) map -> m_lblk );
3976- return - EIO ;
3977+ return - EFSCORRUPTED ;
39773978 }
39783979 }
39793980
@@ -4311,7 +4312,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
43114312 "lblock: %lu, depth: %d pblock %lld" ,
43124313 (unsigned long ) map -> m_lblk , depth ,
43134314 path [depth ].p_block );
4314- err = - EIO ;
4315+ err = - EFSCORRUPTED ;
43154316 goto out2 ;
43164317 }
43174318
@@ -5274,7 +5275,7 @@ ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift,
52745275 if (depth == path -> p_depth ) {
52755276 ex_start = path [depth ].p_ext ;
52765277 if (!ex_start )
5277- return - EIO ;
5278+ return - EFSCORRUPTED ;
52785279
52795280 ex_last = EXT_LAST_EXTENT (path [depth ].p_hdr );
52805281
@@ -5414,7 +5415,7 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
54145415 if (!extent ) {
54155416 EXT4_ERROR_INODE (inode , "unexpected hole at %lu" ,
54165417 (unsigned long ) * iterator );
5417- return - EIO ;
5418+ return - EFSCORRUPTED ;
54185419 }
54195420 if (SHIFT == SHIFT_LEFT && * iterator >
54205421 le32_to_cpu (extent -> ee_block )) {
0 commit comments