diff options
Diffstat (limited to 'fs/btrfs/dir-item.c')
-rw-r--r-- | fs/btrfs/dir-item.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c index 0ee9945fb1b0..7aed9f015b55 100644 --- a/fs/btrfs/dir-item.c +++ b/fs/btrfs/dir-item.c | |||
@@ -25,8 +25,8 @@ int insert_with_overflow(struct btrfs_trans_handle *trans, struct btrfs_root | |||
25 | } | 25 | } |
26 | 26 | ||
27 | int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root | 27 | int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root |
28 | *root, const char *name, int name_len, u64 dir, u64 | 28 | *root, const char *name, int name_len, u64 dir, |
29 | objectid, u8 type) | 29 | struct btrfs_key *location, u8 type) |
30 | { | 30 | { |
31 | int ret = 0; | 31 | int ret = 0; |
32 | struct btrfs_path *path; | 32 | struct btrfs_path *path; |
@@ -50,17 +50,21 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root | |||
50 | dir_item = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]), | 50 | dir_item = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]), |
51 | path->slots[0], | 51 | path->slots[0], |
52 | struct btrfs_dir_item); | 52 | struct btrfs_dir_item); |
53 | btrfs_set_dir_objectid(dir_item, objectid); | 53 | btrfs_cpu_key_to_disk(&dir_item->location, location); |
54 | btrfs_set_dir_type(dir_item, type); | 54 | btrfs_set_dir_type(dir_item, type); |
55 | btrfs_set_dir_flags(dir_item, 0); | 55 | btrfs_set_dir_flags(dir_item, 0); |
56 | btrfs_set_dir_name_len(dir_item, name_len); | 56 | btrfs_set_dir_name_len(dir_item, name_len); |
57 | name_ptr = (char *)(dir_item + 1); | 57 | name_ptr = (char *)(dir_item + 1); |
58 | /* FIXME, use some real flag for selecting the extra index */ | ||
59 | if (root == root->fs_info->tree_root) | ||
60 | goto out; | ||
61 | |||
58 | btrfs_memcpy(root, path->nodes[0]->b_data, name_ptr, name, name_len); | 62 | btrfs_memcpy(root, path->nodes[0]->b_data, name_ptr, name, name_len); |
59 | btrfs_mark_buffer_dirty(path->nodes[0]); | 63 | btrfs_mark_buffer_dirty(path->nodes[0]); |
60 | btrfs_release_path(root, path); | 64 | btrfs_release_path(root, path); |
61 | 65 | ||
62 | btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY); | 66 | btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY); |
63 | key.offset = objectid; | 67 | key.offset = location->objectid; |
64 | ret = insert_with_overflow(trans, root, path, &key, data_size); | 68 | ret = insert_with_overflow(trans, root, path, &key, data_size); |
65 | // FIXME clear the dirindex bit | 69 | // FIXME clear the dirindex bit |
66 | if (ret) | 70 | if (ret) |
@@ -69,7 +73,7 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root | |||
69 | dir_item = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]), | 73 | dir_item = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]), |
70 | path->slots[0], | 74 | path->slots[0], |
71 | struct btrfs_dir_item); | 75 | struct btrfs_dir_item); |
72 | btrfs_set_dir_objectid(dir_item, objectid); | 76 | btrfs_cpu_key_to_disk(&dir_item->location, location); |
73 | btrfs_set_dir_type(dir_item, type); | 77 | btrfs_set_dir_type(dir_item, type); |
74 | btrfs_set_dir_flags(dir_item, 0); | 78 | btrfs_set_dir_flags(dir_item, 0); |
75 | btrfs_set_dir_name_len(dir_item, name_len); | 79 | btrfs_set_dir_name_len(dir_item, name_len); |