Commit 17a5b9ab authored by Goldwyn Rodrigues's avatar Goldwyn Rodrigues Committed by Linus Torvalds

ocfs2: acknowledge return value of ocfs2_error()

Caveat: This may return -EROFS for a read case, which seems wrong.  This
is happening even without this patch series though.  Should we convert
EROFS to EIO?
Signed-off-by: default avatarGoldwyn Rodrigues <rgoldwyn@suse.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7d0fb914
...@@ -908,32 +908,32 @@ static int ocfs2_validate_extent_block(struct super_block *sb, ...@@ -908,32 +908,32 @@ static int ocfs2_validate_extent_block(struct super_block *sb,
*/ */
if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) {
ocfs2_error(sb, rc = ocfs2_error(sb,
"Extent block #%llu has bad signature %.*s", "Extent block #%llu has bad signature %.*s",
(unsigned long long)bh->b_blocknr, 7, (unsigned long long)bh->b_blocknr, 7,
eb->h_signature); eb->h_signature);
return -EINVAL; goto bail;
} }
if (le64_to_cpu(eb->h_blkno) != bh->b_blocknr) { if (le64_to_cpu(eb->h_blkno) != bh->b_blocknr) {
ocfs2_error(sb, rc = ocfs2_error(sb,
"Extent block #%llu has an invalid h_blkno " "Extent block #%llu has an invalid h_blkno "
"of %llu", "of %llu",
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
(unsigned long long)le64_to_cpu(eb->h_blkno)); (unsigned long long)le64_to_cpu(eb->h_blkno));
return -EINVAL; goto bail;
} }
if (le32_to_cpu(eb->h_fs_generation) != OCFS2_SB(sb)->fs_generation) { if (le32_to_cpu(eb->h_fs_generation) != OCFS2_SB(sb)->fs_generation) {
ocfs2_error(sb, rc = ocfs2_error(sb,
"Extent block #%llu has an invalid " "Extent block #%llu has an invalid "
"h_fs_generation of #%u", "h_fs_generation of #%u",
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
le32_to_cpu(eb->h_fs_generation)); le32_to_cpu(eb->h_fs_generation));
return -EINVAL; goto bail;
} }
bail:
return 0; return rc;
} }
int ocfs2_read_extent_block(struct ocfs2_caching_info *ci, u64 eb_blkno, int ocfs2_read_extent_block(struct ocfs2_caching_info *ci, u64 eb_blkno,
......
...@@ -480,8 +480,7 @@ static int ocfs2_check_dir_trailer(struct inode *dir, struct buffer_head *bh) ...@@ -480,8 +480,7 @@ static int ocfs2_check_dir_trailer(struct inode *dir, struct buffer_head *bh)
trailer = ocfs2_trailer_from_bh(bh, dir->i_sb); trailer = ocfs2_trailer_from_bh(bh, dir->i_sb);
if (!OCFS2_IS_VALID_DIR_TRAILER(trailer)) { if (!OCFS2_IS_VALID_DIR_TRAILER(trailer)) {
rc = -EINVAL; rc = ocfs2_error(dir->i_sb,
ocfs2_error(dir->i_sb,
"Invalid dirblock #%llu: " "Invalid dirblock #%llu: "
"signature = %.*s\n", "signature = %.*s\n",
(unsigned long long)bh->b_blocknr, 7, (unsigned long long)bh->b_blocknr, 7,
...@@ -489,8 +488,7 @@ static int ocfs2_check_dir_trailer(struct inode *dir, struct buffer_head *bh) ...@@ -489,8 +488,7 @@ static int ocfs2_check_dir_trailer(struct inode *dir, struct buffer_head *bh)
goto out; goto out;
} }
if (le64_to_cpu(trailer->db_blkno) != bh->b_blocknr) { if (le64_to_cpu(trailer->db_blkno) != bh->b_blocknr) {
rc = -EINVAL; rc = ocfs2_error(dir->i_sb,
ocfs2_error(dir->i_sb,
"Directory block #%llu has an invalid " "Directory block #%llu has an invalid "
"db_blkno of %llu", "db_blkno of %llu",
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
...@@ -499,8 +497,7 @@ static int ocfs2_check_dir_trailer(struct inode *dir, struct buffer_head *bh) ...@@ -499,8 +497,7 @@ static int ocfs2_check_dir_trailer(struct inode *dir, struct buffer_head *bh)
} }
if (le64_to_cpu(trailer->db_parent_dinode) != if (le64_to_cpu(trailer->db_parent_dinode) !=
OCFS2_I(dir)->ip_blkno) { OCFS2_I(dir)->ip_blkno) {
rc = -EINVAL; rc = ocfs2_error(dir->i_sb,
ocfs2_error(dir->i_sb,
"Directory block #%llu on dinode " "Directory block #%llu on dinode "
"#%llu has an invalid parent_dinode " "#%llu has an invalid parent_dinode "
"of %llu", "of %llu",
...@@ -604,14 +601,13 @@ static int ocfs2_validate_dx_root(struct super_block *sb, ...@@ -604,14 +601,13 @@ static int ocfs2_validate_dx_root(struct super_block *sb,
} }
if (!OCFS2_IS_VALID_DX_ROOT(dx_root)) { if (!OCFS2_IS_VALID_DX_ROOT(dx_root)) {
ocfs2_error(sb, ret = ocfs2_error(sb,
"Dir Index Root # %llu has bad signature %.*s", "Dir Index Root # %llu has bad signature %.*s",
(unsigned long long)le64_to_cpu(dx_root->dr_blkno), (unsigned long long)le64_to_cpu(dx_root->dr_blkno),
7, dx_root->dr_signature); 7, dx_root->dr_signature);
return -EINVAL;
} }
return 0; return ret;
} }
static int ocfs2_read_dx_root(struct inode *dir, struct ocfs2_dinode *di, static int ocfs2_read_dx_root(struct inode *dir, struct ocfs2_dinode *di,
...@@ -648,12 +644,11 @@ static int ocfs2_validate_dx_leaf(struct super_block *sb, ...@@ -648,12 +644,11 @@ static int ocfs2_validate_dx_leaf(struct super_block *sb,
} }
if (!OCFS2_IS_VALID_DX_LEAF(dx_leaf)) { if (!OCFS2_IS_VALID_DX_LEAF(dx_leaf)) {
ocfs2_error(sb, "Dir Index Leaf has bad signature %.*s", ret = ocfs2_error(sb, "Dir Index Leaf has bad signature %.*s",
7, dx_leaf->dl_signature); 7, dx_leaf->dl_signature);
return -EROFS;
} }
return 0; return ret;
} }
static int ocfs2_read_dx_leaf(struct inode *dir, u64 blkno, static int ocfs2_read_dx_leaf(struct inode *dir, u64 blkno,
...@@ -812,11 +807,10 @@ static int ocfs2_dx_dir_lookup_rec(struct inode *inode, ...@@ -812,11 +807,10 @@ static int ocfs2_dx_dir_lookup_rec(struct inode *inode,
el = &eb->h_list; el = &eb->h_list;
if (el->l_tree_depth) { if (el->l_tree_depth) {
ocfs2_error(inode->i_sb, ret = ocfs2_error(inode->i_sb,
"Inode %lu has non zero tree depth in " "Inode %lu has non zero tree depth in "
"btree tree block %llu\n", inode->i_ino, "btree tree block %llu\n", inode->i_ino,
(unsigned long long)eb_bh->b_blocknr); (unsigned long long)eb_bh->b_blocknr);
ret = -EROFS;
goto out; goto out;
} }
} }
...@@ -832,11 +826,10 @@ static int ocfs2_dx_dir_lookup_rec(struct inode *inode, ...@@ -832,11 +826,10 @@ static int ocfs2_dx_dir_lookup_rec(struct inode *inode,
} }
if (!found) { if (!found) {
ocfs2_error(inode->i_sb, "Inode %lu has bad extent " ret = ocfs2_error(inode->i_sb, "Inode %lu has bad extent "
"record (%u, %u, 0) in btree", inode->i_ino, "record (%u, %u, 0) in btree", inode->i_ino,
le32_to_cpu(rec->e_cpos), le32_to_cpu(rec->e_cpos),
ocfs2_rec_clusters(el, rec)); ocfs2_rec_clusters(el, rec));
ret = -EROFS;
goto out; goto out;
} }
......
...@@ -1352,21 +1352,21 @@ int ocfs2_validate_inode_block(struct super_block *sb, ...@@ -1352,21 +1352,21 @@ int ocfs2_validate_inode_block(struct super_block *sb,
rc = -EINVAL; rc = -EINVAL;
if (!OCFS2_IS_VALID_DINODE(di)) { if (!OCFS2_IS_VALID_DINODE(di)) {
ocfs2_error(sb, "Invalid dinode #%llu: signature = %.*s\n", rc = ocfs2_error(sb, "Invalid dinode #%llu: signature = %.*s\n",
(unsigned long long)bh->b_blocknr, 7, (unsigned long long)bh->b_blocknr, 7,
di->i_signature); di->i_signature);
goto bail; goto bail;
} }
if (le64_to_cpu(di->i_blkno) != bh->b_blocknr) { if (le64_to_cpu(di->i_blkno) != bh->b_blocknr) {
ocfs2_error(sb, "Invalid dinode #%llu: i_blkno is %llu\n", rc = ocfs2_error(sb, "Invalid dinode #%llu: i_blkno is %llu\n",
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
(unsigned long long)le64_to_cpu(di->i_blkno)); (unsigned long long)le64_to_cpu(di->i_blkno));
goto bail; goto bail;
} }
if (!(di->i_flags & cpu_to_le32(OCFS2_VALID_FL))) { if (!(di->i_flags & cpu_to_le32(OCFS2_VALID_FL))) {
ocfs2_error(sb, rc = ocfs2_error(sb,
"Invalid dinode #%llu: OCFS2_VALID_FL not set\n", "Invalid dinode #%llu: OCFS2_VALID_FL not set\n",
(unsigned long long)bh->b_blocknr); (unsigned long long)bh->b_blocknr);
goto bail; goto bail;
...@@ -1374,7 +1374,7 @@ int ocfs2_validate_inode_block(struct super_block *sb, ...@@ -1374,7 +1374,7 @@ int ocfs2_validate_inode_block(struct super_block *sb,
if (le32_to_cpu(di->i_fs_generation) != if (le32_to_cpu(di->i_fs_generation) !=
OCFS2_SB(sb)->fs_generation) { OCFS2_SB(sb)->fs_generation) {
ocfs2_error(sb, rc = ocfs2_error(sb,
"Invalid dinode #%llu: fs_generation is %u\n", "Invalid dinode #%llu: fs_generation is %u\n",
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
le32_to_cpu(di->i_fs_generation)); le32_to_cpu(di->i_fs_generation));
......
...@@ -99,11 +99,10 @@ static int __ocfs2_move_extent(handle_t *handle, ...@@ -99,11 +99,10 @@ static int __ocfs2_move_extent(handle_t *handle,
index = ocfs2_search_extent_list(el, cpos); index = ocfs2_search_extent_list(el, cpos);
if (index == -1) { if (index == -1) {
ocfs2_error(inode->i_sb, ret = ocfs2_error(inode->i_sb,
"Inode %llu has an extent at cpos %u which can no " "Inode %llu has an extent at cpos %u which can no "
"longer be found.\n", "longer be found.\n",
(unsigned long long)ino, cpos); (unsigned long long)ino, cpos);
ret = -EROFS;
goto out; goto out;
} }
......
...@@ -102,32 +102,32 @@ static int ocfs2_validate_refcount_block(struct super_block *sb, ...@@ -102,32 +102,32 @@ static int ocfs2_validate_refcount_block(struct super_block *sb,
if (!OCFS2_IS_VALID_REFCOUNT_BLOCK(rb)) { if (!OCFS2_IS_VALID_REFCOUNT_BLOCK(rb)) {
ocfs2_error(sb, rc = ocfs2_error(sb,
"Refcount block #%llu has bad signature %.*s", "Refcount block #%llu has bad signature %.*s",
(unsigned long long)bh->b_blocknr, 7, (unsigned long long)bh->b_blocknr, 7,
rb->rf_signature); rb->rf_signature);
return -EINVAL; goto out;
} }
if (le64_to_cpu(rb->rf_blkno) != bh->b_blocknr) { if (le64_to_cpu(rb->rf_blkno) != bh->b_blocknr) {
ocfs2_error(sb, rc = ocfs2_error(sb,
"Refcount block #%llu has an invalid rf_blkno " "Refcount block #%llu has an invalid rf_blkno "
"of %llu", "of %llu",
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
(unsigned long long)le64_to_cpu(rb->rf_blkno)); (unsigned long long)le64_to_cpu(rb->rf_blkno));
return -EINVAL; goto out;
} }
if (le32_to_cpu(rb->rf_fs_generation) != OCFS2_SB(sb)->fs_generation) { if (le32_to_cpu(rb->rf_fs_generation) != OCFS2_SB(sb)->fs_generation) {
ocfs2_error(sb, rc = ocfs2_error(sb,
"Refcount block #%llu has an invalid " "Refcount block #%llu has an invalid "
"rf_fs_generation of #%u", "rf_fs_generation of #%u",
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
le32_to_cpu(rb->rf_fs_generation)); le32_to_cpu(rb->rf_fs_generation));
return -EINVAL; goto out;
} }
out:
return 0; return rc;
} }
static int ocfs2_read_refcount_block(struct ocfs2_caching_info *ci, static int ocfs2_read_refcount_block(struct ocfs2_caching_info *ci,
...@@ -1102,12 +1102,11 @@ static int ocfs2_get_refcount_rec(struct ocfs2_caching_info *ci, ...@@ -1102,12 +1102,11 @@ static int ocfs2_get_refcount_rec(struct ocfs2_caching_info *ci,
el = &eb->h_list; el = &eb->h_list;
if (el->l_tree_depth) { if (el->l_tree_depth) {
ocfs2_error(sb, ret = ocfs2_error(sb,
"refcount tree %llu has non zero tree " "refcount tree %llu has non zero tree "
"depth in leaf btree tree block %llu\n", "depth in leaf btree tree block %llu\n",
(unsigned long long)ocfs2_metadata_cache_owner(ci), (unsigned long long)ocfs2_metadata_cache_owner(ci),
(unsigned long long)eb_bh->b_blocknr); (unsigned long long)eb_bh->b_blocknr);
ret = -EROFS;
goto out; goto out;
} }
} }
...@@ -2359,10 +2358,9 @@ static int ocfs2_mark_extent_refcounted(struct inode *inode, ...@@ -2359,10 +2358,9 @@ static int ocfs2_mark_extent_refcounted(struct inode *inode,
cpos, len, phys); cpos, len, phys);
if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) { if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) {
ocfs2_error(inode->i_sb, "Inode %lu want to use refcount " ret = ocfs2_error(inode->i_sb, "Inode %lu want to use refcount "
"tree, but the feature bit is not set in the " "tree, but the feature bit is not set in the "
"super block.", inode->i_ino); "super block.", inode->i_ino);
ret = -EROFS;
goto out; goto out;
} }
...@@ -2545,10 +2543,9 @@ int ocfs2_prepare_refcount_change_for_del(struct inode *inode, ...@@ -2545,10 +2543,9 @@ int ocfs2_prepare_refcount_change_for_del(struct inode *inode,
u64 start_cpos = ocfs2_blocks_to_clusters(inode->i_sb, phys_blkno); u64 start_cpos = ocfs2_blocks_to_clusters(inode->i_sb, phys_blkno);
if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) { if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) {
ocfs2_error(inode->i_sb, "Inode %lu want to use refcount " ret = ocfs2_error(inode->i_sb, "Inode %lu want to use refcount "
"tree, but the feature bit is not set in the " "tree, but the feature bit is not set in the "
"super block.", inode->i_ino); "super block.", inode->i_ino);
ret = -EROFS;
goto out; goto out;
} }
...@@ -2672,11 +2669,10 @@ static int ocfs2_refcount_cal_cow_clusters(struct inode *inode, ...@@ -2672,11 +2669,10 @@ static int ocfs2_refcount_cal_cow_clusters(struct inode *inode,
el = &eb->h_list; el = &eb->h_list;
if (el->l_tree_depth) { if (el->l_tree_depth) {
ocfs2_error(inode->i_sb, ret = ocfs2_error(inode->i_sb,
"Inode %lu has non zero tree depth in " "Inode %lu has non zero tree depth in "
"leaf block %llu\n", inode->i_ino, "leaf block %llu\n", inode->i_ino,
(unsigned long long)eb_bh->b_blocknr); (unsigned long long)eb_bh->b_blocknr);
ret = -EROFS;
goto out; goto out;
} }
} }
...@@ -3106,11 +3102,10 @@ static int ocfs2_clear_ext_refcount(handle_t *handle, ...@@ -3106,11 +3102,10 @@ static int ocfs2_clear_ext_refcount(handle_t *handle,
index = ocfs2_search_extent_list(el, cpos); index = ocfs2_search_extent_list(el, cpos);
if (index == -1) { if (index == -1) {
ocfs2_error(sb, ret = ocfs2_error(sb,
"Inode %llu has an extent at cpos %u which can no " "Inode %llu has an extent at cpos %u which can no "
"longer be found.\n", "longer be found.\n",
(unsigned long long)ino, cpos); (unsigned long long)ino, cpos);
ret = -EROFS;
goto out; goto out;
} }
...@@ -3376,10 +3371,9 @@ static int ocfs2_replace_cow(struct ocfs2_cow_context *context) ...@@ -3376,10 +3371,9 @@ static int ocfs2_replace_cow(struct ocfs2_cow_context *context)
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) { if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) {
ocfs2_error(inode->i_sb, "Inode %lu want to use refcount " return ocfs2_error(inode->i_sb, "Inode %lu want to use refcount "
"tree, but the feature bit is not set in the " "tree, but the feature bit is not set in the "
"super block.", inode->i_ino); "super block.", inode->i_ino);
return -EROFS;
} }
ocfs2_init_dealloc_ctxt(&context->dealloc); ocfs2_init_dealloc_ctxt(&context->dealloc);
......
...@@ -171,7 +171,7 @@ static u32 ocfs2_bits_per_group(struct ocfs2_chain_list *cl) ...@@ -171,7 +171,7 @@ static u32 ocfs2_bits_per_group(struct ocfs2_chain_list *cl)
if (resize) \ if (resize) \
mlog(ML_ERROR, fmt "\n", ##__VA_ARGS__); \ mlog(ML_ERROR, fmt "\n", ##__VA_ARGS__); \
else \ else \
ocfs2_error(sb, fmt, ##__VA_ARGS__); \ return ocfs2_error(sb, fmt, ##__VA_ARGS__); \
} while (0) } while (0)
static int ocfs2_validate_gd_self(struct super_block *sb, static int ocfs2_validate_gd_self(struct super_block *sb,
...@@ -184,7 +184,6 @@ static int ocfs2_validate_gd_self(struct super_block *sb, ...@@ -184,7 +184,6 @@ static int ocfs2_validate_gd_self(struct super_block *sb,
do_error("Group descriptor #%llu has bad signature %.*s", do_error("Group descriptor #%llu has bad signature %.*s",
(unsigned long long)bh->b_blocknr, 7, (unsigned long long)bh->b_blocknr, 7,
gd->bg_signature); gd->bg_signature);
return -EINVAL;
} }
if (le64_to_cpu(gd->bg_blkno) != bh->b_blocknr) { if (le64_to_cpu(gd->bg_blkno) != bh->b_blocknr) {
...@@ -192,7 +191,6 @@ static int ocfs2_validate_gd_self(struct super_block *sb, ...@@ -192,7 +191,6 @@ static int ocfs2_validate_gd_self(struct super_block *sb,
"of %llu", "of %llu",
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
(unsigned long long)le64_to_cpu(gd->bg_blkno)); (unsigned long long)le64_to_cpu(gd->bg_blkno));
return -EINVAL;
} }
if (le32_to_cpu(gd->bg_generation) != OCFS2_SB(sb)->fs_generation) { if (le32_to_cpu(gd->bg_generation) != OCFS2_SB(sb)->fs_generation) {
...@@ -200,7 +198,6 @@ static int ocfs2_validate_gd_self(struct super_block *sb, ...@@ -200,7 +198,6 @@ static int ocfs2_validate_gd_self(struct super_block *sb,
"fs_generation of #%u", "fs_generation of #%u",
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
le32_to_cpu(gd->bg_generation)); le32_to_cpu(gd->bg_generation));
return -EINVAL;
} }
if (le16_to_cpu(gd->bg_free_bits_count) > le16_to_cpu(gd->bg_bits)) { if (le16_to_cpu(gd->bg_free_bits_count) > le16_to_cpu(gd->bg_bits)) {
...@@ -209,7 +206,6 @@ static int ocfs2_validate_gd_self(struct super_block *sb, ...@@ -209,7 +206,6 @@ static int ocfs2_validate_gd_self(struct super_block *sb,
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
le16_to_cpu(gd->bg_bits), le16_to_cpu(gd->bg_bits),
le16_to_cpu(gd->bg_free_bits_count)); le16_to_cpu(gd->bg_free_bits_count));
return -EINVAL;
} }
if (le16_to_cpu(gd->bg_bits) > (8 * le16_to_cpu(gd->bg_size))) { if (le16_to_cpu(gd->bg_bits) > (8 * le16_to_cpu(gd->bg_size))) {
...@@ -218,7 +214,6 @@ static int ocfs2_validate_gd_self(struct super_block *sb, ...@@ -218,7 +214,6 @@ static int ocfs2_validate_gd_self(struct super_block *sb,
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
le16_to_cpu(gd->bg_bits), le16_to_cpu(gd->bg_bits),
8 * le16_to_cpu(gd->bg_size)); 8 * le16_to_cpu(gd->bg_size));
return -EINVAL;
} }
return 0; return 0;
...@@ -238,7 +233,6 @@ static int ocfs2_validate_gd_parent(struct super_block *sb, ...@@ -238,7 +233,6 @@ static int ocfs2_validate_gd_parent(struct super_block *sb,
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
(unsigned long long)le64_to_cpu(gd->bg_parent_dinode), (unsigned long long)le64_to_cpu(gd->bg_parent_dinode),
(unsigned long long)le64_to_cpu(di->i_blkno)); (unsigned long long)le64_to_cpu(di->i_blkno));
return -EINVAL;
} }
max_bits = le16_to_cpu(di->id2.i_chain.cl_cpg) * le16_to_cpu(di->id2.i_chain.cl_bpc); max_bits = le16_to_cpu(di->id2.i_chain.cl_cpg) * le16_to_cpu(di->id2.i_chain.cl_bpc);
...@@ -246,7 +240,6 @@ static int ocfs2_validate_gd_parent(struct super_block *sb, ...@@ -246,7 +240,6 @@ static int ocfs2_validate_gd_parent(struct super_block *sb,
do_error("Group descriptor #%llu has bit count of %u", do_error("Group descriptor #%llu has bit count of %u",
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
le16_to_cpu(gd->bg_bits)); le16_to_cpu(gd->bg_bits));
return -EINVAL;
} }
/* In resize, we may meet the case bg_chain == cl_next_free_rec. */ /* In resize, we may meet the case bg_chain == cl_next_free_rec. */
...@@ -257,7 +250,6 @@ static int ocfs2_validate_gd_parent(struct super_block *sb, ...@@ -257,7 +250,6 @@ static int ocfs2_validate_gd_parent(struct super_block *sb,
do_error("Group descriptor #%llu has bad chain %u", do_error("Group descriptor #%llu has bad chain %u",
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
le16_to_cpu(gd->bg_chain)); le16_to_cpu(gd->bg_chain));
return -EINVAL;
} }
return 0; return 0;
...@@ -384,11 +376,10 @@ static int ocfs2_block_group_fill(handle_t *handle, ...@@ -384,11 +376,10 @@ static int ocfs2_block_group_fill(handle_t *handle,
struct super_block * sb = alloc_inode->i_sb; struct super_block * sb = alloc_inode->i_sb;
if (((unsigned long long) bg_bh->b_blocknr) != group_blkno) { if (((unsigned long long) bg_bh->b_blocknr) != group_blkno) {
ocfs2_error(alloc_inode->i_sb, "group block (%llu) != " status = ocfs2_error(alloc_inode->i_sb, "group block (%llu) != "
"b_blocknr (%llu)", "b_blocknr (%llu)",
(unsigned long long)group_blkno, (unsigned long long)group_blkno,
(unsigned long long) bg_bh->b_blocknr); (unsigned long long) bg_bh->b_blocknr);
status = -EIO;
goto bail; goto bail;
} }
...@@ -834,9 +825,8 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb, ...@@ -834,9 +825,8 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
BUG_ON(!OCFS2_IS_VALID_DINODE(fe)); BUG_ON(!OCFS2_IS_VALID_DINODE(fe));
if (!(fe->i_flags & cpu_to_le32(OCFS2_CHAIN_FL))) { if (!(fe->i_flags & cpu_to_le32(OCFS2_CHAIN_FL))) {
ocfs2_error(alloc_inode->i_sb, "Invalid chain allocator %llu", status = ocfs2_error(alloc_inode->i_sb, "Invalid chain allocator %llu",
(unsigned long long)le64_to_cpu(fe->i_blkno)); (unsigned long long)le64_to_cpu(fe->i_blkno));
status = -EIO;
goto bail; goto bail;
} }
...@@ -1370,12 +1360,11 @@ int ocfs2_block_group_set_bits(handle_t *handle, ...@@ -1370,12 +1360,11 @@ int ocfs2_block_group_set_bits(handle_t *handle,
le16_add_cpu(&bg->bg_free_bits_count, -num_bits); le16_add_cpu(&bg->bg_free_bits_count, -num_bits);
if (le16_to_cpu(bg->bg_free_bits_count) > le16_to_cpu(bg->bg_bits)) { if (le16_to_cpu(bg->bg_free_bits_count) > le16_to_cpu(bg->bg_bits)) {
ocfs2_error(alloc_inode->i_sb, "Group descriptor # %llu has bit" return ocfs2_error(alloc_inode->i_sb, "Group descriptor # %llu has bit"
" count %u but claims %u are freed. num_bits %d", " count %u but claims %u are freed. num_bits %d",
(unsigned long long)le64_to_cpu(bg->bg_blkno), (unsigned long long)le64_to_cpu(bg->bg_blkno),
le16_to_cpu(bg->bg_bits), le16_to_cpu(bg->bg_bits),
le16_to_cpu(bg->bg_free_bits_count), num_bits); le16_to_cpu(bg->bg_free_bits_count), num_bits);
return -EROFS;
} }
while(num_bits--) while(num_bits--)
ocfs2_set_bit(bit_off++, bitmap); ocfs2_set_bit(bit_off++, bitmap);
...@@ -1905,13 +1894,12 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac, ...@@ -1905,13 +1894,12 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
if (le32_to_cpu(fe->id1.bitmap1.i_used) >= if (le32_to_cpu(fe->id1.bitmap1.i_used) >=
le32_to_cpu(fe->id1.bitmap1.i_total)) { le32_to_cpu(fe->id1.bitmap1.i_total)) {
ocfs2_error(ac->ac_inode->i_sb, status = ocfs2_error(ac->ac_inode->i_sb,
"Chain allocator dinode %llu has %u used " "Chain allocator dinode %llu has %u used "
"bits but only %u total.", "bits but only %u total.",
(unsigned long long)le64_to_cpu(fe->i_blkno), (unsigned long long)le64_to_cpu(fe->i_blkno),
le32_to_cpu(fe->id1.bitmap1.i_used), le32_to_cpu(fe->id1.bitmap1.i_used),
le32_to_cpu(fe->id1.bitmap1.i_total)); le32_to_cpu(fe->id1.bitmap1.i_total));
status = -EIO;
goto bail; goto bail;
} }
...@@ -2429,12 +2417,11 @@ static int ocfs2_block_group_clear_bits(handle_t *handle, ...@@ -2429,12 +2417,11 @@ static int ocfs2_block_group_clear_bits(handle_t *handle,
} }
le16_add_cpu(&bg->bg_free_bits_count, num_bits); le16_add_cpu(&bg->bg_free_bits_count, num_bits);
if (le16_to_cpu(bg->bg_free_bits_count) > le16_to_cpu(bg->bg_bits)) { if (le16_to_cpu(bg->bg_free_bits_count) > le16_to_cpu(bg->bg_bits)) {
ocfs2_error(alloc_inode->i_sb, "Group descriptor # %llu has bit" return ocfs2_error(alloc_inode->i_sb, "Group descriptor # %llu has bit"
" count %u but claims %u are freed. num_bits %d", " count %u but claims %u are freed. num_bits %d",
(unsigned long long)le64_to_cpu(bg->bg_blkno), (unsigned long long)le64_to_cpu(bg->bg_blkno),
le16_to_cpu(bg->bg_bits), le16_to_cpu(bg->bg_bits),
le16_to_cpu(bg->bg_free_bits_count), num_bits); le16_to_cpu(bg->bg_free_bits_count), num_bits);
return -EROFS;
} }
if (undo_fn) if (undo_fn)
......
...@@ -499,30 +499,27 @@ static int ocfs2_validate_xattr_block(struct super_block *sb, ...@@ -499,30 +499,27 @@ static int ocfs2_validate_xattr_block(struct super_block *sb,
*/ */
if (!OCFS2_IS_VALID_XATTR_BLOCK(xb)) { if (!OCFS2_IS_VALID_XATTR_BLOCK(xb)) {
ocfs2_error(sb, return ocfs2_error(sb,
"Extended attribute block #%llu has bad " "Extended attribute block #%llu has bad "
"signature %.*s", "signature %.*s",
(unsigned long long)bh->b_blocknr, 7, (unsigned long long)bh->b_blocknr, 7,
xb->xb_signature); xb->xb_signature);
return -EINVAL;
} }
if (le64_to_cpu(xb->xb_blkno) != bh->b_blocknr) { if (le64_to_cpu(xb->xb_blkno) != bh->b_blocknr) {
ocfs2_error(sb, return ocfs2_error(sb,
"Extended attribute block #%llu has an " "Extended attribute block #%llu has an "
"invalid xb_blkno of %llu", "invalid xb_blkno of %llu",
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
(unsigned long long)le64_to_cpu(xb->xb_blkno)); (unsigned long long)le64_to_cpu(xb->xb_blkno));
return -EINVAL;
} }
if (le32_to_cpu(xb->xb_fs_generation) != OCFS2_SB(sb)->fs_generation) { if (le32_to_cpu(xb->xb_fs_generation) != OCFS2_SB(sb)->fs_generation) {
ocfs2_error(sb, return ocfs2_error(sb,
"Extended attribute block #%llu has an invalid " "Extended attribute block #%llu has an invalid "
"xb_fs_generation of #%u", "xb_fs_generation of #%u",
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
le32_to_cpu(xb->xb_fs_generation)); le32_to_cpu(xb->xb_fs_generation));
return -EINVAL;
} }
return 0; return 0;
...@@ -3694,11 +3691,10 @@ static int ocfs2_xattr_get_rec(struct inode *inode, ...@@ -3694,11 +3691,10 @@ static int ocfs2_xattr_get_rec(struct inode *inode,
el = &eb->h_list; el = &eb->h_list;
if (el->l_tree_depth) { if (el->l_tree_depth) {
ocfs2_error(inode->i_sb, ret = ocfs2_error(inode->i_sb,
"Inode %lu has non zero tree depth in " "Inode %lu has non zero tree depth in "
"xattr tree block %llu\n", inode->i_ino, "xattr tree block %llu\n", inode->i_ino,
(unsigned long long)eb_bh->b_blocknr); (unsigned long long)eb_bh->b_blocknr);
ret = -EROFS;
goto out; goto out;
} }
} }
...@@ -3713,11 +3709,10 @@ static int ocfs2_xattr_get_rec(struct inode *inode, ...@@ -3713,11 +3709,10 @@ static int ocfs2_xattr_get_rec(struct inode *inode,
} }
if (!e_blkno) { if (!e_blkno) {
ocfs2_error(inode->i_sb, "Inode %lu has bad extent " ret = ocfs2_error(inode->i_sb, "Inode %lu has bad extent "
"record (%u, %u, 0) in xattr", inode->i_ino, "record (%u, %u, 0) in xattr", inode->i_ino,
le32_to_cpu(rec->e_cpos), le32_to_cpu(rec->e_cpos),
ocfs2_rec_clusters(el, rec)); ocfs2_rec_clusters(el, rec));
ret = -EROFS;
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment