* [Ocfs2-devel] [PATCH] ocfs2: return -EROFS when filesystem becomes read-only
@ 2018-06-06 1:18 piaojun
2018-06-06 9:39 ` Joseph Qi
0 siblings, 1 reply; 3+ messages in thread
From: piaojun @ 2018-06-06 1:18 UTC (permalink / raw)
To: ocfs2-devel
We should return -EROFS rather than other errno if filesystem becomes
read-only.
Signed-off-by: Jun Piao <piaojun@huawei.com>
Reviewed-by: Yiwen Jiang <jiangyiwen@huawei.com>
---
fs/ocfs2/alloc.c | 15 +++++----------
fs/ocfs2/localalloc.c | 3 +--
fs/ocfs2/quota_local.c | 7 +++----
3 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 0f157bb..453d39f 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,
while(le16_to_cpu(el->l_tree_depth) > 1) {
if (le16_to_cpu(el->l_next_free_rec) == 0) {
- ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
+ status = ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
"Owner %llu has empty extent list (next_free_rec == 0)\n",
(unsigned long long)ocfs2_metadata_cache_owner(et->et_ci));
- status = -EIO;
goto bail;
}
i = le16_to_cpu(el->l_next_free_rec) - 1;
blkno = le64_to_cpu(el->l_recs[i].e_blkno);
if (!blkno) {
- ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
+ status = ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
"Owner %llu has extent list where extent # %d has no physical block start\n",
(unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), i);
- status = -EIO;
goto bail;
}
@@ -3214,8 +3212,7 @@ static int ocfs2_rotate_tree_left(handle_t *handle,
goto rightmost_no_delete;
if (le16_to_cpu(el->l_next_free_rec) == 0) {
- ret = -EIO;
- ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
+ ret = ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
"Owner %llu has empty extent block at %llu\n",
(unsigned long long)ocfs2_metadata_cache_owner(et->et_ci),
(unsigned long long)le64_to_cpu(eb->h_blkno));
@@ -4411,12 +4408,11 @@ static int ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
le16_to_cpu(new_el->l_count)) {
bh = path_leaf_bh(left_path);
eb = (struct ocfs2_extent_block *)bh->b_data;
- ocfs2_error(sb,
+ status = ocfs2_error(sb,
"Extent block #%llu has an invalid l_next_free_rec of %d. It should have matched the l_count of %d\n",
(unsigned long long)le64_to_cpu(eb->h_blkno),
le16_to_cpu(new_el->l_next_free_rec),
le16_to_cpu(new_el->l_count));
- status = -EINVAL;
goto free_left_path;
}
rec = &new_el->l_recs[
@@ -4466,11 +4462,10 @@ static int ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
if (le16_to_cpu(new_el->l_next_free_rec) <= 1) {
bh = path_leaf_bh(right_path);
eb = (struct ocfs2_extent_block *)bh->b_data;
- ocfs2_error(sb,
+ status = ocfs2_error(sb,
"Extent block #%llu has an invalid l_next_free_rec of %d\n",
(unsigned long long)le64_to_cpu(eb->h_blkno),
le16_to_cpu(new_el->l_next_free_rec));
- status = -EINVAL;
goto free_right_path;
}
rec = &new_el->l_recs[1];
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index fe0d1f9..222a3d1 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,
#ifdef CONFIG_OCFS2_DEBUG_FS
if (le32_to_cpu(alloc->id1.bitmap1.i_used) !=
ocfs2_local_alloc_count_bits(alloc)) {
- ocfs2_error(osb->sb, "local alloc inode %llu says it has %u used bits, but a count shows %u\n",
+ status = ocfs2_error(osb->sb, "local alloc inode %llu says it has %u used bits, but a count shows %u\n",
(unsigned long long)le64_to_cpu(alloc->i_blkno),
le32_to_cpu(alloc->id1.bitmap1.i_used),
ocfs2_local_alloc_count_bits(alloc));
- status = -EIO;
goto bail;
}
#endif
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
index 16c42ed..d56cec1 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,
int rc = 0;
struct buffer_head *tmp = *bh;
- if (i_size_read(inode) >> inode->i_sb->s_blocksize_bits <= v_block) {
- ocfs2_error(inode->i_sb,
+ if (i_size_read(inode) >> inode->i_sb->s_blocksize_bits <= v_block)
+ return ocfs2_error(inode->i_sb,
"Quota file %llu is probably corrupted! Requested to read block %Lu but file has size only %Lu\n",
(unsigned long long)OCFS2_I(inode)->ip_blkno,
(unsigned long long)v_block,
(unsigned long long)i_size_read(inode));
- return -EIO;
- }
+
rc = ocfs2_read_virt_blocks(inode, v_block, 1, &tmp, 0,
ocfs2_validate_quota_block);
if (rc)
--
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Ocfs2-devel] [PATCH] ocfs2: return -EROFS when filesystem becomes read-only
2018-06-06 1:18 [Ocfs2-devel] [PATCH] ocfs2: return -EROFS when filesystem becomes read-only piaojun
@ 2018-06-06 9:39 ` Joseph Qi
2018-06-07 0:32 ` piaojun
0 siblings, 1 reply; 3+ messages in thread
From: Joseph Qi @ 2018-06-06 9:39 UTC (permalink / raw)
To: ocfs2-devel
Looks reasonable.
But I suggest make the error messages alignment as well.
Thanks,
Joseph
On 18/6/6 09:18, piaojun wrote:
> We should return -EROFS rather than other errno if filesystem becomes
> read-only.
>
> Signed-off-by: Jun Piao <piaojun@huawei.com>
> Reviewed-by: Yiwen Jiang <jiangyiwen@huawei.com>
> ---
> fs/ocfs2/alloc.c | 15 +++++----------
> fs/ocfs2/localalloc.c | 3 +--
> fs/ocfs2/quota_local.c | 7 +++----
> 3 files changed, 9 insertions(+), 16 deletions(-)
>
> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
> index 0f157bb..453d39f 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,
>
> while(le16_to_cpu(el->l_tree_depth) > 1) {
> if (le16_to_cpu(el->l_next_free_rec) == 0) {
> - ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
> + status = ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
> "Owner %llu has empty extent list (next_free_rec == 0)\n",
> (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci));
> - status = -EIO;
> goto bail;
> }
> i = le16_to_cpu(el->l_next_free_rec) - 1;
> blkno = le64_to_cpu(el->l_recs[i].e_blkno);
> if (!blkno) {
> - ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
> + status = ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
> "Owner %llu has extent list where extent # %d has no physical block start\n",
> (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), i);
> - status = -EIO;
> goto bail;
> }
>
> @@ -3214,8 +3212,7 @@ static int ocfs2_rotate_tree_left(handle_t *handle,
> goto rightmost_no_delete;
>
> if (le16_to_cpu(el->l_next_free_rec) == 0) {
> - ret = -EIO;
> - ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
> + ret = ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
> "Owner %llu has empty extent block at %llu\n",
> (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci),
> (unsigned long long)le64_to_cpu(eb->h_blkno));
> @@ -4411,12 +4408,11 @@ static int ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
> le16_to_cpu(new_el->l_count)) {
> bh = path_leaf_bh(left_path);
> eb = (struct ocfs2_extent_block *)bh->b_data;
> - ocfs2_error(sb,
> + status = ocfs2_error(sb,
> "Extent block #%llu has an invalid l_next_free_rec of %d. It should have matched the l_count of %d\n",
> (unsigned long long)le64_to_cpu(eb->h_blkno),
> le16_to_cpu(new_el->l_next_free_rec),
> le16_to_cpu(new_el->l_count));
> - status = -EINVAL;
> goto free_left_path;
> }
> rec = &new_el->l_recs[
> @@ -4466,11 +4462,10 @@ static int ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
> if (le16_to_cpu(new_el->l_next_free_rec) <= 1) {
> bh = path_leaf_bh(right_path);
> eb = (struct ocfs2_extent_block *)bh->b_data;
> - ocfs2_error(sb,
> + status = ocfs2_error(sb,
> "Extent block #%llu has an invalid l_next_free_rec of %d\n",
> (unsigned long long)le64_to_cpu(eb->h_blkno),
> le16_to_cpu(new_el->l_next_free_rec));
> - status = -EINVAL;
> goto free_right_path;
> }
> rec = &new_el->l_recs[1];
> diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
> index fe0d1f9..222a3d1 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,
> #ifdef CONFIG_OCFS2_DEBUG_FS
> if (le32_to_cpu(alloc->id1.bitmap1.i_used) !=
> ocfs2_local_alloc_count_bits(alloc)) {
> - ocfs2_error(osb->sb, "local alloc inode %llu says it has %u used bits, but a count shows %u\n",
> + status = ocfs2_error(osb->sb, "local alloc inode %llu says it has %u used bits, but a count shows %u\n",
> (unsigned long long)le64_to_cpu(alloc->i_blkno),
> le32_to_cpu(alloc->id1.bitmap1.i_used),
> ocfs2_local_alloc_count_bits(alloc));
> - status = -EIO;
> goto bail;
> }
> #endif
> diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
> index 16c42ed..d56cec1 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,
> int rc = 0;
> struct buffer_head *tmp = *bh;
>
> - if (i_size_read(inode) >> inode->i_sb->s_blocksize_bits <= v_block) {
> - ocfs2_error(inode->i_sb,
> + if (i_size_read(inode) >> inode->i_sb->s_blocksize_bits <= v_block)
> + return ocfs2_error(inode->i_sb,
> "Quota file %llu is probably corrupted! Requested to read block %Lu but file has size only %Lu\n",
> (unsigned long long)OCFS2_I(inode)->ip_blkno,
> (unsigned long long)v_block,
> (unsigned long long)i_size_read(inode));
> - return -EIO;
> - }
> +
> rc = ocfs2_read_virt_blocks(inode, v_block, 1, &tmp, 0,
> ocfs2_validate_quota_block);
> if (rc)
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Ocfs2-devel] [PATCH] ocfs2: return -EROFS when filesystem becomes read-only
2018-06-06 9:39 ` Joseph Qi
@ 2018-06-07 0:32 ` piaojun
0 siblings, 0 replies; 3+ messages in thread
From: piaojun @ 2018-06-07 0:32 UTC (permalink / raw)
To: ocfs2-devel
Hi Joseph,
Thanks for reviewing, and I will post patch v2 to fix alignment.
Thanks,
Jun
On 2018/6/6 17:39, Joseph Qi wrote:
> Looks reasonable.
> But I suggest make the error messages alignment as well.
>
> Thanks,
> Joseph
>
> On 18/6/6 09:18, piaojun wrote:
>> We should return -EROFS rather than other errno if filesystem becomes
>> read-only.
>>
>> Signed-off-by: Jun Piao <piaojun@huawei.com>
>> Reviewed-by: Yiwen Jiang <jiangyiwen@huawei.com>
>> ---
>> fs/ocfs2/alloc.c | 15 +++++----------
>> fs/ocfs2/localalloc.c | 3 +--
>> fs/ocfs2/quota_local.c | 7 +++----
>> 3 files changed, 9 insertions(+), 16 deletions(-)
>>
>> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
>> index 0f157bb..453d39f 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,
>>
>> while(le16_to_cpu(el->l_tree_depth) > 1) {
>> if (le16_to_cpu(el->l_next_free_rec) == 0) {
>> - ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
>> + status = ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
>> "Owner %llu has empty extent list (next_free_rec == 0)\n",
>> (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci));
>> - status = -EIO;
>> goto bail;
>> }
>> i = le16_to_cpu(el->l_next_free_rec) - 1;
>> blkno = le64_to_cpu(el->l_recs[i].e_blkno);
>> if (!blkno) {
>> - ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
>> + status = ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
>> "Owner %llu has extent list where extent # %d has no physical block start\n",
>> (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), i);
>> - status = -EIO;
>> goto bail;
>> }
>>
>> @@ -3214,8 +3212,7 @@ static int ocfs2_rotate_tree_left(handle_t *handle,
>> goto rightmost_no_delete;
>>
>> if (le16_to_cpu(el->l_next_free_rec) == 0) {
>> - ret = -EIO;
>> - ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
>> + ret = ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
>> "Owner %llu has empty extent block at %llu\n",
>> (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci),
>> (unsigned long long)le64_to_cpu(eb->h_blkno));
>> @@ -4411,12 +4408,11 @@ static int ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
>> le16_to_cpu(new_el->l_count)) {
>> bh = path_leaf_bh(left_path);
>> eb = (struct ocfs2_extent_block *)bh->b_data;
>> - ocfs2_error(sb,
>> + status = ocfs2_error(sb,
>> "Extent block #%llu has an invalid l_next_free_rec of %d. It should have matched the l_count of %d\n",
>> (unsigned long long)le64_to_cpu(eb->h_blkno),
>> le16_to_cpu(new_el->l_next_free_rec),
>> le16_to_cpu(new_el->l_count));
>> - status = -EINVAL;
>> goto free_left_path;
>> }
>> rec = &new_el->l_recs[
>> @@ -4466,11 +4462,10 @@ static int ocfs2_figure_merge_contig_type(struct ocfs2_extent_tree *et,
>> if (le16_to_cpu(new_el->l_next_free_rec) <= 1) {
>> bh = path_leaf_bh(right_path);
>> eb = (struct ocfs2_extent_block *)bh->b_data;
>> - ocfs2_error(sb,
>> + status = ocfs2_error(sb,
>> "Extent block #%llu has an invalid l_next_free_rec of %d\n",
>> (unsigned long long)le64_to_cpu(eb->h_blkno),
>> le16_to_cpu(new_el->l_next_free_rec));
>> - status = -EINVAL;
>> goto free_right_path;
>> }
>> rec = &new_el->l_recs[1];
>> diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
>> index fe0d1f9..222a3d1 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,
>> #ifdef CONFIG_OCFS2_DEBUG_FS
>> if (le32_to_cpu(alloc->id1.bitmap1.i_used) !=
>> ocfs2_local_alloc_count_bits(alloc)) {
>> - ocfs2_error(osb->sb, "local alloc inode %llu says it has %u used bits, but a count shows %u\n",
>> + status = ocfs2_error(osb->sb, "local alloc inode %llu says it has %u used bits, but a count shows %u\n",
>> (unsigned long long)le64_to_cpu(alloc->i_blkno),
>> le32_to_cpu(alloc->id1.bitmap1.i_used),
>> ocfs2_local_alloc_count_bits(alloc));
>> - status = -EIO;
>> goto bail;
>> }
>> #endif
>> diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
>> index 16c42ed..d56cec1 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,
>> int rc = 0;
>> struct buffer_head *tmp = *bh;
>>
>> - if (i_size_read(inode) >> inode->i_sb->s_blocksize_bits <= v_block) {
>> - ocfs2_error(inode->i_sb,
>> + if (i_size_read(inode) >> inode->i_sb->s_blocksize_bits <= v_block)
>> + return ocfs2_error(inode->i_sb,
>> "Quota file %llu is probably corrupted! Requested to read block %Lu but file has size only %Lu\n",
>> (unsigned long long)OCFS2_I(inode)->ip_blkno,
>> (unsigned long long)v_block,
>> (unsigned long long)i_size_read(inode));
>> - return -EIO;
>> - }
>> +
>> rc = ocfs2_read_virt_blocks(inode, v_block, 1, &tmp, 0,
>> ocfs2_validate_quota_block);
>> if (rc)
>>
> .
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-06-07 0:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-06 1:18 [Ocfs2-devel] [PATCH] ocfs2: return -EROFS when filesystem becomes read-only piaojun
2018-06-06 9:39 ` Joseph Qi
2018-06-07 0:32 ` piaojun
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.