* [PATCH] btrfs-progs: btrfs-map-logical fix case when extent isn't found
@ 2021-03-22 2:42 Dāvis Mosāns
0 siblings, 0 replies; only message in thread
From: Dāvis Mosāns @ 2021-03-22 2:42 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba, Qu Wenruo, Dāvis Mosāns
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-03-22 2:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-22 2:42 [PATCH] btrfs-progs: btrfs-map-logical fix case when extent isn't found Dāvis Mosāns
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox