diff options
author | Jun Piao <piaojun@huawei.com> | 2018-08-17 18:44:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-17 19:20:27 -0400 |
commit | 93f5920d8607c5e3f2d3b159377a7e7d7875ffdd (patch) | |
tree | 6e43f89a7293c50450b8cb420912ced745ff7b00 | |
parent | 8d00d0c00c0720c43b0eec0e86a6e916192f35d0 (diff) |
ocfs2: return -EROFS when filesystem becomes read-only
We should return -EROFS rather than other errno if filesystem becomes
read-only.
[akpm@linux-foundation.org: coding-style fixes]
Link: http://lkml.kernel.org/r/5B191B26.9010501@huawei.com
Signed-off-by: Jun Piao <piaojun@huawei.com>
Reviewed-by: Yiwen Jiang <jiangyiwen@huawei.com>
Acked-by: Joseph Qi <jiangqi903@gmail.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <ge.changwei@h3c.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/ocfs2/alloc.c | 43 | ||||
-rw-r--r-- | fs/ocfs2/localalloc.c | 9 | ||||
-rw-r--r-- | fs/ocfs2/quota_local.c | 15 |
3 files changed, 30 insertions, 37 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 0f157bbd3e0f..676714fef869 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -1481,19 +1481,17 @@ static int ocfs2_find_branch_target(struct ocfs2_extent_tree *et, | |||
1481 | 1481 | ||
1482 | while(le16_to_cpu(el->l_tree_depth) > 1) { | 1482 | while(le16_to_cpu(el->l_tree_depth) > 1) { |
1483 | if (le16_to_cpu(el->l_next_free_rec) == 0) { | 1483 | if (le16_to_cpu(el->l_next_free_rec) == 0) { |
1484 | ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci), | 1484 | status = ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci), |
1485 | "Owner %llu has empty extent list (next_free_rec == 0)\n", | 1485 | "Owner %llu has empty extent list (next_free_rec == 0)\n", |
1486 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci)); | 1486 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci)); |
1487 | status = -EIO; | ||
1488 | goto bail; | 1487 | goto bail; |
1489 | } | 1488 | } |
1490 | i = le16_to_cpu(el->l_next_free_rec) - 1; | 1489 | i = le16_to_cpu(el->l_next_free_rec) - 1; |
1491 | blkno = le64_to_cpu(el->l_recs[i].e_blkno); | 1490 | blkno = le64_to_cpu(el->l_recs[i].e_blkno); |
1492 | if (!blkno) { | 1491 | if (!blkno) { |
1493 | ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci), | 1492 | status = ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci), |
1494 | "Owner %llu has extent list where extent # %d has no physical block start\n", | 1493 | "Owner %llu has extent list where extent # %d has no physical block start\n", |
1495 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), i); | 1494 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), i); |
1496 | status = -EIO; | ||
1497 | goto bail; | 1495 | goto bail; |
1498 | } | 1496 | } |
1499 | 1497 | ||
@@ -3214,11 +3212,10 @@ rightmost_no_delete: | |||
3214 | goto rightmost_no_delete; | 3212 | goto rightmost_no_delete; |
3215 | 3213 | ||
3216 | if (le16_to_cpu(el->l_next_free_rec) == 0) { | 3214 | if (le16_to_cpu(el->l_next_free_rec) == 0) { |
3217 | ret = -EIO; | 3215 | ret = ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci), |
3218 | ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci), | 3216 | "Owner %llu has empty extent block at %llu\n", |
3219 | "Owner %llu has empty extent block at %llu\n", | 3217 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), |
3220 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), | 3218 | (unsigned long long)le64_to_cpu(eb->h_blkno)); |
3221 | (unsigned long long)le64_to_cpu(eb->h_blkno)); | ||
3222 | goto out; | 3219 | goto out; |
3223 | } | 3220 | } |
3224 | 3221 | ||
@@ -4411,12 +4408,11 @@ static int ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et, | |||
4411 | le16_to_cpu(new_el->l_count)) { | 4408 | le16_to_cpu(new_el->l_count)) { |
4412 | bh = path_leaf_bh(left_path); | 4409 | bh = path_leaf_bh(left_path); |
4413 | eb = (struct ocfs2_extent_block *)bh->b_data; | 4410 | eb = (struct ocfs2_extent_block *)bh->b_data; |
4414 | ocfs2_error(sb, | 4411 | status = ocfs2_error(sb, |
4415 | "Extent block #%llu has an invalid l_next_free_rec of %d. It should have matched the l_count of %d\n", | 4412 | "Extent block #%llu has an invalid l_next_free_rec of %d. It should have matched the l_count of %d\n", |
4416 | (unsigned long long)le64_to_cpu(eb->h_blkno), | 4413 | (unsigned long long)le64_to_cpu(eb->h_blkno), |
4417 | le16_to_cpu(new_el->l_next_free_rec), | 4414 | le16_to_cpu(new_el->l_next_free_rec), |
4418 | le16_to_cpu(new_el->l_count)); | 4415 | le16_to_cpu(new_el->l_count)); |
4419 | status = -EINVAL; | ||
4420 | goto free_left_path; | 4416 | goto free_left_path; |
4421 | } | 4417 | } |
4422 | rec = &new_el->l_recs[ | 4418 | rec = &new_el->l_recs[ |
@@ -4466,11 +4462,10 @@ static int ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et, | |||
4466 | if (le16_to_cpu(new_el->l_next_free_rec) <= 1) { | 4462 | if (le16_to_cpu(new_el->l_next_free_rec) <= 1) { |
4467 | bh = path_leaf_bh(right_path); | 4463 | bh = path_leaf_bh(right_path); |
4468 | eb = (struct ocfs2_extent_block *)bh->b_data; | 4464 | eb = (struct ocfs2_extent_block *)bh->b_data; |
4469 | ocfs2_error(sb, | 4465 | status = ocfs2_error(sb, |
4470 | "Extent block #%llu has an invalid l_next_free_rec of %d\n", | 4466 | "Extent block #%llu has an invalid l_next_free_rec of %d\n", |
4471 | (unsigned long long)le64_to_cpu(eb->h_blkno), | 4467 | (unsigned long long)le64_to_cpu(eb->h_blkno), |
4472 | le16_to_cpu(new_el->l_next_free_rec)); | 4468 | le16_to_cpu(new_el->l_next_free_rec)); |
4473 | status = -EINVAL; | ||
4474 | goto free_right_path; | 4469 | goto free_right_path; |
4475 | } | 4470 | } |
4476 | rec = &new_el->l_recs[1]; | 4471 | rec = &new_el->l_recs[1]; |
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index fe0d1f9571bb..7642b6712c39 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c | |||
@@ -663,11 +663,10 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, | |||
663 | #ifdef CONFIG_OCFS2_DEBUG_FS | 663 | #ifdef CONFIG_OCFS2_DEBUG_FS |
664 | if (le32_to_cpu(alloc->id1.bitmap1.i_used) != | 664 | if (le32_to_cpu(alloc->id1.bitmap1.i_used) != |
665 | ocfs2_local_alloc_count_bits(alloc)) { | 665 | ocfs2_local_alloc_count_bits(alloc)) { |
666 | ocfs2_error(osb->sb, "local alloc inode %llu says it has %u used bits, but a count shows %u\n", | 666 | status = ocfs2_error(osb->sb, "local alloc inode %llu says it has %u used bits, but a count shows %u\n", |
667 | (unsigned long long)le64_to_cpu(alloc->i_blkno), | 667 | (unsigned long long)le64_to_cpu(alloc->i_blkno), |
668 | le32_to_cpu(alloc->id1.bitmap1.i_used), | 668 | le32_to_cpu(alloc->id1.bitmap1.i_used), |
669 | ocfs2_local_alloc_count_bits(alloc)); | 669 | ocfs2_local_alloc_count_bits(alloc)); |
670 | status = -EIO; | ||
671 | goto bail; | 670 | goto bail; |
672 | } | 671 | } |
673 | #endif | 672 | #endif |
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c index 16c42ed0dca8..b1a8b046f4c2 100644 --- a/fs/ocfs2/quota_local.c +++ b/fs/ocfs2/quota_local.c | |||
@@ -137,14 +137,13 @@ static int ocfs2_read_quota_block(struct inode *inode, u64 v_block, | |||
137 | int rc = 0; | 137 | int rc = 0; |
138 | struct buffer_head *tmp = *bh; | 138 | struct buffer_head *tmp = *bh; |
139 | 139 | ||
140 | if (i_size_read(inode) >> inode->i_sb->s_blocksize_bits <= v_block) { | 140 | if (i_size_read(inode) >> inode->i_sb->s_blocksize_bits <= v_block) |
141 | ocfs2_error(inode->i_sb, | 141 | return ocfs2_error(inode->i_sb, |
142 | "Quota file %llu is probably corrupted! Requested to read block %Lu but file has size only %Lu\n", | 142 | "Quota file %llu is probably corrupted! Requested to read block %Lu but file has size only %Lu\n", |
143 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 143 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
144 | (unsigned long long)v_block, | 144 | (unsigned long long)v_block, |
145 | (unsigned long long)i_size_read(inode)); | 145 | (unsigned long long)i_size_read(inode)); |
146 | return -EIO; | 146 | |
147 | } | ||
148 | rc = ocfs2_read_virt_blocks(inode, v_block, 1, &tmp, 0, | 147 | rc = ocfs2_read_virt_blocks(inode, v_block, 1, &tmp, 0, |
149 | ocfs2_validate_quota_block); | 148 | ocfs2_validate_quota_block); |
150 | if (rc) | 149 | if (rc) |