diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-05-23 15:44:28 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-05-23 15:44:28 -0400 |
commit | e06afa839e726959be2166bec4cb85c117e213f1 (patch) | |
tree | f2acae733ce4c4368e3368cf912b1c76462aa0f7 /fs/btrfs/dir-item.c | |
parent | f9f3c6b666f717510b67036c314ec915b9059eaa (diff) |
Btrfs: rename
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/dir-item.c')
-rw-r--r-- | fs/btrfs/dir-item.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c index 00a28d90fea6..b408a3d20c7b 100644 --- a/fs/btrfs/dir-item.c +++ b/fs/btrfs/dir-item.c | |||
@@ -9,7 +9,9 @@ static struct btrfs_dir_item *insert_with_overflow(struct btrfs_trans_handle | |||
9 | struct btrfs_root *root, | 9 | struct btrfs_root *root, |
10 | struct btrfs_path *path, | 10 | struct btrfs_path *path, |
11 | struct btrfs_key *cpu_key, | 11 | struct btrfs_key *cpu_key, |
12 | u32 data_size) | 12 | u32 data_size, |
13 | const char *name, | ||
14 | int name_len) | ||
13 | { | 15 | { |
14 | int ret; | 16 | int ret; |
15 | char *ptr; | 17 | char *ptr; |
@@ -18,6 +20,10 @@ static struct btrfs_dir_item *insert_with_overflow(struct btrfs_trans_handle | |||
18 | 20 | ||
19 | ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size); | 21 | ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size); |
20 | if (ret == -EEXIST) { | 22 | if (ret == -EEXIST) { |
23 | struct btrfs_dir_item *di; | ||
24 | di = btrfs_match_dir_item_name(root, path, name, name_len); | ||
25 | if (di) | ||
26 | return ERR_PTR(-EEXIST); | ||
21 | ret = btrfs_extend_item(trans, root, path, data_size); | 27 | ret = btrfs_extend_item(trans, root, path, data_size); |
22 | WARN_ON(ret > 0); | 28 | WARN_ON(ret > 0); |
23 | if (ret) | 29 | if (ret) |
@@ -37,6 +43,7 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root | |||
37 | struct btrfs_key *location, u8 type) | 43 | struct btrfs_key *location, u8 type) |
38 | { | 44 | { |
39 | int ret = 0; | 45 | int ret = 0; |
46 | int ret2 = 0; | ||
40 | struct btrfs_path *path; | 47 | struct btrfs_path *path; |
41 | struct btrfs_dir_item *dir_item; | 48 | struct btrfs_dir_item *dir_item; |
42 | char *name_ptr; | 49 | char *name_ptr; |
@@ -51,9 +58,12 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root | |||
51 | path = btrfs_alloc_path(); | 58 | path = btrfs_alloc_path(); |
52 | btrfs_init_path(path); | 59 | btrfs_init_path(path); |
53 | data_size = sizeof(*dir_item) + name_len; | 60 | data_size = sizeof(*dir_item) + name_len; |
54 | dir_item = insert_with_overflow(trans, root, path, &key, data_size); | 61 | dir_item = insert_with_overflow(trans, root, path, &key, data_size, |
62 | name, name_len); | ||
55 | if (IS_ERR(dir_item)) { | 63 | if (IS_ERR(dir_item)) { |
56 | ret = PTR_ERR(dir_item); | 64 | ret = PTR_ERR(dir_item); |
65 | if (ret == -EEXIST) | ||
66 | goto second_insert; | ||
57 | goto out; | 67 | goto out; |
58 | } | 68 | } |
59 | 69 | ||
@@ -66,19 +76,20 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root | |||
66 | btrfs_memcpy(root, path->nodes[0]->b_data, name_ptr, name, name_len); | 76 | btrfs_memcpy(root, path->nodes[0]->b_data, name_ptr, name, name_len); |
67 | btrfs_mark_buffer_dirty(path->nodes[0]); | 77 | btrfs_mark_buffer_dirty(path->nodes[0]); |
68 | 78 | ||
79 | second_insert: | ||
69 | /* FIXME, use some real flag for selecting the extra index */ | 80 | /* FIXME, use some real flag for selecting the extra index */ |
70 | if (root == root->fs_info->tree_root) { | 81 | if (root == root->fs_info->tree_root) { |
71 | ret = 0; | 82 | ret = 0; |
72 | goto out; | 83 | goto out; |
73 | } | 84 | } |
74 | |||
75 | btrfs_release_path(root, path); | 85 | btrfs_release_path(root, path); |
76 | 86 | ||
77 | btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY); | 87 | btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY); |
78 | key.offset = location->objectid; | 88 | key.offset = location->objectid; |
79 | dir_item = insert_with_overflow(trans, root, path, &key, data_size); | 89 | dir_item = insert_with_overflow(trans, root, path, &key, data_size, |
90 | name, name_len); | ||
80 | if (IS_ERR(dir_item)) { | 91 | if (IS_ERR(dir_item)) { |
81 | ret = PTR_ERR(dir_item); | 92 | ret2 = PTR_ERR(dir_item); |
82 | goto out; | 93 | goto out; |
83 | } | 94 | } |
84 | btrfs_cpu_key_to_disk(&dir_item->location, location); | 95 | btrfs_cpu_key_to_disk(&dir_item->location, location); |
@@ -90,7 +101,11 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root | |||
90 | btrfs_mark_buffer_dirty(path->nodes[0]); | 101 | btrfs_mark_buffer_dirty(path->nodes[0]); |
91 | out: | 102 | out: |
92 | btrfs_free_path(path); | 103 | btrfs_free_path(path); |
93 | return ret; | 104 | if (ret) |
105 | return ret; | ||
106 | if (ret2) | ||
107 | return ret2; | ||
108 | return 0; | ||
94 | } | 109 | } |
95 | 110 | ||
96 | struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, | 111 | struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, |