From: "Dāvis Mosāns" <davispuh@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: "David Sterba" <dsterba@suse.cz>,
"Qu Wenruo" <quwenruo.btrfs@gmx.com>,
"Dāvis Mosāns" <davispuh@gmail.com>
Subject: [PATCH] btrfs-progs: btrfs-map-logical fix case when extent isn't found
Date: Mon, 22 Mar 2021 04:42:42 +0200 [thread overview]
Message-ID: <20210322024242.32045-1-davispuh@gmail.com> (raw)
Given extents:
[21057146519552,21057146535936)
[21057146552320,21057146568704)
and trying to map 21057146535936 we would find 21057146519552
which would give us extent with length of 0 because
> real_logical = max(logical, cur_logical); // logical (21057146535936)
> real_len = min(logical + bytes, cur_logical + cur_len) -
> real_logical;
// cur_logical (21057146519552) + cur_len (16384) -
// real_logical (21057146535936) = 0
So we need to break before this
Signed-off-by: Dāvis Mosāns <davispuh@gmail.com>
---
btrfs-map-logical.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index 24c81b8d..a2030f96 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -327,17 +327,18 @@ int main(int argc, char **argv)
u64 real_logical;
u64 real_len;
- found = 1;
ret = map_one_extent(root->fs_info, &cur_logical, &cur_len, 1);
if (ret < 0)
goto out_close_fd;
if (ret > 0)
break;
/* check again if there is overlap. */
- if (cur_logical + cur_len < logical ||
+ if (cur_logical + cur_len <= logical ||
cur_logical >= logical + bytes)
break;
+ found = 1;
+
real_logical = max(logical, cur_logical);
real_len = min(logical + bytes, cur_logical + cur_len) -
real_logical;
--
2.30.2
reply other threads:[~2021-03-22 2:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210322024242.32045-1-davispuh@gmail.com \
--to=davispuh@gmail.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=quwenruo.btrfs@gmx.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