btrfs: improve error reporting in lookup_inline_extent_backref
PATCH v5 1/1 btrfs: improve error reporting in lookup_inline_extent_backref
When iterating the backrefs in an extent item if the ptr to the 'current' backref record goes beyond the extent item a warning is generated and -ENOENT is returned. However what's more appropriate to debug such cases would be to return EUCLEAN and also print identifying information about the performed search as well as the current content of the leaf containing the possibly corrupted extent item.
---
V5:
* Stop printing the key we are searching for as it was both wrong and redundant, since we have the slot number printed anyway. (Filipe)
V4:
* Also print the value of 'parent' as it's pertinent when metadata inline backrefs are being searched (Filipe)
* Print the leaf before printing the error message so that the latter is not lost (Filipe)
V3:
* Fixed format for the btree slot
* Removed redundant argument passed to format string
fs/btrfs/extent-tree.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
fs/btrfs/extent-tree.c +8 -1
@@ -895,7 +895,14 @@ int lookup_inline_extent_backref(struct btrfs_trans_handle *trans, err = -ENOENT ;while (1 ) {if (ptr >= end) { -WARN_ON (ptr > end); +if (ptr > end) { + err = -EUCLEAN ; +btrfs_print_leaf (path->nodes[0 ]); +btrfs_crit (fs_info, +"overrun extent record at slot %d while looking for inline extent for root %llu owner %llu offset %llu parent %llu" , + path->slots[0 ], root_objectid, owner, offset, + parent); + }break ; } iref = (struct btrfs_extent_inline_ref *)ptr;
--
2.25.1
Quoted 8 lines · Nikolay Borisov
When iterating the backrefs in an extent item if the ptr to the 'current' backref record goes beyond the extent item a warning is generated and
-ENOENTis returned. However what's more appropriate to debug such cases would be to return EUCLEAN and also print identifying information about the performed search as well as the current content of the leaf containing the possibly corrupted extent item.Signed-off-by Nikolay Borisov <[email protected]>
Looks good now, thanks.
Quoted 42 lines
---
V5:
* Stop printing the key we are searching for as it was both wrong and redundant, since we have the slot number printed anyway. (Filipe)V4:
* Also print the value of 'parent' as it's pertinent when metadata inline backrefs are being searched (Filipe)
* Print the leaf before printing the error message so that the latter is not lost (Filipe)V3:
* Fixed format for the btree slot
* Removed redundant argument passed to format stringfs/btrfs/extent-tree.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)fs/btrfs/extent-tree.c +8
-2@@ -895,7 +895,14 @@ int lookup_inline_extent_backref(struct btrfs_trans_handle *trans, err = -ENOENT ;while (1 ) {if (ptr >= end) { -WARN_ON (ptr > end); +if (ptr > end) { + err = -EUCLEAN ; +btrfs_print_leaf (path->nodes[0 ]); +btrfs_crit (fs_info, +"overrun extent record at slot %d while looking for inline extent for root %llu owner %llu offset %llu parent %llu" , + path->slots[0 ], root_objectid, owner, offset, + parent); + }break ; } iref = (struct btrfs_extent_inline_ref *)ptr; --2.25.1
Quoted 7 lines · Nikolay Borisov
When iterating the backrefs in an extent item if the ptr to the 'current' backref record goes beyond the extent item a warning is generated and
-ENOENTis returned. However what's more appropriate to debug such cases would be to return EUCLEAN and also print identifying information about the performed search as well as the current content of the leaf containing the possibly corrupted extent item.
Quoted 6 lines
Signed-off-by Nikolay Borisov <[email protected]>---
V5:
* Stop printing the key we are searching for as it was both wrong and redundant, since we have the slot number printed anyway. (Filipe)
Added to misc-next, thanks.