aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMarek BehĂșn2018-07-04 13:23:01 -0500
committerTom Rini2018-07-20 14:37:44 -0500
commitf8c173b6a0b7695089d5ec48cb5b320863c91fdf (patch)
tree0a3506445bea0ed84db77e574a2901d45a5d5d83 /fs
parent25dabd730a534a93b585fe6623783e034399c68e (diff)
downloadu-boot-f8c173b6a0b7695089d5ec48cb5b320863c91fdf.tar.gz
u-boot-f8c173b6a0b7695089d5ec48cb5b320863c91fdf.tar.xz
u-boot-f8c173b6a0b7695089d5ec48cb5b320863c91fdf.zip
fs: btrfs: Fix wrong comparison in logical to physical mapping
The comparison logical > item->logical + item->length in btrfs_map_logical_to_physical is wrong and should be instead logical >= item->logical + item->length For example, if item->logical = 4096 item->length = 4096 and we are looking for logical = 8192, it is not part of item (item is [4096, 8191]). But the comparison is false and we think we have found the correct item, although we should be searing in the right subtree. This fixes some bugs I encountered. Signed-off-by: Marek Behun <marek.behun@nic.cz>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/chunk-map.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/chunk-map.c b/fs/btrfs/chunk-map.c
index beb6a4bb92..0c9a659f8f 100644
--- a/fs/btrfs/chunk-map.c
+++ b/fs/btrfs/chunk-map.c
@@ -78,7 +78,7 @@ u64 btrfs_map_logical_to_physical(u64 logical)
78 78
79 if (item->logical > logical) 79 if (item->logical > logical)
80 node = node->rb_left; 80 node = node->rb_left;
81 else if (logical > item->logical + item->length) 81 else if (logical >= item->logical + item->length)
82 node = node->rb_right; 82 node = node->rb_right;
83 else 83 else
84 return item->physical + logical - item->logical; 84 return item->physical + logical - item->logical;