From: Josef Bacik <josef@toxicpanda.com>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v5 06/13] btrfs: lookup physical address from stripe extent
Date: Wed, 8 Feb 2023 15:16:24 -0500 [thread overview]
Message-ID: <Y+QDGMuAOkIOuvZh@localhost.localdomain> (raw)
In-Reply-To: <f1ee4f592ce63640fec2caf9d1b5ce64da11a733.1675853489.git.johannes.thumshirn@wdc.com>
On Wed, Feb 08, 2023 at 02:57:43AM -0800, Johannes Thumshirn wrote:
> Lookup the physical address from the raid stripe tree when a read on an
> RAID volume formatted with the raid stripe tree was attempted.
>
> If the requested logical address was not found in the stripe tree, it may
> still be in the in-memory ordered stripe tree, so fallback to searching
> the ordered stripe tree in this case.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
> fs/btrfs/raid-stripe-tree.c | 145 ++++++++++++++++++++++++++++++++++++
> fs/btrfs/raid-stripe-tree.h | 3 +
> fs/btrfs/volumes.c | 31 ++++++--
> 3 files changed, 172 insertions(+), 7 deletions(-)
>
> diff --git a/fs/btrfs/raid-stripe-tree.c b/fs/btrfs/raid-stripe-tree.c
> index ff5787a19454..ba7015a8012c 100644
> --- a/fs/btrfs/raid-stripe-tree.c
> +++ b/fs/btrfs/raid-stripe-tree.c
> @@ -231,3 +231,148 @@ int btrfs_insert_raid_extent(struct btrfs_trans_handle *trans,
>
> return ret;
> }
> +
> +static bool btrfs_physical_from_ordered_stripe(struct btrfs_fs_info *fs_info,
> + u64 logical, u64 *length,
> + int num_stripes,
> + struct btrfs_io_stripe *stripe)
> +{
> + struct btrfs_ordered_stripe *os;
> + u64 offset;
> + u64 found_end;
> + u64 end;
> + int i;
> +
> + os = btrfs_lookup_ordered_stripe(fs_info, logical);
> + if (!os)
> + return false;
> +
> + end = logical + *length;
> + found_end = os->logical + os->num_bytes;
> + if (end > found_end)
> + *length -= end - found_end;
> +
> + for (i = 0; i < num_stripes; i++) {
> + if (os->stripes[i].dev != stripe->dev)
> + continue;
> +
> + offset = logical - os->logical;
> + ASSERT(offset >= 0);
This is always going to be true, should probably be
ASSERT(logical >= os->logical);
otherwise you can add
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Thanks,
Josef
next prev parent reply other threads:[~2023-02-08 20:16 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-08 10:57 [PATCH v5 00/13] btrfs: introduce RAID stripe tree Johannes Thumshirn
2023-02-08 10:57 ` [PATCH v5 01/13] btrfs: re-add trans parameter to insert_delayed_ref Johannes Thumshirn
2023-02-08 19:41 ` Josef Bacik
2023-02-08 10:57 ` [PATCH v5 02/13] btrfs: add raid stripe tree definitions Johannes Thumshirn
2023-02-08 19:42 ` Josef Bacik
2023-02-13 6:50 ` Christoph Hellwig
2023-02-13 11:10 ` Johannes Thumshirn
2023-02-13 11:34 ` Anand Jain
2023-02-08 10:57 ` [PATCH v5 03/13] btrfs: read raid-stripe-tree from disk Johannes Thumshirn
2023-02-08 19:43 ` Josef Bacik
2023-02-13 11:35 ` Anand Jain
2023-02-08 10:57 ` [PATCH v5 04/13] btrfs: add support for inserting raid stripe extents Johannes Thumshirn
2023-02-08 19:47 ` Josef Bacik
2023-02-08 19:52 ` Josef Bacik
2023-02-13 6:57 ` Christoph Hellwig
2023-02-13 10:43 ` Johannes Thumshirn
2023-02-13 13:12 ` Johannes Thumshirn
2023-02-13 7:40 ` Qu Wenruo
2023-02-13 10:49 ` Johannes Thumshirn
2023-02-13 11:12 ` Qu Wenruo
2023-02-13 11:37 ` Johannes Thumshirn
2023-02-08 10:57 ` [PATCH v5 05/13] btrfs: delete stripe extent on extent deletion Johannes Thumshirn
2023-02-08 20:00 ` Josef Bacik
2023-02-13 15:21 ` Johannes Thumshirn
2023-02-08 10:57 ` [PATCH v5 06/13] btrfs: lookup physical address from stripe extent Johannes Thumshirn
2023-02-08 20:16 ` Josef Bacik [this message]
2023-02-08 10:57 ` [PATCH v5 07/13] btrfs: add raid stripe tree pretty printer Johannes Thumshirn
2023-02-08 10:57 ` [PATCH v5 08/13] btrfs: zoned: allow zoned RAID Johannes Thumshirn
2023-02-08 20:18 ` Josef Bacik
2023-02-08 10:57 ` [PATCH v5 09/13] btrfs: check for leaks of ordered stripes on umount Johannes Thumshirn
2023-02-08 20:19 ` Josef Bacik
2023-02-08 10:57 ` [PATCH v5 10/13] btrfs: add tracepoints for ordered stripes Johannes Thumshirn
2023-02-08 10:57 ` [PATCH v5 11/13] btrfs: announce presence of raid-stripe-tree in sysfs Johannes Thumshirn
2023-02-08 20:20 ` Josef Bacik
2023-02-08 10:57 ` [PATCH v5 12/13] btrfs: consult raid-stripe-tree when scrubbing Johannes Thumshirn
2023-02-08 20:21 ` Josef Bacik
2023-02-08 10:57 ` [PATCH v5 13/13] btrfs: add raid-stripe-tree to features enabled with debug Johannes Thumshirn
2023-02-08 20:23 ` Josef Bacik
2023-02-09 0:42 ` [PATCH v5 00/13] btrfs: introduce RAID stripe tree Qu Wenruo
2023-02-09 8:47 ` Johannes Thumshirn
2023-02-09 15:57 ` Phillip Susi
2023-02-10 8:44 ` Johannes Thumshirn
2023-02-10 10:33 ` Johannes Thumshirn
2023-02-13 16:42 ` Phillip Susi
2023-02-13 17:44 ` Johannes Thumshirn
2023-02-13 17:56 ` Phillip Susi
2023-02-14 5:52 ` Christoph Hellwig
2023-02-14 5:51 ` Christoph Hellwig
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=Y+QDGMuAOkIOuvZh@localhost.localdomain \
--to=josef@toxicpanda.com \
--cc=johannes.thumshirn@wdc.com \
--cc=linux-btrfs@vger.kernel.org \
/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