Skip to content

Commit 17a5b9a

Browse files
Goldwyn Rodriguestorvalds
authored andcommitted
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: Goldwyn Rodrigues <[email protected]> Cc: Mark Fasheh <[email protected]> Cc: Joel Becker <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 7d0fb91 commit 17a5b9a

File tree

7 files changed

+51
-83
lines changed

7 files changed

+51
-83
lines changed

fs/ocfs2/alloc.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -908,32 +908,32 @@ static int ocfs2_validate_extent_block(struct super_block *sb,
908908
*/
909909

910910
if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) {
911-
ocfs2_error(sb,
911+
rc = ocfs2_error(sb,
912912
"Extent block #%llu has bad signature %.*s",
913913
(unsigned long long)bh->b_blocknr, 7,
914914
eb->h_signature);
915-
return -EINVAL;
915+
goto bail;
916916
}
917917

918918
if (le64_to_cpu(eb->h_blkno) != bh->b_blocknr) {
919-
ocfs2_error(sb,
919+
rc = ocfs2_error(sb,
920920
"Extent block #%llu has an invalid h_blkno "
921921
"of %llu",
922922
(unsigned long long)bh->b_blocknr,
923923
(unsigned long long)le64_to_cpu(eb->h_blkno));
924-
return -EINVAL;
924+
goto bail;
925925
}
926926

927927
if (le32_to_cpu(eb->h_fs_generation) != OCFS2_SB(sb)->fs_generation) {
928-
ocfs2_error(sb,
928+
rc = ocfs2_error(sb,
929929
"Extent block #%llu has an invalid "
930930
"h_fs_generation of #%u",
931931
(unsigned long long)bh->b_blocknr,
932932
le32_to_cpu(eb->h_fs_generation));
933-
return -EINVAL;
933+
goto bail;
934934
}
935-
936-
return 0;
935+
bail:
936+
return rc;
937937
}
938938

939939
int ocfs2_read_extent_block(struct ocfs2_caching_info *ci, u64 eb_blkno,

fs/ocfs2/dir.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -480,17 +480,15 @@ static int ocfs2_check_dir_trailer(struct inode *dir, struct buffer_head *bh)
480480

481481
trailer = ocfs2_trailer_from_bh(bh, dir->i_sb);
482482
if (!OCFS2_IS_VALID_DIR_TRAILER(trailer)) {
483-
rc = -EINVAL;
484-
ocfs2_error(dir->i_sb,
483+
rc = ocfs2_error(dir->i_sb,
485484
"Invalid dirblock #%llu: "
486485
"signature = %.*s\n",
487486
(unsigned long long)bh->b_blocknr, 7,
488487
trailer->db_signature);
489488
goto out;
490489
}
491490
if (le64_to_cpu(trailer->db_blkno) != bh->b_blocknr) {
492-
rc = -EINVAL;
493-
ocfs2_error(dir->i_sb,
491+
rc = ocfs2_error(dir->i_sb,
494492
"Directory block #%llu has an invalid "
495493
"db_blkno of %llu",
496494
(unsigned long long)bh->b_blocknr,
@@ -499,8 +497,7 @@ static int ocfs2_check_dir_trailer(struct inode *dir, struct buffer_head *bh)
499497
}
500498
if (le64_to_cpu(trailer->db_parent_dinode) !=
501499
OCFS2_I(dir)->ip_blkno) {
502-
rc = -EINVAL;
503-
ocfs2_error(dir->i_sb,
500+
rc = ocfs2_error(dir->i_sb,
504501
"Directory block #%llu on dinode "
505502
"#%llu has an invalid parent_dinode "
506503
"of %llu",
@@ -604,14 +601,13 @@ static int ocfs2_validate_dx_root(struct super_block *sb,
604601
}
605602

606603
if (!OCFS2_IS_VALID_DX_ROOT(dx_root)) {
607-
ocfs2_error(sb,
604+
ret = ocfs2_error(sb,
608605
"Dir Index Root # %llu has bad signature %.*s",
609606
(unsigned long long)le64_to_cpu(dx_root->dr_blkno),
610607
7, dx_root->dr_signature);
611-
return -EINVAL;
612608
}
613609

614-
return 0;
610+
return ret;
615611
}
616612

617613
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,
648644
}
649645

650646
if (!OCFS2_IS_VALID_DX_LEAF(dx_leaf)) {
651-
ocfs2_error(sb, "Dir Index Leaf has bad signature %.*s",
647+
ret = ocfs2_error(sb, "Dir Index Leaf has bad signature %.*s",
652648
7, dx_leaf->dl_signature);
653-
return -EROFS;
654649
}
655650

656-
return 0;
651+
return ret;
657652
}
658653

659654
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,
812807
el = &eb->h_list;
813808

814809
if (el->l_tree_depth) {
815-
ocfs2_error(inode->i_sb,
810+
ret = ocfs2_error(inode->i_sb,
816811
"Inode %lu has non zero tree depth in "
817812
"btree tree block %llu\n", inode->i_ino,
818813
(unsigned long long)eb_bh->b_blocknr);
819-
ret = -EROFS;
820814
goto out;
821815
}
822816
}
@@ -832,11 +826,10 @@ static int ocfs2_dx_dir_lookup_rec(struct inode *inode,
832826
}
833827

834828
if (!found) {
835-
ocfs2_error(inode->i_sb, "Inode %lu has bad extent "
829+
ret = ocfs2_error(inode->i_sb, "Inode %lu has bad extent "
836830
"record (%u, %u, 0) in btree", inode->i_ino,
837831
le32_to_cpu(rec->e_cpos),
838832
ocfs2_rec_clusters(el, rec));
839-
ret = -EROFS;
840833
goto out;
841834
}
842835

fs/ocfs2/inode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,29 +1352,29 @@ int ocfs2_validate_inode_block(struct super_block *sb,
13521352
rc = -EINVAL;
13531353

13541354
if (!OCFS2_IS_VALID_DINODE(di)) {
1355-
ocfs2_error(sb, "Invalid dinode #%llu: signature = %.*s\n",
1355+
rc = ocfs2_error(sb, "Invalid dinode #%llu: signature = %.*s\n",
13561356
(unsigned long long)bh->b_blocknr, 7,
13571357
di->i_signature);
13581358
goto bail;
13591359
}
13601360

13611361
if (le64_to_cpu(di->i_blkno) != bh->b_blocknr) {
1362-
ocfs2_error(sb, "Invalid dinode #%llu: i_blkno is %llu\n",
1362+
rc = ocfs2_error(sb, "Invalid dinode #%llu: i_blkno is %llu\n",
13631363
(unsigned long long)bh->b_blocknr,
13641364
(unsigned long long)le64_to_cpu(di->i_blkno));
13651365
goto bail;
13661366
}
13671367

13681368
if (!(di->i_flags & cpu_to_le32(OCFS2_VALID_FL))) {
1369-
ocfs2_error(sb,
1369+
rc = ocfs2_error(sb,
13701370
"Invalid dinode #%llu: OCFS2_VALID_FL not set\n",
13711371
(unsigned long long)bh->b_blocknr);
13721372
goto bail;
13731373
}
13741374

13751375
if (le32_to_cpu(di->i_fs_generation) !=
13761376
OCFS2_SB(sb)->fs_generation) {
1377-
ocfs2_error(sb,
1377+
rc = ocfs2_error(sb,
13781378
"Invalid dinode #%llu: fs_generation is %u\n",
13791379
(unsigned long long)bh->b_blocknr,
13801380
le32_to_cpu(di->i_fs_generation));

fs/ocfs2/move_extents.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,10 @@ static int __ocfs2_move_extent(handle_t *handle,
9999

100100
index = ocfs2_search_extent_list(el, cpos);
101101
if (index == -1) {
102-
ocfs2_error(inode->i_sb,
102+
ret = ocfs2_error(inode->i_sb,
103103
"Inode %llu has an extent at cpos %u which can no "
104104
"longer be found.\n",
105105
(unsigned long long)ino, cpos);
106-
ret = -EROFS;
107106
goto out;
108107
}
109108

fs/ocfs2/refcounttree.c

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -102,32 +102,32 @@ static int ocfs2_validate_refcount_block(struct super_block *sb,
102102

103103

104104
if (!OCFS2_IS_VALID_REFCOUNT_BLOCK(rb)) {
105-
ocfs2_error(sb,
105+
rc = ocfs2_error(sb,
106106
"Refcount block #%llu has bad signature %.*s",
107107
(unsigned long long)bh->b_blocknr, 7,
108108
rb->rf_signature);
109-
return -EINVAL;
109+
goto out;
110110
}
111111

112112
if (le64_to_cpu(rb->rf_blkno) != bh->b_blocknr) {
113-
ocfs2_error(sb,
113+
rc = ocfs2_error(sb,
114114
"Refcount block #%llu has an invalid rf_blkno "
115115
"of %llu",
116116
(unsigned long long)bh->b_blocknr,
117117
(unsigned long long)le64_to_cpu(rb->rf_blkno));
118-
return -EINVAL;
118+
goto out;
119119
}
120120

121121
if (le32_to_cpu(rb->rf_fs_generation) != OCFS2_SB(sb)->fs_generation) {
122-
ocfs2_error(sb,
122+
rc = ocfs2_error(sb,
123123
"Refcount block #%llu has an invalid "
124124
"rf_fs_generation of #%u",
125125
(unsigned long long)bh->b_blocknr,
126126
le32_to_cpu(rb->rf_fs_generation));
127-
return -EINVAL;
127+
goto out;
128128
}
129-
130-
return 0;
129+
out:
130+
return rc;
131131
}
132132

133133
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,
11021102
el = &eb->h_list;
11031103

11041104
if (el->l_tree_depth) {
1105-
ocfs2_error(sb,
1106-
"refcount tree %llu has non zero tree "
1107-
"depth in leaf btree tree block %llu\n",
1108-
(unsigned long long)ocfs2_metadata_cache_owner(ci),
1109-
(unsigned long long)eb_bh->b_blocknr);
1110-
ret = -EROFS;
1105+
ret = ocfs2_error(sb,
1106+
"refcount tree %llu has non zero tree "
1107+
"depth in leaf btree tree block %llu\n",
1108+
(unsigned long long)ocfs2_metadata_cache_owner(ci),
1109+
(unsigned long long)eb_bh->b_blocknr);
11111110
goto out;
11121111
}
11131112
}
@@ -2359,10 +2358,9 @@ static int ocfs2_mark_extent_refcounted(struct inode *inode,
23592358
cpos, len, phys);
23602359

23612360
if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) {
2362-
ocfs2_error(inode->i_sb, "Inode %lu want to use refcount "
2361+
ret = ocfs2_error(inode->i_sb, "Inode %lu want to use refcount "
23632362
"tree, but the feature bit is not set in the "
23642363
"super block.", inode->i_ino);
2365-
ret = -EROFS;
23662364
goto out;
23672365
}
23682366

@@ -2545,10 +2543,9 @@ int ocfs2_prepare_refcount_change_for_del(struct inode *inode,
25452543
u64 start_cpos = ocfs2_blocks_to_clusters(inode->i_sb, phys_blkno);
25462544

25472545
if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) {
2548-
ocfs2_error(inode->i_sb, "Inode %lu want to use refcount "
2546+
ret = ocfs2_error(inode->i_sb, "Inode %lu want to use refcount "
25492547
"tree, but the feature bit is not set in the "
25502548
"super block.", inode->i_ino);
2551-
ret = -EROFS;
25522549
goto out;
25532550
}
25542551

@@ -2672,11 +2669,10 @@ static int ocfs2_refcount_cal_cow_clusters(struct inode *inode,
26722669
el = &eb->h_list;
26732670

26742671
if (el->l_tree_depth) {
2675-
ocfs2_error(inode->i_sb,
2672+
ret = ocfs2_error(inode->i_sb,
26762673
"Inode %lu has non zero tree depth in "
26772674
"leaf block %llu\n", inode->i_ino,
26782675
(unsigned long long)eb_bh->b_blocknr);
2679-
ret = -EROFS;
26802676
goto out;
26812677
}
26822678
}
@@ -3106,11 +3102,10 @@ static int ocfs2_clear_ext_refcount(handle_t *handle,
31063102

31073103
index = ocfs2_search_extent_list(el, cpos);
31083104
if (index == -1) {
3109-
ocfs2_error(sb,
3105+
ret = ocfs2_error(sb,
31103106
"Inode %llu has an extent at cpos %u which can no "
31113107
"longer be found.\n",
31123108
(unsigned long long)ino, cpos);
3113-
ret = -EROFS;
31143109
goto out;
31153110
}
31163111

@@ -3376,10 +3371,9 @@ static int ocfs2_replace_cow(struct ocfs2_cow_context *context)
33763371
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
33773372

33783373
if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) {
3379-
ocfs2_error(inode->i_sb, "Inode %lu want to use refcount "
3374+
return ocfs2_error(inode->i_sb, "Inode %lu want to use refcount "
33803375
"tree, but the feature bit is not set in the "
33813376
"super block.", inode->i_ino);
3382-
return -EROFS;
33833377
}
33843378

33853379
ocfs2_init_dealloc_ctxt(&context->dealloc);

0 commit comments

Comments
 (0)