diff options
author | Theodore Ts'o <tytso@mit.edu> | 2010-05-16 21:00:00 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2010-05-16 21:00:00 -0400 |
commit | 24676da469f50f433baa347845639662c561d1f6 (patch) | |
tree | b4b8205f8b50376af286193d0dcbe76f2bc2d1e1 /fs/ext4/inode.c | |
parent | 2ed886852adfcb070bf350e66a0da0d98b2f3ab5 (diff) |
ext4: Convert calls of ext4_error() to EXT4_ERROR_INODE()
EXT4_ERROR_INODE() tends to provide better error information and in a
more consistent format. Some errors were not even identifying the inode
or directory which was corrupted, which made them not very useful.
Addresses-Google-Bug: #2507977
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r-- | fs/ext4/inode.c | 83 |
1 files changed, 38 insertions, 45 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 0b1d7c89f93f..3b6877257580 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -348,9 +348,8 @@ static int __ext4_check_blockref(const char *function, struct inode *inode, | |||
348 | if (blk && | 348 | if (blk && |
349 | unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb), | 349 | unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb), |
350 | blk, 1))) { | 350 | blk, 1))) { |
351 | __ext4_error(inode->i_sb, function, | 351 | ext4_error_inode(function, inode, |
352 | "invalid block reference %u " | 352 | "invalid block reference %u", blk); |
353 | "in inode #%lu", blk, inode->i_ino); | ||
354 | return -EIO; | 353 | return -EIO; |
355 | } | 354 | } |
356 | } | 355 | } |
@@ -1129,15 +1128,15 @@ void ext4_da_update_reserve_space(struct inode *inode, | |||
1129 | ext4_discard_preallocations(inode); | 1128 | ext4_discard_preallocations(inode); |
1130 | } | 1129 | } |
1131 | 1130 | ||
1132 | static int check_block_validity(struct inode *inode, const char *msg, | 1131 | static int check_block_validity(struct inode *inode, const char *func, |
1133 | sector_t logical, sector_t phys, int len) | 1132 | struct ext4_map_blocks *map) |
1134 | { | 1133 | { |
1135 | if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), phys, len)) { | 1134 | if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), map->m_pblk, |
1136 | __ext4_error(inode->i_sb, msg, | 1135 | map->m_len)) { |
1137 | "inode #%lu logical block %llu mapped to %llu " | 1136 | ext4_error_inode(func, inode, |
1138 | "(size %d)", inode->i_ino, | 1137 | "lblock %lu mapped to illegal pblock %llu " |
1139 | (unsigned long long) logical, | 1138 | "(length %d)", (unsigned long) map->m_lblk, |
1140 | (unsigned long long) phys, len); | 1139 | map->m_pblk, map->m_len); |
1141 | return -EIO; | 1140 | return -EIO; |
1142 | } | 1141 | } |
1143 | return 0; | 1142 | return 0; |
@@ -1245,8 +1244,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, | |||
1245 | up_read((&EXT4_I(inode)->i_data_sem)); | 1244 | up_read((&EXT4_I(inode)->i_data_sem)); |
1246 | 1245 | ||
1247 | if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) { | 1246 | if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) { |
1248 | int ret = check_block_validity(inode, "file system corruption", | 1247 | int ret = check_block_validity(inode, __func__, map); |
1249 | map->m_lblk, map->m_pblk, retval); | ||
1250 | if (ret != 0) | 1248 | if (ret != 0) |
1251 | return ret; | 1249 | return ret; |
1252 | } | 1250 | } |
@@ -1326,10 +1324,9 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, | |||
1326 | 1324 | ||
1327 | up_write((&EXT4_I(inode)->i_data_sem)); | 1325 | up_write((&EXT4_I(inode)->i_data_sem)); |
1328 | if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) { | 1326 | if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) { |
1329 | int ret = check_block_validity(inode, "file system " | 1327 | int ret = check_block_validity(inode, |
1330 | "corruption after allocation", | 1328 | "ext4_map_blocks_after_alloc", |
1331 | map->m_lblk, map->m_pblk, | 1329 | map); |
1332 | retval); | ||
1333 | if (ret != 0) | 1330 | if (ret != 0) |
1334 | return ret; | 1331 | return ret; |
1335 | } | 1332 | } |
@@ -4327,10 +4324,9 @@ static int ext4_clear_blocks(handle_t *handle, struct inode *inode, | |||
4327 | 4324 | ||
4328 | if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), block_to_free, | 4325 | if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), block_to_free, |
4329 | count)) { | 4326 | count)) { |
4330 | ext4_error(inode->i_sb, "inode #%lu: " | 4327 | EXT4_ERROR_INODE(inode, "attempt to clear invalid " |
4331 | "attempt to clear blocks %llu len %lu, invalid", | 4328 | "blocks %llu len %lu", |
4332 | inode->i_ino, (unsigned long long) block_to_free, | 4329 | (unsigned long long) block_to_free, count); |
4333 | count); | ||
4334 | return 1; | 4330 | return 1; |
4335 | } | 4331 | } |
4336 | 4332 | ||
@@ -4435,11 +4431,10 @@ static void ext4_free_data(handle_t *handle, struct inode *inode, | |||
4435 | if ((EXT4_JOURNAL(inode) == NULL) || bh2jh(this_bh)) | 4431 | if ((EXT4_JOURNAL(inode) == NULL) || bh2jh(this_bh)) |
4436 | ext4_handle_dirty_metadata(handle, inode, this_bh); | 4432 | ext4_handle_dirty_metadata(handle, inode, this_bh); |
4437 | else | 4433 | else |
4438 | ext4_error(inode->i_sb, | 4434 | EXT4_ERROR_INODE(inode, |
4439 | "circular indirect block detected, " | 4435 | "circular indirect block detected at " |
4440 | "inode=%lu, block=%llu", | 4436 | "block %llu", |
4441 | inode->i_ino, | 4437 | (unsigned long long) this_bh->b_blocknr); |
4442 | (unsigned long long) this_bh->b_blocknr); | ||
4443 | } | 4438 | } |
4444 | } | 4439 | } |
4445 | 4440 | ||
@@ -4477,11 +4472,10 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode, | |||
4477 | 4472 | ||
4478 | if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), | 4473 | if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), |
4479 | nr, 1)) { | 4474 | nr, 1)) { |
4480 | ext4_error(inode->i_sb, | 4475 | EXT4_ERROR_INODE(inode, |
4481 | "indirect mapped block in inode " | 4476 | "invalid indirect mapped " |
4482 | "#%lu invalid (level %d, blk #%lu)", | 4477 | "block %lu (level %d)", |
4483 | inode->i_ino, depth, | 4478 | (unsigned long) nr, depth); |
4484 | (unsigned long) nr); | ||
4485 | break; | 4479 | break; |
4486 | } | 4480 | } |
4487 | 4481 | ||
@@ -4493,9 +4487,9 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode, | |||
4493 | * (should be rare). | 4487 | * (should be rare). |
4494 | */ | 4488 | */ |
4495 | if (!bh) { | 4489 | if (!bh) { |
4496 | ext4_error(inode->i_sb, | 4490 | EXT4_ERROR_INODE(inode, |
4497 | "Read failure, inode=%lu, block=%llu", | 4491 | "Read failure block=%llu", |
4498 | inode->i_ino, nr); | 4492 | (unsigned long long) nr); |
4499 | continue; | 4493 | continue; |
4500 | } | 4494 | } |
4501 | 4495 | ||
@@ -4810,8 +4804,8 @@ static int __ext4_get_inode_loc(struct inode *inode, | |||
4810 | 4804 | ||
4811 | bh = sb_getblk(sb, block); | 4805 | bh = sb_getblk(sb, block); |
4812 | if (!bh) { | 4806 | if (!bh) { |
4813 | ext4_error(sb, "unable to read inode block - " | 4807 | EXT4_ERROR_INODE(inode, "unable to read inode block - " |
4814 | "inode=%lu, block=%llu", inode->i_ino, block); | 4808 | "block %llu", block); |
4815 | return -EIO; | 4809 | return -EIO; |
4816 | } | 4810 | } |
4817 | if (!buffer_uptodate(bh)) { | 4811 | if (!buffer_uptodate(bh)) { |
@@ -4909,8 +4903,8 @@ make_io: | |||
4909 | submit_bh(READ_META, bh); | 4903 | submit_bh(READ_META, bh); |
4910 | wait_on_buffer(bh); | 4904 | wait_on_buffer(bh); |
4911 | if (!buffer_uptodate(bh)) { | 4905 | if (!buffer_uptodate(bh)) { |
4912 | ext4_error(sb, "unable to read inode block - inode=%lu," | 4906 | EXT4_ERROR_INODE(inode, "unable to read inode " |
4913 | " block=%llu", inode->i_ino, block); | 4907 | "block %llu", block); |
4914 | brelse(bh); | 4908 | brelse(bh); |
4915 | return -EIO; | 4909 | return -EIO; |
4916 | } | 4910 | } |
@@ -5121,8 +5115,8 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) | |||
5121 | ret = 0; | 5115 | ret = 0; |
5122 | if (ei->i_file_acl && | 5116 | if (ei->i_file_acl && |
5123 | !ext4_data_block_valid(EXT4_SB(sb), ei->i_file_acl, 1)) { | 5117 | !ext4_data_block_valid(EXT4_SB(sb), ei->i_file_acl, 1)) { |
5124 | ext4_error(sb, "bad extended attribute block %llu inode #%lu", | 5118 | EXT4_ERROR_INODE(inode, "bad extended attribute block %llu", |
5125 | ei->i_file_acl, inode->i_ino); | 5119 | ei->i_file_acl); |
5126 | ret = -EIO; | 5120 | ret = -EIO; |
5127 | goto bad_inode; | 5121 | goto bad_inode; |
5128 | } else if (ei->i_flags & EXT4_EXTENTS_FL) { | 5122 | } else if (ei->i_flags & EXT4_EXTENTS_FL) { |
@@ -5167,8 +5161,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) | |||
5167 | new_decode_dev(le32_to_cpu(raw_inode->i_block[1]))); | 5161 | new_decode_dev(le32_to_cpu(raw_inode->i_block[1]))); |
5168 | } else { | 5162 | } else { |
5169 | ret = -EIO; | 5163 | ret = -EIO; |
5170 | ext4_error(inode->i_sb, "bogus i_mode (%o) for inode=%lu", | 5164 | EXT4_ERROR_INODE(inode, "bogus i_mode (%o)", inode->i_mode); |
5171 | inode->i_mode, inode->i_ino); | ||
5172 | goto bad_inode; | 5165 | goto bad_inode; |
5173 | } | 5166 | } |
5174 | brelse(iloc.bh); | 5167 | brelse(iloc.bh); |
@@ -5406,9 +5399,9 @@ int ext4_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
5406 | if (wbc->sync_mode == WB_SYNC_ALL) | 5399 | if (wbc->sync_mode == WB_SYNC_ALL) |
5407 | sync_dirty_buffer(iloc.bh); | 5400 | sync_dirty_buffer(iloc.bh); |
5408 | if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) { | 5401 | if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) { |
5409 | ext4_error(inode->i_sb, "IO error syncing inode, " | 5402 | EXT4_ERROR_INODE(inode, |
5410 | "inode=%lu, block=%llu", inode->i_ino, | 5403 | "IO error syncing inode (block=%llu)", |
5411 | (unsigned long long)iloc.bh->b_blocknr); | 5404 | (unsigned long long) iloc.bh->b_blocknr); |
5412 | err = -EIO; | 5405 | err = -EIO; |
5413 | } | 5406 | } |
5414 | brelse(iloc.bh); | 5407 | brelse(iloc.bh); |