aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2015-10-17 16:16:04 -0400
committerTheodore Ts'o <tytso@mit.edu>2015-10-17 16:16:04 -0400
commit6a797d2737838906f2ea0a31686e87c3151e21ca (patch)
treec13f506c771271660fb76d3e0ba86a9e107f0ed9 /fs/ext4
parent8c81bd8f586c46eaf114758a78d82895a2b081c2 (diff)
ext4: call out CRC and corruption errors with specific error codes
Instead of overloading EIO for CRC errors and corrupt structures, return the same error codes that XFS returns for the same issues. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/balloc.c2
-rw-r--r--fs/ext4/block_validity.c2
-rw-r--r--fs/ext4/dir.c4
-rw-r--r--fs/ext4/ext4.h3
-rw-r--r--fs/ext4/extents.c75
-rw-r--r--fs/ext4/ialloc.c1
-rw-r--r--fs/ext4/indirect.c2
-rw-r--r--fs/ext4/inode.c16
-rw-r--r--fs/ext4/mmp.c8
-rw-r--r--fs/ext4/namei.c28
-rw-r--r--fs/ext4/super.c10
-rw-r--r--fs/ext4/symlink.c2
-rw-r--r--fs/ext4/xattr.c28
13 files changed, 98 insertions, 83 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index cd6ea29be645..f831e10a7475 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -203,7 +203,7 @@ static int ext4_init_block_bitmap(struct super_block *sb,
203 count); 203 count);
204 } 204 }
205 set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &grp->bb_state); 205 set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &grp->bb_state);
206 return -EIO; 206 return -EFSBADCRC;
207 } 207 }
208 memset(bh->b_data, 0, sb->s_blocksize); 208 memset(bh->b_data, 0, sb->s_blocksize);
209 209
diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c
index 3522340c7a99..02ddec6d8a7d 100644
--- a/fs/ext4/block_validity.c
+++ b/fs/ext4/block_validity.c
@@ -234,7 +234,7 @@ int ext4_check_blockref(const char *function, unsigned int line,
234 es->s_last_error_block = cpu_to_le64(blk); 234 es->s_last_error_block = cpu_to_le64(blk);
235 ext4_error_inode(inode, function, line, blk, 235 ext4_error_inode(inode, function, line, blk,
236 "invalid block"); 236 "invalid block");
237 return -EIO; 237 return -EFSCORRUPTED;
238 } 238 }
239 } 239 }
240 return 0; 240 return 0;
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index f9e14911918c..b29cb707539f 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -621,14 +621,14 @@ int ext4_check_all_de(struct inode *dir, struct buffer_head *bh, void *buf,
621 while ((char *) de < top) { 621 while ((char *) de < top) {
622 if (ext4_check_dir_entry(dir, NULL, de, bh, 622 if (ext4_check_dir_entry(dir, NULL, de, bh,
623 buf, buf_size, offset)) 623 buf, buf_size, offset))
624 return -EIO; 624 return -EFSCORRUPTED;
625 nlen = EXT4_DIR_REC_LEN(de->name_len); 625 nlen = EXT4_DIR_REC_LEN(de->name_len);
626 rlen = ext4_rec_len_from_disk(de->rec_len, buf_size); 626 rlen = ext4_rec_len_from_disk(de->rec_len, buf_size);
627 de = (struct ext4_dir_entry_2 *)((char *)de + rlen); 627 de = (struct ext4_dir_entry_2 *)((char *)de + rlen);
628 offset += rlen; 628 offset += rlen;
629 } 629 }
630 if ((char *) de > top) 630 if ((char *) de > top)
631 return -EIO; 631 return -EFSCORRUPTED;
632 632
633 return 0; 633 return 0;
634} 634}
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index cd832b99f68c..6c0797346da1 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3064,4 +3064,7 @@ extern void ext4_resize_end(struct super_block *sb);
3064 3064
3065#endif /* __KERNEL__ */ 3065#endif /* __KERNEL__ */
3066 3066
3067#define EFSBADCRC EBADMSG /* Bad CRC detected */
3068#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
3069
3067#endif /* _EXT4_H */ 3070#endif /* _EXT4_H */
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 7f486e350d15..faeaba8582d7 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -442,7 +442,7 @@ static int __ext4_ext_check(const char *function, unsigned int line,
442 int depth, ext4_fsblk_t pblk) 442 int depth, ext4_fsblk_t pblk)
443{ 443{
444 const char *error_msg; 444 const char *error_msg;
445 int max = 0; 445 int max = 0, err = -EFSCORRUPTED;
446 446
447 if (unlikely(eh->eh_magic != EXT4_EXT_MAGIC)) { 447 if (unlikely(eh->eh_magic != EXT4_EXT_MAGIC)) {
448 error_msg = "invalid magic"; 448 error_msg = "invalid magic";
@@ -473,6 +473,7 @@ static int __ext4_ext_check(const char *function, unsigned int line,
473 if (ext_depth(inode) != depth && 473 if (ext_depth(inode) != depth &&
474 !ext4_extent_block_csum_verify(inode, eh)) { 474 !ext4_extent_block_csum_verify(inode, eh)) {
475 error_msg = "extent tree corrupted"; 475 error_msg = "extent tree corrupted";
476 err = -EFSBADCRC;
476 goto corrupted; 477 goto corrupted;
477 } 478 }
478 return 0; 479 return 0;
@@ -485,7 +486,7 @@ corrupted:
485 le16_to_cpu(eh->eh_magic), 486 le16_to_cpu(eh->eh_magic),
486 le16_to_cpu(eh->eh_entries), le16_to_cpu(eh->eh_max), 487 le16_to_cpu(eh->eh_entries), le16_to_cpu(eh->eh_max),
487 max, le16_to_cpu(eh->eh_depth), depth); 488 max, le16_to_cpu(eh->eh_depth), depth);
488 return -EIO; 489 return err;
489} 490}
490 491
491#define ext4_ext_check(inode, eh, depth, pblk) \ 492#define ext4_ext_check(inode, eh, depth, pblk) \
@@ -910,7 +911,7 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block,
910 put_bh(bh); 911 put_bh(bh);
911 EXT4_ERROR_INODE(inode, 912 EXT4_ERROR_INODE(inode,
912 "ppos %d > depth %d", ppos, depth); 913 "ppos %d > depth %d", ppos, depth);
913 ret = -EIO; 914 ret = -EFSCORRUPTED;
914 goto err; 915 goto err;
915 } 916 }
916 path[ppos].p_bh = bh; 917 path[ppos].p_bh = bh;
@@ -959,7 +960,7 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
959 EXT4_ERROR_INODE(inode, 960 EXT4_ERROR_INODE(inode,
960 "logical %d == ei_block %d!", 961 "logical %d == ei_block %d!",
961 logical, le32_to_cpu(curp->p_idx->ei_block)); 962 logical, le32_to_cpu(curp->p_idx->ei_block));
962 return -EIO; 963 return -EFSCORRUPTED;
963 } 964 }
964 965
965 if (unlikely(le16_to_cpu(curp->p_hdr->eh_entries) 966 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,
968 "eh_entries %d >= eh_max %d!", 969 "eh_entries %d >= eh_max %d!",
969 le16_to_cpu(curp->p_hdr->eh_entries), 970 le16_to_cpu(curp->p_hdr->eh_entries),
970 le16_to_cpu(curp->p_hdr->eh_max)); 971 le16_to_cpu(curp->p_hdr->eh_max));
971 return -EIO; 972 return -EFSCORRUPTED;
972 } 973 }
973 974
974 if (logical > le32_to_cpu(curp->p_idx->ei_block)) { 975 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,
992 993
993 if (unlikely(ix > EXT_MAX_INDEX(curp->p_hdr))) { 994 if (unlikely(ix > EXT_MAX_INDEX(curp->p_hdr))) {
994 EXT4_ERROR_INODE(inode, "ix > EXT_MAX_INDEX!"); 995 EXT4_ERROR_INODE(inode, "ix > EXT_MAX_INDEX!");
995 return -EIO; 996 return -EFSCORRUPTED;
996 } 997 }
997 998
998 ix->ei_block = cpu_to_le32(logical); 999 ix->ei_block = cpu_to_le32(logical);
@@ -1001,7 +1002,7 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
1001 1002
1002 if (unlikely(ix > EXT_LAST_INDEX(curp->p_hdr))) { 1003 if (unlikely(ix > EXT_LAST_INDEX(curp->p_hdr))) {
1003 EXT4_ERROR_INODE(inode, "ix > EXT_LAST_INDEX!"); 1004 EXT4_ERROR_INODE(inode, "ix > EXT_LAST_INDEX!");
1004 return -EIO; 1005 return -EFSCORRUPTED;
1005 } 1006 }
1006 1007
1007 err = ext4_ext_dirty(handle, inode, curp); 1008 err = ext4_ext_dirty(handle, inode, curp);
@@ -1042,7 +1043,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
1042 * border from split point */ 1043 * border from split point */
1043 if (unlikely(path[depth].p_ext > EXT_MAX_EXTENT(path[depth].p_hdr))) { 1044 if (unlikely(path[depth].p_ext > EXT_MAX_EXTENT(path[depth].p_hdr))) {
1044 EXT4_ERROR_INODE(inode, "p_ext > EXT_MAX_EXTENT!"); 1045 EXT4_ERROR_INODE(inode, "p_ext > EXT_MAX_EXTENT!");
1045 return -EIO; 1046 return -EFSCORRUPTED;
1046 } 1047 }
1047 if (path[depth].p_ext != EXT_MAX_EXTENT(path[depth].p_hdr)) { 1048 if (path[depth].p_ext != EXT_MAX_EXTENT(path[depth].p_hdr)) {
1048 border = path[depth].p_ext[1].ee_block; 1049 border = path[depth].p_ext[1].ee_block;
@@ -1086,7 +1087,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
1086 newblock = ablocks[--a]; 1087 newblock = ablocks[--a];
1087 if (unlikely(newblock == 0)) { 1088 if (unlikely(newblock == 0)) {
1088 EXT4_ERROR_INODE(inode, "newblock == 0!"); 1089 EXT4_ERROR_INODE(inode, "newblock == 0!");
1089 err = -EIO; 1090 err = -EFSCORRUPTED;
1090 goto cleanup; 1091 goto cleanup;
1091 } 1092 }
1092 bh = sb_getblk_gfp(inode->i_sb, newblock, __GFP_MOVABLE | GFP_NOFS); 1093 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,
1112 EXT4_ERROR_INODE(inode, "eh_entries %d != eh_max %d!", 1113 EXT4_ERROR_INODE(inode, "eh_entries %d != eh_max %d!",
1113 path[depth].p_hdr->eh_entries, 1114 path[depth].p_hdr->eh_entries,
1114 path[depth].p_hdr->eh_max); 1115 path[depth].p_hdr->eh_max);
1115 err = -EIO; 1116 err = -EFSCORRUPTED;
1116 goto cleanup; 1117 goto cleanup;
1117 } 1118 }
1118 /* start copy from next extent */ 1119 /* start copy from next extent */
@@ -1151,7 +1152,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
1151 k = depth - at - 1; 1152 k = depth - at - 1;
1152 if (unlikely(k < 0)) { 1153 if (unlikely(k < 0)) {
1153 EXT4_ERROR_INODE(inode, "k %d < 0!", k); 1154 EXT4_ERROR_INODE(inode, "k %d < 0!", k);
1154 err = -EIO; 1155 err = -EFSCORRUPTED;
1155 goto cleanup; 1156 goto cleanup;
1156 } 1157 }
1157 if (k) 1158 if (k)
@@ -1191,7 +1192,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
1191 EXT4_ERROR_INODE(inode, 1192 EXT4_ERROR_INODE(inode,
1192 "EXT_MAX_INDEX != EXT_LAST_INDEX ee_block %d!", 1193 "EXT_MAX_INDEX != EXT_LAST_INDEX ee_block %d!",
1193 le32_to_cpu(path[i].p_ext->ee_block)); 1194 le32_to_cpu(path[i].p_ext->ee_block));
1194 err = -EIO; 1195 err = -EFSCORRUPTED;
1195 goto cleanup; 1196 goto cleanup;
1196 } 1197 }
1197 /* start copy indexes */ 1198 /* start copy indexes */
@@ -1425,7 +1426,7 @@ static int ext4_ext_search_left(struct inode *inode,
1425 1426
1426 if (unlikely(path == NULL)) { 1427 if (unlikely(path == NULL)) {
1427 EXT4_ERROR_INODE(inode, "path == NULL *logical %d!", *logical); 1428 EXT4_ERROR_INODE(inode, "path == NULL *logical %d!", *logical);
1428 return -EIO; 1429 return -EFSCORRUPTED;
1429 } 1430 }
1430 depth = path->p_depth; 1431 depth = path->p_depth;
1431 *phys = 0; 1432 *phys = 0;
@@ -1444,7 +1445,7 @@ static int ext4_ext_search_left(struct inode *inode,
1444 EXT4_ERROR_INODE(inode, 1445 EXT4_ERROR_INODE(inode,
1445 "EXT_FIRST_EXTENT != ex *logical %d ee_block %d!", 1446 "EXT_FIRST_EXTENT != ex *logical %d ee_block %d!",
1446 *logical, le32_to_cpu(ex->ee_block)); 1447 *logical, le32_to_cpu(ex->ee_block));
1447 return -EIO; 1448 return -EFSCORRUPTED;
1448 } 1449 }
1449 while (--depth >= 0) { 1450 while (--depth >= 0) {
1450 ix = path[depth].p_idx; 1451 ix = path[depth].p_idx;
@@ -1455,7 +1456,7 @@ static int ext4_ext_search_left(struct inode *inode,
1455 EXT_FIRST_INDEX(path[depth].p_hdr) != NULL ? 1456 EXT_FIRST_INDEX(path[depth].p_hdr) != NULL ?
1456 le32_to_cpu(EXT_FIRST_INDEX(path[depth].p_hdr)->ei_block) : 0, 1457 le32_to_cpu(EXT_FIRST_INDEX(path[depth].p_hdr)->ei_block) : 0,
1457 depth); 1458 depth);
1458 return -EIO; 1459 return -EFSCORRUPTED;
1459 } 1460 }
1460 } 1461 }
1461 return 0; 1462 return 0;
@@ -1465,7 +1466,7 @@ static int ext4_ext_search_left(struct inode *inode,
1465 EXT4_ERROR_INODE(inode, 1466 EXT4_ERROR_INODE(inode,
1466 "logical %d < ee_block %d + ee_len %d!", 1467 "logical %d < ee_block %d + ee_len %d!",
1467 *logical, le32_to_cpu(ex->ee_block), ee_len); 1468 *logical, le32_to_cpu(ex->ee_block), ee_len);
1468 return -EIO; 1469 return -EFSCORRUPTED;
1469 } 1470 }
1470 1471
1471 *logical = le32_to_cpu(ex->ee_block) + ee_len - 1; 1472 *logical = le32_to_cpu(ex->ee_block) + ee_len - 1;
@@ -1495,7 +1496,7 @@ static int ext4_ext_search_right(struct inode *inode,
1495 1496
1496 if (unlikely(path == NULL)) { 1497 if (unlikely(path == NULL)) {
1497 EXT4_ERROR_INODE(inode, "path == NULL *logical %d!", *logical); 1498 EXT4_ERROR_INODE(inode, "path == NULL *logical %d!", *logical);
1498 return -EIO; 1499 return -EFSCORRUPTED;
1499 } 1500 }
1500 depth = path->p_depth; 1501 depth = path->p_depth;
1501 *phys = 0; 1502 *phys = 0;
@@ -1514,7 +1515,7 @@ static int ext4_ext_search_right(struct inode *inode,
1514 EXT4_ERROR_INODE(inode, 1515 EXT4_ERROR_INODE(inode,
1515 "first_extent(path[%d].p_hdr) != ex", 1516 "first_extent(path[%d].p_hdr) != ex",
1516 depth); 1517 depth);
1517 return -EIO; 1518 return -EFSCORRUPTED;
1518 } 1519 }
1519 while (--depth >= 0) { 1520 while (--depth >= 0) {
1520 ix = path[depth].p_idx; 1521 ix = path[depth].p_idx;
@@ -1522,7 +1523,7 @@ static int ext4_ext_search_right(struct inode *inode,
1522 EXT4_ERROR_INODE(inode, 1523 EXT4_ERROR_INODE(inode,
1523 "ix != EXT_FIRST_INDEX *logical %d!", 1524 "ix != EXT_FIRST_INDEX *logical %d!",
1524 *logical); 1525 *logical);
1525 return -EIO; 1526 return -EFSCORRUPTED;
1526 } 1527 }
1527 } 1528 }
1528 goto found_extent; 1529 goto found_extent;
@@ -1532,7 +1533,7 @@ static int ext4_ext_search_right(struct inode *inode,
1532 EXT4_ERROR_INODE(inode, 1533 EXT4_ERROR_INODE(inode,
1533 "logical %d < ee_block %d + ee_len %d!", 1534 "logical %d < ee_block %d + ee_len %d!",
1534 *logical, le32_to_cpu(ex->ee_block), ee_len); 1535 *logical, le32_to_cpu(ex->ee_block), ee_len);
1535 return -EIO; 1536 return -EFSCORRUPTED;
1536 } 1537 }
1537 1538
1538 if (ex != EXT_LAST_EXTENT(path[depth].p_hdr)) { 1539 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,
1670 if (unlikely(ex == NULL || eh == NULL)) { 1671 if (unlikely(ex == NULL || eh == NULL)) {
1671 EXT4_ERROR_INODE(inode, 1672 EXT4_ERROR_INODE(inode,
1672 "ex %p == NULL or eh %p == NULL", ex, eh); 1673 "ex %p == NULL or eh %p == NULL", ex, eh);
1673 return -EIO; 1674 return -EFSCORRUPTED;
1674 } 1675 }
1675 1676
1676 if (depth == 0) { 1677 if (depth == 0) {
@@ -1938,14 +1939,14 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode,
1938 mb_flags |= EXT4_MB_DELALLOC_RESERVED; 1939 mb_flags |= EXT4_MB_DELALLOC_RESERVED;
1939 if (unlikely(ext4_ext_get_actual_len(newext) == 0)) { 1940 if (unlikely(ext4_ext_get_actual_len(newext) == 0)) {
1940 EXT4_ERROR_INODE(inode, "ext4_ext_get_actual_len(newext) == 0"); 1941 EXT4_ERROR_INODE(inode, "ext4_ext_get_actual_len(newext) == 0");
1941 return -EIO; 1942 return -EFSCORRUPTED;
1942 } 1943 }
1943 depth = ext_depth(inode); 1944 depth = ext_depth(inode);
1944 ex = path[depth].p_ext; 1945 ex = path[depth].p_ext;
1945 eh = path[depth].p_hdr; 1946 eh = path[depth].p_hdr;
1946 if (unlikely(path[depth].p_hdr == NULL)) { 1947 if (unlikely(path[depth].p_hdr == NULL)) {
1947 EXT4_ERROR_INODE(inode, "path[%d].p_hdr == NULL", depth); 1948 EXT4_ERROR_INODE(inode, "path[%d].p_hdr == NULL", depth);
1948 return -EIO; 1949 return -EFSCORRUPTED;
1949 } 1950 }
1950 1951
1951 /* try to insert block into found extent and return */ 1952 /* try to insert block into found extent and return */
@@ -2172,7 +2173,7 @@ static int ext4_fill_fiemap_extents(struct inode *inode,
2172 if (unlikely(path[depth].p_hdr == NULL)) { 2173 if (unlikely(path[depth].p_hdr == NULL)) {
2173 up_read(&EXT4_I(inode)->i_data_sem); 2174 up_read(&EXT4_I(inode)->i_data_sem);
2174 EXT4_ERROR_INODE(inode, "path[%d].p_hdr == NULL", depth); 2175 EXT4_ERROR_INODE(inode, "path[%d].p_hdr == NULL", depth);
2175 err = -EIO; 2176 err = -EFSCORRUPTED;
2176 break; 2177 break;
2177 } 2178 }
2178 ex = path[depth].p_ext; 2179 ex = path[depth].p_ext;
@@ -2241,7 +2242,7 @@ static int ext4_fill_fiemap_extents(struct inode *inode,
2241 2242
2242 if (unlikely(es.es_len == 0)) { 2243 if (unlikely(es.es_len == 0)) {
2243 EXT4_ERROR_INODE(inode, "es.es_len == 0"); 2244 EXT4_ERROR_INODE(inode, "es.es_len == 0");
2244 err = -EIO; 2245 err = -EFSCORRUPTED;
2245 break; 2246 break;
2246 } 2247 }
2247 2248
@@ -2264,7 +2265,7 @@ static int ext4_fill_fiemap_extents(struct inode *inode,
2264 "next extent == %u, next " 2265 "next extent == %u, next "
2265 "delalloc extent = %u", 2266 "delalloc extent = %u",
2266 next, next_del); 2267 next, next_del);
2267 err = -EIO; 2268 err = -EFSCORRUPTED;
2268 break; 2269 break;
2269 } 2270 }
2270 } 2271 }
@@ -2363,7 +2364,7 @@ static int ext4_ext_rm_idx(handle_t *handle, struct inode *inode,
2363 leaf = ext4_idx_pblock(path->p_idx); 2364 leaf = ext4_idx_pblock(path->p_idx);
2364 if (unlikely(path->p_hdr->eh_entries == 0)) { 2365 if (unlikely(path->p_hdr->eh_entries == 0)) {
2365 EXT4_ERROR_INODE(inode, "path->p_hdr->eh_entries == 0"); 2366 EXT4_ERROR_INODE(inode, "path->p_hdr->eh_entries == 0");
2366 return -EIO; 2367 return -EFSCORRUPTED;
2367 } 2368 }
2368 err = ext4_ext_get_access(handle, inode, path); 2369 err = ext4_ext_get_access(handle, inode, path);
2369 if (err) 2370 if (err)
@@ -2612,7 +2613,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
2612 eh = path[depth].p_hdr; 2613 eh = path[depth].p_hdr;
2613 if (unlikely(path[depth].p_hdr == NULL)) { 2614 if (unlikely(path[depth].p_hdr == NULL)) {
2614 EXT4_ERROR_INODE(inode, "path[%d].p_hdr == NULL", depth); 2615 EXT4_ERROR_INODE(inode, "path[%d].p_hdr == NULL", depth);
2615 return -EIO; 2616 return -EFSCORRUPTED;
2616 } 2617 }
2617 /* find where to start removing */ 2618 /* find where to start removing */
2618 ex = path[depth].p_ext; 2619 ex = path[depth].p_ext;
@@ -2666,7 +2667,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
2666 "on extent %u:%u", 2667 "on extent %u:%u",
2667 start, end, ex_ee_block, 2668 start, end, ex_ee_block,
2668 ex_ee_block + ex_ee_len - 1); 2669 ex_ee_block + ex_ee_len - 1);
2669 err = -EIO; 2670 err = -EFSCORRUPTED;
2670 goto out; 2671 goto out;
2671 } else if (a != ex_ee_block) { 2672 } else if (a != ex_ee_block) {
2672 /* remove tail of the extent */ 2673 /* remove tail of the extent */
@@ -2841,7 +2842,7 @@ again:
2841 EXT4_ERROR_INODE(inode, 2842 EXT4_ERROR_INODE(inode,
2842 "path[%d].p_hdr == NULL", 2843 "path[%d].p_hdr == NULL",
2843 depth); 2844 depth);
2844 err = -EIO; 2845 err = -EFSCORRUPTED;
2845 } 2846 }
2846 goto out; 2847 goto out;
2847 } 2848 }
@@ -2920,7 +2921,7 @@ again:
2920 i = 0; 2921 i = 0;
2921 2922
2922 if (ext4_ext_check(inode, path[0].p_hdr, depth, 0)) { 2923 if (ext4_ext_check(inode, path[0].p_hdr, depth, 0)) {
2923 err = -EIO; 2924 err = -EFSCORRUPTED;
2924 goto out; 2925 goto out;
2925 } 2926 }
2926 } 2927 }
@@ -2978,7 +2979,7 @@ again:
2978 * Should be a no-op if we did IO above. */ 2979 * Should be a no-op if we did IO above. */
2979 cond_resched(); 2980 cond_resched();
2980 if (WARN_ON(i + 1 > depth)) { 2981 if (WARN_ON(i + 1 > depth)) {
2981 err = -EIO; 2982 err = -EFSCORRUPTED;
2982 break; 2983 break;
2983 } 2984 }
2984 path[i + 1].p_bh = bh; 2985 path[i + 1].p_bh = bh;
@@ -3345,7 +3346,7 @@ static int ext4_split_extent(handle_t *handle,
3345 if (!ex) { 3346 if (!ex) {
3346 EXT4_ERROR_INODE(inode, "unexpected hole at %lu", 3347 EXT4_ERROR_INODE(inode, "unexpected hole at %lu",
3347 (unsigned long) map->m_lblk); 3348 (unsigned long) map->m_lblk);
3348 return -EIO; 3349 return -EFSCORRUPTED;
3349 } 3350 }
3350 unwritten = ext4_ext_is_unwritten(ex); 3351 unwritten = ext4_ext_is_unwritten(ex);
3351 split_flag1 = 0; 3352 split_flag1 = 0;
@@ -3973,7 +3974,7 @@ convert_initialized_extent(handle_t *handle, struct inode *inode,
3973 if (!ex) { 3974 if (!ex) {
3974 EXT4_ERROR_INODE(inode, "unexpected hole at %lu", 3975 EXT4_ERROR_INODE(inode, "unexpected hole at %lu",
3975 (unsigned long) map->m_lblk); 3976 (unsigned long) map->m_lblk);
3976 return -EIO; 3977 return -EFSCORRUPTED;
3977 } 3978 }
3978 } 3979 }
3979 3980
@@ -4311,7 +4312,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
4311 "lblock: %lu, depth: %d pblock %lld", 4312 "lblock: %lu, depth: %d pblock %lld",
4312 (unsigned long) map->m_lblk, depth, 4313 (unsigned long) map->m_lblk, depth,
4313 path[depth].p_block); 4314 path[depth].p_block);
4314 err = -EIO; 4315 err = -EFSCORRUPTED;
4315 goto out2; 4316 goto out2;
4316 } 4317 }
4317 4318
@@ -5274,7 +5275,7 @@ ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift,
5274 if (depth == path->p_depth) { 5275 if (depth == path->p_depth) {
5275 ex_start = path[depth].p_ext; 5276 ex_start = path[depth].p_ext;
5276 if (!ex_start) 5277 if (!ex_start)
5277 return -EIO; 5278 return -EFSCORRUPTED;
5278 5279
5279 ex_last = EXT_LAST_EXTENT(path[depth].p_hdr); 5280 ex_last = EXT_LAST_EXTENT(path[depth].p_hdr);
5280 5281
@@ -5414,7 +5415,7 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
5414 if (!extent) { 5415 if (!extent) {
5415 EXT4_ERROR_INODE(inode, "unexpected hole at %lu", 5416 EXT4_ERROR_INODE(inode, "unexpected hole at %lu",
5416 (unsigned long) *iterator); 5417 (unsigned long) *iterator);
5417 return -EIO; 5418 return -EFSCORRUPTED;
5418 } 5419 }
5419 if (SHIFT == SHIFT_LEFT && *iterator > 5420 if (SHIFT == SHIFT_LEFT && *iterator >
5420 le32_to_cpu(extent->ee_block)) { 5421 le32_to_cpu(extent->ee_block)) {
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 619bfc1fda8c..f34b1aa8bbb5 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1116,6 +1116,7 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
1116 /* Error cases - e2fsck has already cleaned up for us */ 1116 /* Error cases - e2fsck has already cleaned up for us */
1117 if (ino > max_ino) { 1117 if (ino > max_ino) {
1118 ext4_warning(sb, "bad orphan ino %lu! e2fsck was run?", ino); 1118 ext4_warning(sb, "bad orphan ino %lu! e2fsck was run?", ino);
1119 err = -EFSCORRUPTED;
1119 goto error; 1120 goto error;
1120 } 1121 }
1121 1122
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
index 2468261748b2..d96ea53bbece 100644
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -566,7 +566,7 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
566 EXT4_FEATURE_RO_COMPAT_BIGALLOC)) { 566 EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
567 EXT4_ERROR_INODE(inode, "Can't allocate blocks for " 567 EXT4_ERROR_INODE(inode, "Can't allocate blocks for "
568 "non-extent mapped inodes with bigalloc"); 568 "non-extent mapped inodes with bigalloc");
569 return -EUCLEAN; 569 return -EFSCORRUPTED;
570 } 570 }
571 571
572 /* Set up for the direct block allocation */ 572 /* Set up for the direct block allocation */
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index f205ac3c4e41..2b9278867caf 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -378,7 +378,7 @@ static int __check_block_validity(struct inode *inode, const char *func,
378 "lblock %lu mapped to illegal pblock " 378 "lblock %lu mapped to illegal pblock "
379 "(length %d)", (unsigned long) map->m_lblk, 379 "(length %d)", (unsigned long) map->m_lblk,
380 map->m_len); 380 map->m_len);
381 return -EIO; 381 return -EFSCORRUPTED;
382 } 382 }
383 return 0; 383 return 0;
384} 384}
@@ -480,7 +480,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
480 480
481 /* We can handle the block number less than EXT_MAX_BLOCKS */ 481 /* We can handle the block number less than EXT_MAX_BLOCKS */
482 if (unlikely(map->m_lblk >= EXT_MAX_BLOCKS)) 482 if (unlikely(map->m_lblk >= EXT_MAX_BLOCKS))
483 return -EIO; 483 return -EFSCORRUPTED;
484 484
485 /* Lookup extent status tree firstly */ 485 /* Lookup extent status tree firstly */
486 if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) { 486 if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) {
@@ -3863,7 +3863,7 @@ static int __ext4_get_inode_loc(struct inode *inode,
3863 3863
3864 iloc->bh = NULL; 3864 iloc->bh = NULL;
3865 if (!ext4_valid_inum(sb, inode->i_ino)) 3865 if (!ext4_valid_inum(sb, inode->i_ino))
3866 return -EIO; 3866 return -EFSCORRUPTED;
3867 3867
3868 iloc->block_group = (inode->i_ino - 1) / EXT4_INODES_PER_GROUP(sb); 3868 iloc->block_group = (inode->i_ino - 1) / EXT4_INODES_PER_GROUP(sb);
3869 gdp = ext4_get_group_desc(sb, iloc->block_group, NULL); 3869 gdp = ext4_get_group_desc(sb, iloc->block_group, NULL);
@@ -4111,7 +4111,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
4111 EXT4_ERROR_INODE(inode, "bad extra_isize (%u != %u)", 4111 EXT4_ERROR_INODE(inode, "bad extra_isize (%u != %u)",
4112 EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize, 4112 EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize,
4113 EXT4_INODE_SIZE(inode->i_sb)); 4113 EXT4_INODE_SIZE(inode->i_sb));
4114 ret = -EIO; 4114 ret = -EFSCORRUPTED;
4115 goto bad_inode; 4115 goto bad_inode;
4116 } 4116 }
4117 } else 4117 } else
@@ -4131,7 +4131,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
4131 4131
4132 if (!ext4_inode_csum_verify(inode, raw_inode, ei)) { 4132 if (!ext4_inode_csum_verify(inode, raw_inode, ei)) {
4133 EXT4_ERROR_INODE(inode, "checksum invalid"); 4133 EXT4_ERROR_INODE(inode, "checksum invalid");
4134 ret = -EIO; 4134 ret = -EFSBADCRC;
4135 goto bad_inode; 4135 goto bad_inode;
4136 } 4136 }
4137 4137
@@ -4246,7 +4246,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
4246 !ext4_data_block_valid(EXT4_SB(sb), ei->i_file_acl, 1)) { 4246 !ext4_data_block_valid(EXT4_SB(sb), ei->i_file_acl, 1)) {
4247 EXT4_ERROR_INODE(inode, "bad extended attribute block %llu", 4247 EXT4_ERROR_INODE(inode, "bad extended attribute block %llu",
4248 ei->i_file_acl); 4248 ei->i_file_acl);
4249 ret = -EIO; 4249 ret = -EFSCORRUPTED;
4250 goto bad_inode; 4250 goto bad_inode;
4251 } else if (!ext4_has_inline_data(inode)) { 4251 } else if (!ext4_has_inline_data(inode)) {
4252 if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) { 4252 if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {
@@ -4297,7 +4297,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
4297 } else if (ino == EXT4_BOOT_LOADER_INO) { 4297 } else if (ino == EXT4_BOOT_LOADER_INO) {
4298 make_bad_inode(inode); 4298 make_bad_inode(inode);
4299 } else { 4299 } else {
4300 ret = -EIO; 4300 ret = -EFSCORRUPTED;
4301 EXT4_ERROR_INODE(inode, "bogus i_mode (%o)", inode->i_mode); 4301 EXT4_ERROR_INODE(inode, "bogus i_mode (%o)", inode->i_mode);
4302 goto bad_inode; 4302 goto bad_inode;
4303 } 4303 }
@@ -4315,7 +4315,7 @@ bad_inode:
4315struct inode *ext4_iget_normal(struct super_block *sb, unsigned long ino) 4315struct inode *ext4_iget_normal(struct super_block *sb, unsigned long ino)
4316{ 4316{
4317 if (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO) 4317 if (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO)
4318 return ERR_PTR(-EIO); 4318 return ERR_PTR(-EFSCORRUPTED);
4319 return ext4_iget(sb, ino); 4319 return ext4_iget(sb, ino);
4320} 4320}
4321 4321
diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
index 6eb1a619890c..0a512aa81bf7 100644
--- a/fs/ext4/mmp.c
+++ b/fs/ext4/mmp.c
@@ -98,10 +98,12 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
98 } 98 }
99 99
100 mmp = (struct mmp_struct *)((*bh)->b_data); 100 mmp = (struct mmp_struct *)((*bh)->b_data);
101 if (le32_to_cpu(mmp->mmp_magic) == EXT4_MMP_MAGIC && 101 if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC)
102 ext4_mmp_csum_verify(sb, mmp)) 102 ret = -EFSCORRUPTED;
103 else if (!ext4_mmp_csum_verify(sb, mmp))
104 ret = -EFSBADCRC;
105 else
103 return 0; 106 return 0;
104 ret = -EINVAL;
105 107
106warn_exit: 108warn_exit:
107 ext4_warning(sb, "Error %d while reading MMP block %llu", 109 ext4_warning(sb, "Error %d while reading MMP block %llu",
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 9f61e7679a6d..8fd8e0d4c75e 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -109,7 +109,7 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode,
109 if (!bh) { 109 if (!bh) {
110 ext4_error_inode(inode, func, line, block, 110 ext4_error_inode(inode, func, line, block,
111 "Directory hole found"); 111 "Directory hole found");
112 return ERR_PTR(-EIO); 112 return ERR_PTR(-EFSCORRUPTED);
113 } 113 }
114 dirent = (struct ext4_dir_entry *) bh->b_data; 114 dirent = (struct ext4_dir_entry *) bh->b_data;
115 /* Determine whether or not we have an index block */ 115 /* Determine whether or not we have an index block */
@@ -124,7 +124,7 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode,
124 if (!is_dx_block && type == INDEX) { 124 if (!is_dx_block && type == INDEX) {
125 ext4_error_inode(inode, func, line, block, 125 ext4_error_inode(inode, func, line, block,
126 "directory leaf block found instead of index block"); 126 "directory leaf block found instead of index block");
127 return ERR_PTR(-EIO); 127 return ERR_PTR(-EFSCORRUPTED);
128 } 128 }
129 if (!ext4_has_metadata_csum(inode->i_sb) || 129 if (!ext4_has_metadata_csum(inode->i_sb) ||
130 buffer_verified(bh)) 130 buffer_verified(bh))
@@ -142,7 +142,7 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode,
142 ext4_error_inode(inode, func, line, block, 142 ext4_error_inode(inode, func, line, block,
143 "Directory index failed checksum"); 143 "Directory index failed checksum");
144 brelse(bh); 144 brelse(bh);
145 return ERR_PTR(-EIO); 145 return ERR_PTR(-EFSBADCRC);
146 } 146 }
147 } 147 }
148 if (!is_dx_block) { 148 if (!is_dx_block) {
@@ -152,7 +152,7 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode,
152 ext4_error_inode(inode, func, line, block, 152 ext4_error_inode(inode, func, line, block,
153 "Directory block failed checksum"); 153 "Directory block failed checksum");
154 brelse(bh); 154 brelse(bh);
155 return ERR_PTR(-EIO); 155 return ERR_PTR(-EFSBADCRC);
156 } 156 }
157 } 157 }
158 return bh; 158 return bh;
@@ -1570,19 +1570,19 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
1570 brelse(bh); 1570 brelse(bh);
1571 if (!ext4_valid_inum(dir->i_sb, ino)) { 1571 if (!ext4_valid_inum(dir->i_sb, ino)) {
1572 EXT4_ERROR_INODE(dir, "bad inode number: %u", ino); 1572 EXT4_ERROR_INODE(dir, "bad inode number: %u", ino);
1573 return ERR_PTR(-EIO); 1573 return ERR_PTR(-EFSCORRUPTED);
1574 } 1574 }
1575 if (unlikely(ino == dir->i_ino)) { 1575 if (unlikely(ino == dir->i_ino)) {
1576 EXT4_ERROR_INODE(dir, "'%pd' linked to parent dir", 1576 EXT4_ERROR_INODE(dir, "'%pd' linked to parent dir",
1577 dentry); 1577 dentry);
1578 return ERR_PTR(-EIO); 1578 return ERR_PTR(-EFSCORRUPTED);
1579 } 1579 }
1580 inode = ext4_iget_normal(dir->i_sb, ino); 1580 inode = ext4_iget_normal(dir->i_sb, ino);
1581 if (inode == ERR_PTR(-ESTALE)) { 1581 if (inode == ERR_PTR(-ESTALE)) {
1582 EXT4_ERROR_INODE(dir, 1582 EXT4_ERROR_INODE(dir,
1583 "deleted inode referenced: %u", 1583 "deleted inode referenced: %u",
1584 ino); 1584 ino);
1585 return ERR_PTR(-EIO); 1585 return ERR_PTR(-EFSCORRUPTED);
1586 } 1586 }
1587 if (!IS_ERR(inode) && ext4_encrypted_inode(dir) && 1587 if (!IS_ERR(inode) && ext4_encrypted_inode(dir) &&
1588 (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || 1588 (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
@@ -1619,7 +1619,7 @@ struct dentry *ext4_get_parent(struct dentry *child)
1619 if (!ext4_valid_inum(d_inode(child)->i_sb, ino)) { 1619 if (!ext4_valid_inum(d_inode(child)->i_sb, ino)) {
1620 EXT4_ERROR_INODE(d_inode(child), 1620 EXT4_ERROR_INODE(d_inode(child),
1621 "bad parent inode number: %u", ino); 1621 "bad parent inode number: %u", ino);
1622 return ERR_PTR(-EIO); 1622 return ERR_PTR(-EFSCORRUPTED);
1623 } 1623 }
1624 1624
1625 return d_obtain_alias(ext4_iget_normal(d_inode(child)->i_sb, ino)); 1625 return d_obtain_alias(ext4_iget_normal(d_inode(child)->i_sb, ino));
@@ -1807,7 +1807,7 @@ int ext4_find_dest_de(struct inode *dir, struct inode *inode,
1807 while ((char *) de <= top) { 1807 while ((char *) de <= top) {
1808 if (ext4_check_dir_entry(dir, NULL, de, bh, 1808 if (ext4_check_dir_entry(dir, NULL, de, bh,
1809 buf, buf_size, offset)) { 1809 buf, buf_size, offset)) {
1810 res = -EIO; 1810 res = -EFSCORRUPTED;
1811 goto return_result; 1811 goto return_result;
1812 } 1812 }
1813 /* Provide crypto context and crypto buffer to ext4 match */ 1813 /* Provide crypto context and crypto buffer to ext4 match */
@@ -1967,7 +1967,7 @@ static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname,
1967 if ((char *) de >= (((char *) root) + blocksize)) { 1967 if ((char *) de >= (((char *) root) + blocksize)) {
1968 EXT4_ERROR_INODE(dir, "invalid rec_len for '..'"); 1968 EXT4_ERROR_INODE(dir, "invalid rec_len for '..'");
1969 brelse(bh); 1969 brelse(bh);
1970 return -EIO; 1970 return -EFSCORRUPTED;
1971 } 1971 }
1972 len = ((char *) root) + (blocksize - csum_size) - (char *) de; 1972 len = ((char *) root) + (blocksize - csum_size) - (char *) de;
1973 1973
@@ -2315,7 +2315,7 @@ int ext4_generic_delete_entry(handle_t *handle,
2315 while (i < buf_size - csum_size) { 2315 while (i < buf_size - csum_size) {
2316 if (ext4_check_dir_entry(dir, NULL, de, bh, 2316 if (ext4_check_dir_entry(dir, NULL, de, bh,
2317 bh->b_data, bh->b_size, i)) 2317 bh->b_data, bh->b_size, i))
2318 return -EIO; 2318 return -EFSCORRUPTED;
2319 if (de == de_del) { 2319 if (de == de_del) {
2320 if (pde) 2320 if (pde)
2321 pde->rec_len = ext4_rec_len_to_disk( 2321 pde->rec_len = ext4_rec_len_to_disk(
@@ -2934,7 +2934,7 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
2934 2934
2935 inode = d_inode(dentry); 2935 inode = d_inode(dentry);
2936 2936
2937 retval = -EIO; 2937 retval = -EFSCORRUPTED;
2938 if (le32_to_cpu(de->inode) != inode->i_ino) 2938 if (le32_to_cpu(de->inode) != inode->i_ino)
2939 goto end_rmdir; 2939 goto end_rmdir;
2940 2940
@@ -3008,7 +3008,7 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
3008 3008
3009 inode = d_inode(dentry); 3009 inode = d_inode(dentry);
3010 3010
3011 retval = -EIO; 3011 retval = -EFSCORRUPTED;
3012 if (le32_to_cpu(de->inode) != inode->i_ino) 3012 if (le32_to_cpu(de->inode) != inode->i_ino)
3013 goto end_unlink; 3013 goto end_unlink;
3014 3014
@@ -3310,7 +3310,7 @@ static int ext4_rename_dir_prepare(handle_t *handle, struct ext4_renament *ent)
3310 if (!ent->dir_bh) 3310 if (!ent->dir_bh)
3311 return retval; 3311 return retval;
3312 if (le32_to_cpu(ent->parent_de->inode) != ent->dir->i_ino) 3312 if (le32_to_cpu(ent->parent_de->inode) != ent->dir->i_ino)
3313 return -EIO; 3313 return -EFSCORRUPTED;
3314 BUFFER_TRACE(ent->dir_bh, "get_write_access"); 3314 BUFFER_TRACE(ent->dir_bh, "get_write_access");
3315 return ext4_journal_get_write_access(handle, ent->dir_bh); 3315 return ext4_journal_get_write_access(handle, ent->dir_bh);
3316} 3316}
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 43c0cc802189..f7519ad25cce 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -490,6 +490,12 @@ const char *ext4_decode_error(struct super_block *sb, int errno,
490 char *errstr = NULL; 490 char *errstr = NULL;
491 491
492 switch (errno) { 492 switch (errno) {
493 case -EFSCORRUPTED:
494 errstr = "Corrupt filesystem";
495 break;
496 case -EFSBADCRC:
497 errstr = "Filesystem failed CRC";
498 break;
493 case -EIO: 499 case -EIO:
494 errstr = "IO failure"; 500 errstr = "IO failure";
495 break; 501 break;
@@ -3192,6 +3198,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3192 ext4_msg(sb, KERN_ERR, "VFS: Found ext4 filesystem with " 3198 ext4_msg(sb, KERN_ERR, "VFS: Found ext4 filesystem with "
3193 "invalid superblock checksum. Run e2fsck?"); 3199 "invalid superblock checksum. Run e2fsck?");
3194 silent = 1; 3200 silent = 1;
3201 ret = -EFSBADCRC;
3195 goto cantfind_ext4; 3202 goto cantfind_ext4;
3196 } 3203 }
3197 3204
@@ -3612,6 +3619,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3612 } 3619 }
3613 if (!ext4_check_descriptors(sb, &first_not_zeroed)) { 3620 if (!ext4_check_descriptors(sb, &first_not_zeroed)) {
3614 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); 3621 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
3622 ret = -EFSCORRUPTED;
3615 goto failed_mount2; 3623 goto failed_mount2;
3616 } 3624 }
3617 3625
@@ -4664,7 +4672,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
4664 "ext4_remount: Checksum for group %u failed (%u!=%u)", 4672 "ext4_remount: Checksum for group %u failed (%u!=%u)",
4665 g, le16_to_cpu(ext4_group_desc_csum(sbi, g, gdp)), 4673 g, le16_to_cpu(ext4_group_desc_csum(sbi, g, gdp)),
4666 le16_to_cpu(gdp->bg_checksum)); 4674 le16_to_cpu(gdp->bg_checksum));
4667 err = -EINVAL; 4675 err = -EFSBADCRC;
4668 goto restore_opts; 4676 goto restore_opts;
4669 } 4677 }
4670 } 4678 }
diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c
index c677f2c1044b..abe2401ce405 100644
--- a/fs/ext4/symlink.c
+++ b/fs/ext4/symlink.c
@@ -57,7 +57,7 @@ static const char *ext4_encrypted_follow_link(struct dentry *dentry, void **cook
57 sizeof(struct ext4_encrypted_symlink_data) - 1) > 57 sizeof(struct ext4_encrypted_symlink_data) - 1) >
58 max_size) { 58 max_size) {
59 /* Symlink data on the disk is corrupted */ 59 /* Symlink data on the disk is corrupted */
60 res = -EIO; 60 res = -EFSCORRUPTED;
61 goto errout; 61 goto errout;
62 } 62 }
63 plen = (cstr.len < EXT4_FNAME_CRYPTO_DIGEST_SIZE*2) ? 63 plen = (cstr.len < EXT4_FNAME_CRYPTO_DIGEST_SIZE*2) ?
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 16e28c08d1e8..7649422ed7a1 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -195,7 +195,7 @@ ext4_xattr_check_names(struct ext4_xattr_entry *entry, void *end,
195 while (!IS_LAST_ENTRY(e)) { 195 while (!IS_LAST_ENTRY(e)) {
196 struct ext4_xattr_entry *next = EXT4_XATTR_NEXT(e); 196 struct ext4_xattr_entry *next = EXT4_XATTR_NEXT(e);
197 if ((void *)next >= end) 197 if ((void *)next >= end)
198 return -EIO; 198 return -EFSCORRUPTED;
199 e = next; 199 e = next;
200 } 200 }
201 201
@@ -205,7 +205,7 @@ ext4_xattr_check_names(struct ext4_xattr_entry *entry, void *end,
205 (void *)e + sizeof(__u32) || 205 (void *)e + sizeof(__u32) ||
206 value_start + le16_to_cpu(entry->e_value_offs) + 206 value_start + le16_to_cpu(entry->e_value_offs) +
207 le32_to_cpu(entry->e_value_size) > end)) 207 le32_to_cpu(entry->e_value_size) > end))
208 return -EIO; 208 return -EFSCORRUPTED;
209 entry = EXT4_XATTR_NEXT(entry); 209 entry = EXT4_XATTR_NEXT(entry);
210 } 210 }
211 211
@@ -222,9 +222,9 @@ ext4_xattr_check_block(struct inode *inode, struct buffer_head *bh)
222 222
223 if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) || 223 if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) ||
224 BHDR(bh)->h_blocks != cpu_to_le32(1)) 224 BHDR(bh)->h_blocks != cpu_to_le32(1))
225 return -EIO; 225 return -EFSCORRUPTED;
226 if (!ext4_xattr_block_csum_verify(inode, bh->b_blocknr, BHDR(bh))) 226 if (!ext4_xattr_block_csum_verify(inode, bh->b_blocknr, BHDR(bh)))
227 return -EIO; 227 return -EFSBADCRC;
228 error = ext4_xattr_check_names(BFIRST(bh), bh->b_data + bh->b_size, 228 error = ext4_xattr_check_names(BFIRST(bh), bh->b_data + bh->b_size,
229 bh->b_data); 229 bh->b_data);
230 if (!error) 230 if (!error)
@@ -239,7 +239,7 @@ ext4_xattr_check_entry(struct ext4_xattr_entry *entry, size_t size)
239 239
240 if (entry->e_value_block != 0 || value_size > size || 240 if (entry->e_value_block != 0 || value_size > size ||
241 le16_to_cpu(entry->e_value_offs) + value_size > size) 241 le16_to_cpu(entry->e_value_offs) + value_size > size)
242 return -EIO; 242 return -EFSCORRUPTED;
243 return 0; 243 return 0;
244} 244}
245 245
@@ -266,7 +266,7 @@ ext4_xattr_find_entry(struct ext4_xattr_entry **pentry, int name_index,
266 } 266 }
267 *pentry = entry; 267 *pentry = entry;
268 if (!cmp && ext4_xattr_check_entry(entry, size)) 268 if (!cmp && ext4_xattr_check_entry(entry, size))
269 return -EIO; 269 return -EFSCORRUPTED;
270 return cmp ? -ENODATA : 0; 270 return cmp ? -ENODATA : 0;
271} 271}
272 272
@@ -297,13 +297,13 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name,
297bad_block: 297bad_block:
298 EXT4_ERROR_INODE(inode, "bad block %llu", 298 EXT4_ERROR_INODE(inode, "bad block %llu",
299 EXT4_I(inode)->i_file_acl); 299 EXT4_I(inode)->i_file_acl);
300 error = -EIO; 300 error = -EFSCORRUPTED;
301 goto cleanup; 301 goto cleanup;
302 } 302 }
303 ext4_xattr_cache_insert(ext4_mb_cache, bh); 303 ext4_xattr_cache_insert(ext4_mb_cache, bh);
304 entry = BFIRST(bh); 304 entry = BFIRST(bh);
305 error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1); 305 error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1);
306 if (error == -EIO) 306 if (error == -EFSCORRUPTED)
307 goto bad_block; 307 goto bad_block;
308 if (error) 308 if (error)
309 goto cleanup; 309 goto cleanup;
@@ -445,7 +445,7 @@ ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size)
445 if (ext4_xattr_check_block(inode, bh)) { 445 if (ext4_xattr_check_block(inode, bh)) {
446 EXT4_ERROR_INODE(inode, "bad block %llu", 446 EXT4_ERROR_INODE(inode, "bad block %llu",
447 EXT4_I(inode)->i_file_acl); 447 EXT4_I(inode)->i_file_acl);
448 error = -EIO; 448 error = -EFSCORRUPTED;
449 goto cleanup; 449 goto cleanup;
450 } 450 }
451 ext4_xattr_cache_insert(ext4_mb_cache, bh); 451 ext4_xattr_cache_insert(ext4_mb_cache, bh);
@@ -751,7 +751,7 @@ ext4_xattr_block_find(struct inode *inode, struct ext4_xattr_info *i,
751 if (ext4_xattr_check_block(inode, bs->bh)) { 751 if (ext4_xattr_check_block(inode, bs->bh)) {
752 EXT4_ERROR_INODE(inode, "bad block %llu", 752 EXT4_ERROR_INODE(inode, "bad block %llu",
753 EXT4_I(inode)->i_file_acl); 753 EXT4_I(inode)->i_file_acl);
754 error = -EIO; 754 error = -EFSCORRUPTED;
755 goto cleanup; 755 goto cleanup;
756 } 756 }
757 /* Find the named attribute. */ 757 /* Find the named attribute. */
@@ -811,7 +811,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
811 bs->bh); 811 bs->bh);
812 } 812 }
813 unlock_buffer(bs->bh); 813 unlock_buffer(bs->bh);
814 if (error == -EIO) 814 if (error == -EFSCORRUPTED)
815 goto bad_block; 815 goto bad_block;
816 if (!error) 816 if (!error)
817 error = ext4_handle_dirty_xattr_block(handle, 817 error = ext4_handle_dirty_xattr_block(handle,
@@ -855,7 +855,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
855 } 855 }
856 856
857 error = ext4_xattr_set_entry(i, s); 857 error = ext4_xattr_set_entry(i, s);
858 if (error == -EIO) 858 if (error == -EFSCORRUPTED)
859 goto bad_block; 859 goto bad_block;
860 if (error) 860 if (error)
861 goto cleanup; 861 goto cleanup;
@@ -1314,7 +1314,7 @@ retry:
1314 if (ext4_xattr_check_block(inode, bh)) { 1314 if (ext4_xattr_check_block(inode, bh)) {
1315 EXT4_ERROR_INODE(inode, "bad block %llu", 1315 EXT4_ERROR_INODE(inode, "bad block %llu",
1316 EXT4_I(inode)->i_file_acl); 1316 EXT4_I(inode)->i_file_acl);
1317 error = -EIO; 1317 error = -EFSCORRUPTED;
1318 goto cleanup; 1318 goto cleanup;
1319 } 1319 }
1320 base = BHDR(bh); 1320 base = BHDR(bh);
@@ -1579,7 +1579,7 @@ ext4_xattr_cmp(struct ext4_xattr_header *header1,
1579 memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len)) 1579 memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
1580 return 1; 1580 return 1;
1581 if (entry1->e_value_block != 0 || entry2->e_value_block != 0) 1581 if (entry1->e_value_block != 0 || entry2->e_value_block != 0)
1582 return -EIO; 1582 return -EFSCORRUPTED;
1583 if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs), 1583 if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
1584 (char *)header2 + le16_to_cpu(entry2->e_value_offs), 1584 (char *)header2 + le16_to_cpu(entry2->e_value_offs),
1585 le32_to_cpu(entry1->e_value_size))) 1585 le32_to_cpu(entry1->e_value_size)))