aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ordered-data.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-09-29 15:18:18 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-29 15:18:18 -0400
commitd352ac68148b69937d39ca5d48bcc4478e118dbf (patch)
tree7951dd7311999d9e77766acdc7f8e93de97874d8 /fs/btrfs/ordered-data.c
parent9a5e1ea1e1e539e244a54afffc330fc368376ab9 (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/ordered-data.c')
-rw-r--r--fs/btrfs/ordered-data.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 951eacff2420..dcc1730dd837 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -26,7 +26,6 @@
26#include "btrfs_inode.h" 26#include "btrfs_inode.h"
27#include "extent_io.h" 27#include "extent_io.h"
28 28
29
30static u64 entry_end(struct btrfs_ordered_extent *entry) 29static u64 entry_end(struct btrfs_ordered_extent *entry)
31{ 30{
32 if (entry->file_offset + entry->len < entry->file_offset) 31 if (entry->file_offset + entry->len < entry->file_offset)
@@ -34,6 +33,9 @@ static u64 entry_end(struct btrfs_ordered_extent *entry)
34 return entry->file_offset + entry->len; 33 return entry->file_offset + entry->len;
35} 34}
36 35
36/* returns NULL if the insertion worked, or it returns the node it did find
37 * in the tree
38 */
37static struct rb_node *tree_insert(struct rb_root *root, u64 file_offset, 39static struct rb_node *tree_insert(struct rb_root *root, u64 file_offset,
38 struct rb_node *node) 40 struct rb_node *node)
39{ 41{
@@ -58,6 +60,10 @@ static struct rb_node *tree_insert(struct rb_root *root, u64 file_offset,
58 return NULL; 60 return NULL;
59} 61}
60 62
63/*
64 * look for a given offset in the tree, and if it can't be found return the
65 * first lesser offset
66 */
61static struct rb_node *__tree_search(struct rb_root *root, u64 file_offset, 67static struct rb_node *__tree_search(struct rb_root *root, u64 file_offset,
62 struct rb_node **prev_ret) 68 struct rb_node **prev_ret)
63{ 69{
@@ -108,6 +114,9 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 file_offset,
108 return NULL; 114 return NULL;
109} 115}
110 116
117/*
118 * helper to check if a given offset is inside a given entry
119 */
111static int offset_in_entry(struct btrfs_ordered_extent *entry, u64 file_offset) 120static int offset_in_entry(struct btrfs_ordered_extent *entry, u64 file_offset)
112{ 121{
113 if (file_offset < entry->file_offset || 122 if (file_offset < entry->file_offset ||
@@ -116,6 +125,10 @@ static int offset_in_entry(struct btrfs_ordered_extent *entry, u64 file_offset)
116 return 1; 125 return 1;
117} 126}
118 127
128/*
129 * look find the first ordered struct that has this offset, otherwise
130 * the first one less than this offset
131 */
119static inline struct rb_node *tree_search(struct btrfs_ordered_inode_tree *tree, 132static inline struct rb_node *tree_search(struct btrfs_ordered_inode_tree *tree,
120 u64 file_offset) 133 u64 file_offset)
121{ 134{
@@ -305,6 +318,10 @@ int btrfs_remove_ordered_extent(struct inode *inode,
305 return 0; 318 return 0;
306} 319}
307 320
321/*
322 * wait for all the ordered extents in a root. This is done when balancing
323 * space between drives.
324 */
308int btrfs_wait_ordered_extents(struct btrfs_root *root, int nocow_only) 325int btrfs_wait_ordered_extents(struct btrfs_root *root, int nocow_only)
309{ 326{
310 struct list_head splice; 327 struct list_head splice;