diff options
author | Wang Shilong <wangsl.fnst@cn.fujitsu.com> | 2014-02-06 07:02:29 -0500 |
---|---|---|
committer | Josef Bacik <jbacik@fb.com> | 2014-03-10 15:15:54 -0400 |
commit | 850a8cdffe41abec9e3319d7801c49eced0778a1 (patch) | |
tree | 984f0986b44bfa8fc6e6395acdab4b15d333082b /fs/btrfs/backref.c | |
parent | f88ba6a2a44ee98e8d59654463dc157bb6d13c43 (diff) |
Btrfs: switch to btrfs_previous_extent_item()
Since we have introduced btrfs_previous_extent_item() to search previous
extent item, just switch into it.
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Reviewed-by: Filipe Manana <fdmanana@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Diffstat (limited to 'fs/btrfs/backref.c')
-rw-r--r-- | fs/btrfs/backref.c | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index 903fe68e017b..a88da721dfc5 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c | |||
@@ -1325,38 +1325,13 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical, | |||
1325 | if (ret < 0) | 1325 | if (ret < 0) |
1326 | return ret; | 1326 | return ret; |
1327 | 1327 | ||
1328 | while (1) { | 1328 | ret = btrfs_previous_extent_item(fs_info->extent_root, path, 0); |
1329 | u32 nritems; | 1329 | if (ret) { |
1330 | if (path->slots[0] == 0) { | 1330 | if (ret > 0) |
1331 | btrfs_set_path_blocking(path); | 1331 | ret = -ENOENT; |
1332 | ret = btrfs_prev_leaf(fs_info->extent_root, path); | 1332 | return ret; |
1333 | if (ret != 0) { | ||
1334 | if (ret > 0) { | ||
1335 | pr_debug("logical %llu is not within " | ||
1336 | "any extent\n", logical); | ||
1337 | ret = -ENOENT; | ||
1338 | } | ||
1339 | return ret; | ||
1340 | } | ||
1341 | } else { | ||
1342 | path->slots[0]--; | ||
1343 | } | ||
1344 | nritems = btrfs_header_nritems(path->nodes[0]); | ||
1345 | if (nritems == 0) { | ||
1346 | pr_debug("logical %llu is not within any extent\n", | ||
1347 | logical); | ||
1348 | return -ENOENT; | ||
1349 | } | ||
1350 | if (path->slots[0] == nritems) | ||
1351 | path->slots[0]--; | ||
1352 | |||
1353 | btrfs_item_key_to_cpu(path->nodes[0], found_key, | ||
1354 | path->slots[0]); | ||
1355 | if (found_key->type == BTRFS_EXTENT_ITEM_KEY || | ||
1356 | found_key->type == BTRFS_METADATA_ITEM_KEY) | ||
1357 | break; | ||
1358 | } | 1333 | } |
1359 | 1334 | btrfs_item_key_to_cpu(path->nodes[0], found_key, path->slots[0]); | |
1360 | if (found_key->type == BTRFS_METADATA_ITEM_KEY) | 1335 | if (found_key->type == BTRFS_METADATA_ITEM_KEY) |
1361 | size = fs_info->extent_root->leafsize; | 1336 | size = fs_info->extent_root->leafsize; |
1362 | else if (found_key->type == BTRFS_EXTENT_ITEM_KEY) | 1337 | else if (found_key->type == BTRFS_EXTENT_ITEM_KEY) |