public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@linux-m68k.org>
To: Qu Wenruo <wqu@suse.com>
Cc: u-boot@lists.denx.de, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] fs: btrfs: limit the mapped length to the original length
Date: Mon, 13 Feb 2023 22:01:17 +0100	[thread overview]
Message-ID: <87pmadjn4y.fsf@igel.home> (raw)
In-Reply-To: <99e2c01bb0366af9aec7522f7109c74b09c5509d.1676248644.git.wqu@suse.com> (Qu Wenruo's message of "Mon, 13 Feb 2023 08:37:59 +0800")

On Feb 13 2023, Qu Wenruo wrote:

> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 4aaaeab663f5..7d4095d9ca88 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -956,6 +956,7 @@ int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
>  	struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree;
>  	struct cache_extent *ce;
>  	struct map_lookup *map;
> +	u64 orig_len = *length;
>  	u64 offset;
>  	u64 stripe_offset;
>  	u64 *raid_map = NULL;
> @@ -1047,6 +1048,7 @@ again:
>  	} else {
>  		*length = ce->size - offset;
>  	}
> +	*length = min_t(u64, *length, orig_len);
>  
>  	if (!multi_ret)
>  		goto out;

I can confirm that this fixes the issue.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

  reply	other threads:[~2023-02-13 21:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-13  0:37 [PATCH] fs: btrfs: limit the mapped length to the original length Qu Wenruo
2023-02-13 21:01 ` Andreas Schwab [this message]
2023-02-24 14:43 ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pmadjn4y.fsf@igel.home \
    --to=schwab@linux-m68k.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=u-boot@lists.denx.de \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox