diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-09-29 15:18:18 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-29 15:18:18 -0400 |
commit | d352ac68148b69937d39ca5d48bcc4478e118dbf (patch) | |
tree | 7951dd7311999d9e77766acdc7f8e93de97874d8 /fs/btrfs/dir-item.c | |
parent | 9a5e1ea1e1e539e244a54afffc330fc368376ab9 (diff) |
Btrfs: add and improve comments
This improves the comments at the top of many functions. It didn't
dive into the guts of functions because I was trying to
avoid merging problems with the new allocator and back reference work.
extent-tree.c and volumes.c were both skipped, and there is definitely
more work todo in cleaning and commenting the code.
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 | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c index e4f30090d640..5040b71f1900 100644 --- a/fs/btrfs/dir-item.c +++ b/fs/btrfs/dir-item.c | |||
@@ -21,6 +21,14 @@ | |||
21 | #include "hash.h" | 21 | #include "hash.h" |
22 | #include "transaction.h" | 22 | #include "transaction.h" |
23 | 23 | ||
24 | /* | ||
25 | * insert a name into a directory, doing overflow properly if there is a hash | ||
26 | * collision. data_size indicates how big the item inserted should be. On | ||
27 | * success a struct btrfs_dir_item pointer is returned, otherwise it is | ||
28 | * an ERR_PTR. | ||
29 | * | ||
30 | * The name is not copied into the dir item, you have to do that yourself. | ||
31 | */ | ||
24 | static struct btrfs_dir_item *insert_with_overflow(struct btrfs_trans_handle | 32 | static struct btrfs_dir_item *insert_with_overflow(struct btrfs_trans_handle |
25 | *trans, | 33 | *trans, |
26 | struct btrfs_root *root, | 34 | struct btrfs_root *root, |
@@ -55,6 +63,10 @@ static struct btrfs_dir_item *insert_with_overflow(struct btrfs_trans_handle | |||
55 | return (struct btrfs_dir_item *)ptr; | 63 | return (struct btrfs_dir_item *)ptr; |
56 | } | 64 | } |
57 | 65 | ||
66 | /* | ||
67 | * xattrs work a lot like directories, this inserts an xattr item | ||
68 | * into the tree | ||
69 | */ | ||
58 | int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans, | 70 | int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans, |
59 | struct btrfs_root *root, const char *name, | 71 | struct btrfs_root *root, const char *name, |
60 | u16 name_len, const void *data, u16 data_len, | 72 | u16 name_len, const void *data, u16 data_len, |
@@ -109,6 +121,13 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans, | |||
109 | return ret; | 121 | return ret; |
110 | } | 122 | } |
111 | 123 | ||
124 | /* | ||
125 | * insert a directory item in the tree, doing all the magic for | ||
126 | * both indexes. 'dir' indicates which objectid to insert it into, | ||
127 | * 'location' is the key to stuff into the directory item, 'type' is the | ||
128 | * type of the inode we're pointing to, and 'index' is the sequence number | ||
129 | * to use for the second index (if one is created). | ||
130 | */ | ||
112 | int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root | 131 | int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root |
113 | *root, const char *name, int name_len, u64 dir, | 132 | *root, const char *name, int name_len, u64 dir, |
114 | struct btrfs_key *location, u8 type, u64 index) | 133 | struct btrfs_key *location, u8 type, u64 index) |
@@ -184,6 +203,11 @@ out: | |||
184 | return 0; | 203 | return 0; |
185 | } | 204 | } |
186 | 205 | ||
206 | /* | ||
207 | * lookup a directory item based on name. 'dir' is the objectid | ||
208 | * we're searching in, and 'mod' tells us if you plan on deleting the | ||
209 | * item (use mod < 0) or changing the options (use mod > 0) | ||
210 | */ | ||
187 | struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, | 211 | struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, |
188 | struct btrfs_root *root, | 212 | struct btrfs_root *root, |
189 | struct btrfs_path *path, u64 dir, | 213 | struct btrfs_path *path, u64 dir, |
@@ -222,6 +246,14 @@ struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, | |||
222 | return btrfs_match_dir_item_name(root, path, name, name_len); | 246 | return btrfs_match_dir_item_name(root, path, name, name_len); |
223 | } | 247 | } |
224 | 248 | ||
249 | /* | ||
250 | * lookup a directory item based on index. 'dir' is the objectid | ||
251 | * we're searching in, and 'mod' tells us if you plan on deleting the | ||
252 | * item (use mod < 0) or changing the options (use mod > 0) | ||
253 | * | ||
254 | * The name is used to make sure the index really points to the name you were | ||
255 | * looking for. | ||
256 | */ | ||
225 | struct btrfs_dir_item * | 257 | struct btrfs_dir_item * |
226 | btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans, | 258 | btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans, |
227 | struct btrfs_root *root, | 259 | struct btrfs_root *root, |
@@ -282,6 +314,11 @@ struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans, | |||
282 | return btrfs_match_dir_item_name(root, path, name, name_len); | 314 | return btrfs_match_dir_item_name(root, path, name, name_len); |
283 | } | 315 | } |
284 | 316 | ||
317 | /* | ||
318 | * helper function to look at the directory item pointed to by 'path' | ||
319 | * this walks through all the entries in a dir item and finds one | ||
320 | * for a specific name. | ||
321 | */ | ||
285 | struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root, | 322 | struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root, |
286 | struct btrfs_path *path, | 323 | struct btrfs_path *path, |
287 | const char *name, int name_len) | 324 | const char *name, int name_len) |
@@ -313,6 +350,10 @@ struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root, | |||
313 | return NULL; | 350 | return NULL; |
314 | } | 351 | } |
315 | 352 | ||
353 | /* | ||
354 | * given a pointer into a directory item, delete it. This | ||
355 | * handles items that have more than one entry in them. | ||
356 | */ | ||
316 | int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans, | 357 | int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans, |
317 | struct btrfs_root *root, | 358 | struct btrfs_root *root, |
318 | struct btrfs_path *path, | 359 | struct btrfs_path *path, |