ext4: Convert calls of ext4_error() to EXT4_ERROR_INODE()
Theodore Ts'o
maintainerPATCH 1/1 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" <[email protected]>
--- fs/ext4/dir.c | 10 ++--- fs/ext4/ext4.h | 4 +- fs/ext4/extents.c | 10 ++--- fs/ext4/inode.c | 83 ++++++++++++++++++++++-------------------------- fs/ext4/move_extent.c | 8 ++-- fs/ext4/namei.c | 39 ++++++++++------------ fs/ext4/xattr.c | 35 +++++++++----------- 7 files changed, 86 insertions(+), 103 deletions(-)
fs/ext4/dir.c +4 -6
@@ -83,11 +83,10 @@ int ext4_check_dir_entry(const char *function, struct inode *dir, error_msg ="inode out of bounds" ;if (error_msg !=NULL ) -__ext4_error (dir->i_sb, function, -"bad entry in directory #%lu: %s - block=%llu" +ext4_error_inode (function, dir, +"bad entry in directory: %s - block=%llu" "offset=%u(%u), inode=%u, rec_len=%d, name_len=%d" , - dir->i_ino, error_msg, - (unsigned long long ) bh->b_blocknr, + error_msg, (unsigned long long ) bh->b_blocknr, (unsigned ) (offset%bh->b_size), offset,le32_to_cpu (de->inode), rlen, de->name_len);
@@ -152,9 +151,8 @@ static int ext4_readdir(struct file *filp,*/ if (!bh) {if (!dir_has_error) { -ext4_error (sb,"directory #%lu " +EXT4_ERROR_INODE (inode,"directory " "contains a hole at offset %Lu" , - inode->i_ino, (unsigned long long ) filp->f_pos); dir_has_error =1 ; }
fs/ext4/ext4.h +2 -2
@@ -54,10 +54,10 @@#endif #define EXT4_ERROR_INODE(inode, fmt, a...) \ - ext4_error_inode(__func__, (inode), (fmt), ## a); + ext4_error_inode(__func__, (inode), (fmt), ## a) #define EXT4_ERROR_FILE(file, fmt, a...) \ - ext4_error_file(__func__, (file), (fmt), ## a); + ext4_error_file(__func__, (file), (fmt), ## a)/* data type for block offset of block group */ typedef int ext4_grpblk_t ;
fs/ext4/extents.c +4 -6
@@ -439,10 +439,10 @@ static int __ext4_ext_check(const char *function, struct inode *inode,return 0 ; corrupted: -__ext4_error (inode->i_sb, function, -"bad header/extent in inode #%lu: %s - magic %x, " +ext4_error_inode (function, inode, +"bad header/extent: %s - magic %x, " "entries %u, max %u(%u), depth %u(%u)" , - inode->i_ino, error_msg,le16_to_cpu (eh->eh_magic), + error_msg,le16_to_cpu (eh->eh_magic),le16_to_cpu (eh->eh_entries),le16_to_cpu (eh->eh_max), max,le16_to_cpu (eh->eh_depth), depth);
@@ -1622,9 +1622,7 @@ int ext4_ext_try_to_merge(struct inode *inode, merge_done =1 ;WARN_ON (eh->eh_entries ==0 );if (!eh->eh_entries) -ext4_error (inode->i_sb, -"inode#%lu, eh->eh_entries = 0!" , - inode->i_ino); +EXT4_ERROR_INODE (inode,"eh->eh_entries = 0!" ); }return merge_done;
fs/ext4/inode.c +38 -45
162 lines not on this page · raw message
fs/ext4/move_extent.c +4 -4
@@ -530,7 +530,7 @@ mext_leaf_block(handle_t *handle, struct inode *orig_inode,* new_ext |-------| */ if (le32_to_cpu (oext->ee_block) + oext_alen -1 < new_ext_end) { - ext4_error(orig_inode->i_sb, + EXT4_ERROR_INODE(orig_inode, "new_ext_end(%u) should be less than or equal to " "oext->ee_block(%u) + oext_alen(%d) - 1", new_ext_end, le32_to_cpu(oext->ee_block),
@@ -693,12 +693,12 @@ mext_replace_branches(handle_t *handle, struct inode *orig_inode,while (1 ) {/* The extent for donor must be found. */ if (!dext) { -ext4_error (donor_inode->i_sb, +EXT4_ERROR_INODE (donor_inode,"The extent for donor must be found" ); *err = -EIO ; goto out; }else if (donor_off !=le32_to_cpu (tmp_dext.ee_block)) { - ext4_error(donor_inode->i_sb, + EXT4_ERROR_INODE(donor_inode, "Donor offset(%u) and the first block of donor " "extent(%u) should be equal", donor_off,
@@ -1355,7 +1355,7 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp,if (ret1 <0 )break ;if (*moved_len > len) { -ext4_error (orig_inode->i_sb, +EXT4_ERROR_INODE (orig_inode,"We replaced blocks too much! " "sum of replaced: %llu requested: %llu" , *moved_len, len);
fs/ext4/namei.c +18 -21
@@ -943,8 +943,8 @@ restart:wait_on_buffer (bh);if (!buffer_uptodate (bh)) {/* read error, skip block & hope for the best */ -ext4_error (sb,"reading directory #%lu offset %lu" , - dir->i_ino, (unsigned long )block); +EXT4_ERROR_INODE (dir,"reading directory lblock %lu" , + (unsigned long ) block);brelse (bh); goto next; }
@@ -1066,15 +1066,15 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, stru__u32 ino =le32_to_cpu (de->inode);brelse (bh);if (!ext4_valid_inum (dir->i_sb, ino)) { -ext4_error (dir->i_sb,"bad inode number: %u" , ino); +EXT4_ERROR_INODE (dir,"bad inode number: %u" , ino);return ERR_PTR (-EIO ); } inode =ext4_iget (dir->i_sb, ino);if (unlikely (IS_ERR (inode))) {if (PTR_ERR (inode) == -ESTALE ) { -ext4_error (dir->i_sb, -"deleted inode referenced: %u" , - ino); +EXT4_ERROR_INODE (dir, +"deleted inode referenced: %u" , + ino);return ERR_PTR (-EIO ); }else {return ERR_CAST (inode);
@@ -1104,8 +1104,8 @@ struct dentry *ext4_get_parent(struct dentry *child)brelse (bh);if (!ext4_valid_inum (child->d_inode->i_sb, ino)) { -ext4_error (child->d_inode->i_sb, -"bad inode number: %u" , ino); +EXT4_ERROR_INODE (child->d_inode, +"bad parent inode number: %u" , ino);return ERR_PTR (-EIO ); }
@@ -1404,9 +1404,7 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry, de = (struct ext4_dir_entry_2 *)((char *)fde +ext4_rec_len_from_disk (fde->rec_len, blocksize));if ((char *) de >= (((char *) root) + blocksize)) { -ext4_error (dir->i_sb, -"invalid rec_len for '..' in inode %lu" , - dir->i_ino); +EXT4_ERROR_INODE (dir,"invalid rec_len for '..'" );brelse (bh);return -EIO ; }
@@ -1915,9 +1913,8 @@ static int empty_dir(struct inode *inode)if (inode->i_size <EXT4_DIR_REC_LEN (1 ) +EXT4_DIR_REC_LEN (2 ) || !(bh =ext4_bread (NULL , inode,0 ,0 , &err))) {if (err) -ext4_error (inode->i_sb, -"error %d reading directory #%lu offset 0" , - err, inode->i_ino); +EXT4_ERROR_INODE (inode, +"error %d reading directory lblock 0" , err);else ext4_warning(inode->i_sb, "bad directory (dir #%lu) - no data block",
@@ -1941,17 +1938,17 @@ static int empty_dir(struct inode *inode) de =ext4_next_entry (de1, sb->s_blocksize);while (offset < inode->i_size) {if (!bh || - (void *) de >= (void *) (bh->b_data+sb->s_blocksize)) { + (void *) de >= (void *) (bh->b_data+sb->s_blocksize)) { +unsigned int lblock; err =0 ;brelse (bh); - bh =ext4_bread (NULL , inode, - offset >>EXT4_BLOCK_SIZE_BITS (sb),0 , &err); + lblock = offset >>EXT4_BLOCK_SIZE_BITS (sb); + bh =ext4_bread (NULL , inode, lblock,0 , &err);if (!bh) {if (err) -ext4_error (sb, -"error %d reading directory" -" #%lu offset %u" , - err, inode->i_ino, offset); +EXT4_ERROR_INODE (inode, +"error %d reading directory " +"lblock %u" , err, lblock); offset += sb->s_blocksize;continue ; }
fs/ext4/xattr.c +16 -19
@@ -228,9 +228,8 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name, atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));if (ext4_xattr_check_block (bh)) { bad_block: -ext4_error (inode->i_sb, -"inode %lu: bad block %llu" , inode->i_ino, -EXT4_I (inode)->i_file_acl); +EXT4_ERROR_INODE (inode,"bad block %llu" , +EXT4_I (inode)->i_file_acl); error = -EIO ; goto cleanup; }
@@ -372,9 +371,8 @@ ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size)ea_bdebug (bh,"b_count=%d, refcount=%d" ,atomic_read (&(bh->b_count)),le32_to_cpu (BHDR (bh)->h_refcount));if (ext4_xattr_check_block (bh)) { -ext4_error (inode->i_sb, -"inode %lu: bad block %llu" , inode->i_ino, -EXT4_I (inode)->i_file_acl); +EXT4_ERROR_INODE (inode,"bad block %llu" , +EXT4_I (inode)->i_file_acl); error = -EIO ; goto cleanup; }
@@ -666,8 +664,8 @@ ext4_xattr_block_find(struct inode *inode, struct ext4_xattr_info *i,atomic_read (&(bs->bh->b_count)), le32_to_cpu(BHDR(bs->bh)->h_refcount));if (ext4_xattr_check_block (bs->bh)) { -ext4_error (sb,"inode %lu: bad block %llu" , - inode->i_ino,EXT4_I (inode)->i_file_acl); +EXT4_ERROR_INODE (inode,"bad block %llu" , +EXT4_I (inode)->i_file_acl); error = -EIO ; goto cleanup; }
@@ -880,8 +878,8 @@ cleanup_dquot: goto cleanup; bad_block: -ext4_error (inode->i_sb,"inode %lu: bad block %llu" , - inode->i_ino,EXT4_I (inode)->i_file_acl); +EXT4_ERROR_INODE (inode,"bad block %llu" , +EXT4_I (inode)->i_file_acl); goto cleanup;#undef header
@@ -1194,8 +1192,8 @@ retry:if (!bh) goto cleanup;if (ext4_xattr_check_block (bh)) { -ext4_error (inode->i_sb,"inode %lu: bad block %llu" , - inode->i_ino,EXT4_I (inode)->i_file_acl); +EXT4_ERROR_INODE (inode,"bad block %llu" , +EXT4_I (inode)->i_file_acl); error = -EIO ; goto cleanup; }
@@ -1372,14 +1370,14 @@ ext4_xattr_delete_inode(handle_t *handle, struct inode *inode) goto cleanup; bh =sb_bread (inode->i_sb,EXT4_I (inode)->i_file_acl);if (!bh) { -ext4_error (inode->i_sb,"inode %lu: block %llu read error" , - inode->i_ino,EXT4_I (inode)->i_file_acl); +EXT4_ERROR_INODE (inode,"block %llu read error" , +EXT4_I (inode)->i_file_acl); goto cleanup; }if (BHDR (bh)->h_magic !=cpu_to_le32 (EXT4_XATTR_MAGIC ) ||BHDR (bh)->h_blocks !=cpu_to_le32 (1 )) { -ext4_error (inode->i_sb,"inode %lu: bad block %llu" , - inode->i_ino,EXT4_I (inode)->i_file_acl); +EXT4_ERROR_INODE (inode,"bad block %llu" , +EXT4_I (inode)->i_file_acl); goto cleanup; }ext4_xattr_release_block (handle, inode, bh);
@@ -1504,9 +1502,8 @@ again: } bh =sb_bread (inode->i_sb, ce->e_block);if (!bh) { -ext4_error (inode->i_sb, -"inode %lu: block %lu read error" , - inode->i_ino, (unsigned long ) ce->e_block); +EXT4_ERROR_INODE (inode,"block %lu read error" , + (unsigned long ) ce->e_block); }else if (le32_to_cpu (BHDR (bh)->h_refcount) >=EXT4_XATTR_REFCOUNT_MAX ) { ea_idebug(inode, "block %lu refcount %d>=%d",
Signature · 1 line
1.6.6.1.1.g974db.dirty