diff mbox

[v2] btrfs: return EUCLEAN if extent_inline_ref type is invalid

Message ID 20180622081801.19891-1-suy.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Su Yue June 22, 2018, 8:18 a.m. UTC
If type of extent_inline_ref found is not expected, filesystem may have
been corrupted, should return EUCLEAN instead of EINVAL.
No functional changes.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
Changelog:
v2:
 Add changes in build_backref_tree, get_extent_inline_ref and
   add_inline_refs.
   
 fs/btrfs/backref.c     | 4 ++--
 fs/btrfs/extent-tree.c | 2 +-
 fs/btrfs/relocation.c  | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

Comments

David Sterba June 22, 2018, 9:40 a.m. UTC | #1
On Fri, Jun 22, 2018 at 04:18:01PM +0800, Su Yue wrote:
> If type of extent_inline_ref found is not expected, filesystem may have
> been corrupted, should return EUCLEAN instead of EINVAL.
> No functional changes.
> 
> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
> ---
> Changelog:
> v2:
>  Add changes in build_backref_tree, get_extent_inline_ref and
>    add_inline_refs.

v2 looks good. I saw one implicit check for invalid ref in
add_data_references that still returns -EINVAL.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Su Yue June 25, 2018, 1:28 a.m. UTC | #2
On 06/22/2018 05:40 PM, David Sterba wrote:
> On Fri, Jun 22, 2018 at 04:18:01PM +0800, Su Yue wrote:
>> If type of extent_inline_ref found is not expected, filesystem may have
>> been corrupted, should return EUCLEAN instead of EINVAL.
>> No functional changes.
>>
>> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
>> ---
>> Changelog:
>> v2:
>>   Add changes in build_backref_tree, get_extent_inline_ref and
>>     add_inline_refs.
> 
> v2 looks good. I saw one implicit check for invalid ref in
> add_data_references that still returns -EINVAL.
> 
> The implicit check is located in relocation.c:3804. I changed
it in v1 which is not listed in changedlog.
Did I need to sent v3 to list all functions in commit message?

Thanks,
Su


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Su Yue June 25, 2018, 1:35 a.m. UTC | #3
On 06/25/2018 09:28 AM, Su Yue wrote:
> 
> 
> On 06/22/2018 05:40 PM, David Sterba wrote:
>> On Fri, Jun 22, 2018 at 04:18:01PM +0800, Su Yue wrote:
>>> If type of extent_inline_ref found is not expected, filesystem may have
>>> been corrupted, should return EUCLEAN instead of EINVAL.
>>> No functional changes.
>>>
>>> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
>>> ---
>>> Changelog:
>>> v2:
>>>   Add changes in build_backref_tree, get_extent_inline_ref and
>>>     add_inline_refs.
>>
>> v2 looks good. I saw one implicit check for invalid ref in
>> add_data_references that still returns -EINVAL.
>>
>> The implicit check is located in relocation.c:3804. I changeds/3804/3801
> it in v1 which is not listed in changedlog.
> Did I need to sent v3 to list all functions in commit message?
> 
> Thanks,
> Su
> 
> 
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Sterba June 27, 2018, 12:58 p.m. UTC | #4
On Mon, Jun 25, 2018 at 09:28:32AM +0800, Su Yue wrote:
> 
> 
> On 06/22/2018 05:40 PM, David Sterba wrote:
> > On Fri, Jun 22, 2018 at 04:18:01PM +0800, Su Yue wrote:
> >> If type of extent_inline_ref found is not expected, filesystem may have
> >> been corrupted, should return EUCLEAN instead of EINVAL.
> >> No functional changes.
> >>
> >> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
> >> ---
> >> Changelog:
> >> v2:
> >>   Add changes in build_backref_tree, get_extent_inline_ref and
> >>     add_inline_refs.
> > 
> > v2 looks good. I saw one implicit check for invalid ref in
> > add_data_references that still returns -EINVAL.
> > 
> > The implicit check is located in relocation.c:3804. I changed
> it in v1 which is not listed in changedlog.
> Did I need to sent v3 to list all functions in commit message?

No, the change is in the patch, I must have overlooked it, sorry. Added
to misc-next now, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 0a8e2e29a66b..60f4afa8ecbc 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -925,7 +925,7 @@  static int add_inline_refs(const struct btrfs_fs_info *fs_info,
 		type = btrfs_get_extent_inline_ref_type(leaf, iref,
 							BTRFS_REF_TYPE_ANY);
 		if (type == BTRFS_REF_TYPE_INVALID)
-			return -EINVAL;
+			return -EUCLEAN;
 
 		offset = btrfs_extent_inline_ref_offset(leaf, iref);
 
@@ -1793,7 +1793,7 @@  static int get_extent_inline_ref(unsigned long *ptr,
 	*out_type = btrfs_get_extent_inline_ref_type(eb, *out_eiref,
 						     BTRFS_REF_TYPE_ANY);
 	if (*out_type == BTRFS_REF_TYPE_INVALID)
-		return -EINVAL;
+		return -EUCLEAN;
 
 	*ptr += btrfs_extent_inline_ref_size(*out_type);
 	WARN_ON(*ptr > end);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 3d9fe58c0080..05d50c3a594e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1727,7 +1727,7 @@  int lookup_inline_extent_backref(struct btrfs_trans_handle *trans,
 		iref = (struct btrfs_extent_inline_ref *)ptr;
 		type = btrfs_get_extent_inline_ref_type(leaf, iref, needed);
 		if (type == BTRFS_REF_TYPE_INVALID) {
-			err = -EINVAL;
+			err = -EUCLEAN;
 			goto out;
 		}
 
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 879b76fa881a..2c13e7761440 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -792,7 +792,7 @@  struct backref_node *build_backref_tree(struct reloc_control *rc,
 			type = btrfs_get_extent_inline_ref_type(eb, iref,
 							BTRFS_REF_TYPE_BLOCK);
 			if (type == BTRFS_REF_TYPE_INVALID) {
-				err = -EINVAL;
+				err = -EUCLEAN;
 				goto out;
 			}
 			key.type = type;
@@ -3801,7 +3801,7 @@  int add_data_references(struct reloc_control *rc,
 			ret = find_data_references(rc, extent_key,
 						   eb, dref, blocks);
 		} else {
-			ret = -EINVAL;
+			ret = -EUCLEAN;
 			btrfs_err(rc->extent_root->fs_info,
 		     "extent %llu slot %d has an invalid inline ref type",
 			     eb->start, path->slots[0]);