Skip to content

Commit 6f3eb72

Browse files
fdmananakdave
authored andcommitted
btrfs: send: do not BUG_ON() on unexpected symlink data extent
There's really no need to BUG_ON() if we find a symlink with an extent that is not inline or is compressed. We can just make send fail with an error (-EUCLEAN) and log an informative error message, so just do that instead of BUG_ON(). Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent fc4026e commit 6f3eb72

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

fs/btrfs/send.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,9 +1774,21 @@ static int read_symlink(struct btrfs_root *root,
17741774
ei = btrfs_item_ptr(path->nodes[0], path->slots[0],
17751775
struct btrfs_file_extent_item);
17761776
type = btrfs_file_extent_type(path->nodes[0], ei);
1777+
if (unlikely(type != BTRFS_FILE_EXTENT_INLINE)) {
1778+
ret = -EUCLEAN;
1779+
btrfs_crit(root->fs_info,
1780+
"send: found symlink extent that is not inline, ino %llu root %llu extent type %d",
1781+
ino, btrfs_root_id(root), type);
1782+
goto out;
1783+
}
17771784
compression = btrfs_file_extent_compression(path->nodes[0], ei);
1778-
BUG_ON(type != BTRFS_FILE_EXTENT_INLINE);
1779-
BUG_ON(compression);
1785+
if (unlikely(compression != BTRFS_COMPRESS_NONE)) {
1786+
ret = -EUCLEAN;
1787+
btrfs_crit(root->fs_info,
1788+
"send: found symlink extent with compression, ino %llu root %llu compression type %d",
1789+
ino, btrfs_root_id(root), compression);
1790+
goto out;
1791+
}
17801792

17811793
off = btrfs_file_extent_inline_start(ei);
17821794
len = btrfs_file_extent_ram_bytes(path->nodes[0], ei);

0 commit comments

Comments
 (0)