* [PATCH] btrfs: send: do not BUG_ON() on unexpected symlink data extent
@ 2023-06-12 10:40 fdmanana
2023-06-12 11:19 ` Qu Wenruo
2023-06-12 22:13 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: fdmanana @ 2023-06-12 10:40 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
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().
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/send.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index af2e153543a5..8bfd44750efe 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -1774,9 +1774,21 @@ static int read_symlink(struct btrfs_root *root,
ei = btrfs_item_ptr(path->nodes[0], path->slots[0],
struct btrfs_file_extent_item);
type = btrfs_file_extent_type(path->nodes[0], ei);
+ if (unlikely(type != BTRFS_FILE_EXTENT_INLINE)) {
+ ret = -EUCLEAN;
+ btrfs_crit(root->fs_info,
+"send: found symlink extent that is not inline, ino %llu root %llu extent type %d",
+ ino, btrfs_root_id(root), type);
+ goto out;
+ }
compression = btrfs_file_extent_compression(path->nodes[0], ei);
- BUG_ON(type != BTRFS_FILE_EXTENT_INLINE);
- BUG_ON(compression);
+ if (unlikely(compression != BTRFS_COMPRESS_NONE)) {
+ ret = -EUCLEAN;
+ btrfs_crit(root->fs_info,
+"send: found symlink extent with compression, ino %llu root %llu compression type %d",
+ ino, btrfs_root_id(root), compression);
+ goto out;
+ }
off = btrfs_file_extent_inline_start(ei);
len = btrfs_file_extent_ram_bytes(path->nodes[0], ei);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: send: do not BUG_ON() on unexpected symlink data extent
2023-06-12 10:40 [PATCH] btrfs: send: do not BUG_ON() on unexpected symlink data extent fdmanana
@ 2023-06-12 11:19 ` Qu Wenruo
2023-06-12 22:13 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2023-06-12 11:19 UTC (permalink / raw)
To: fdmanana, linux-btrfs
On 2023/6/12 18:40, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> 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().
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/send.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index af2e153543a5..8bfd44750efe 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -1774,9 +1774,21 @@ static int read_symlink(struct btrfs_root *root,
> ei = btrfs_item_ptr(path->nodes[0], path->slots[0],
> struct btrfs_file_extent_item);
> type = btrfs_file_extent_type(path->nodes[0], ei);
> + if (unlikely(type != BTRFS_FILE_EXTENT_INLINE)) {
> + ret = -EUCLEAN;
> + btrfs_crit(root->fs_info,
> +"send: found symlink extent that is not inline, ino %llu root %llu extent type %d",
> + ino, btrfs_root_id(root), type);
> + goto out;
> + }
> compression = btrfs_file_extent_compression(path->nodes[0], ei);
> - BUG_ON(type != BTRFS_FILE_EXTENT_INLINE);
> - BUG_ON(compression);
> + if (unlikely(compression != BTRFS_COMPRESS_NONE)) {
> + ret = -EUCLEAN;
> + btrfs_crit(root->fs_info,
> +"send: found symlink extent with compression, ino %llu root %llu compression type %d",
> + ino, btrfs_root_id(root), compression);
> + goto out;
> + }
>
> off = btrfs_file_extent_inline_start(ei);
> len = btrfs_file_extent_ram_bytes(path->nodes[0], ei);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: send: do not BUG_ON() on unexpected symlink data extent
2023-06-12 10:40 [PATCH] btrfs: send: do not BUG_ON() on unexpected symlink data extent fdmanana
2023-06-12 11:19 ` Qu Wenruo
@ 2023-06-12 22:13 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2023-06-12 22:13 UTC (permalink / raw)
To: fdmanana; +Cc: linux-btrfs
On Mon, Jun 12, 2023 at 11:40:59AM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> 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().
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Added to misc-next, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-12 22:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-12 10:40 [PATCH] btrfs: send: do not BUG_ON() on unexpected symlink data extent fdmanana
2023-06-12 11:19 ` Qu Wenruo
2023-06-12 22:13 ` David Sterba
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.