summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/ioctl.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f88eeea365f3..82fb11a361c4 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2013,19 +2013,21 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info,
2013 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); 2013 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
2014 if (ret < 0) 2014 if (ret < 0)
2015 goto out; 2015 goto out;
2016 else if (ret > 0) {
2017 ret = btrfs_previous_item(root, path, dirid,
2018 BTRFS_INODE_REF_KEY);
2019 if (ret < 0)
2020 goto out;
2021 else if (ret > 0) {
2022 ret = -ENOENT;
2023 goto out;
2024 }
2025 }
2016 2026
2017 l = path->nodes[0]; 2027 l = path->nodes[0];
2018 slot = path->slots[0]; 2028 slot = path->slots[0];
2019 if (ret > 0 && slot > 0)
2020 slot--;
2021 btrfs_item_key_to_cpu(l, &key, slot); 2029 btrfs_item_key_to_cpu(l, &key, slot);
2022 2030
2023 if (ret > 0 && (key.objectid != dirid ||
2024 key.type != BTRFS_INODE_REF_KEY)) {
2025 ret = -ENOENT;
2026 goto out;
2027 }
2028
2029 iref = btrfs_item_ptr(l, slot, struct btrfs_inode_ref); 2031 iref = btrfs_item_ptr(l, slot, struct btrfs_inode_ref);
2030 len = btrfs_inode_ref_name_len(l, iref); 2032 len = btrfs_inode_ref_name_len(l, iref);
2031 ptr -= len + 1; 2033 ptr -= len + 1;