aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.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/extent_io.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/extent_io.c')
-rw-r--r--fs/btrfs/extent_io.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 8bd1b402f3fd..563b2d12f4f2 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -914,6 +914,10 @@ int wait_on_extent_writeback(struct extent_io_tree *tree, u64 start, u64 end)
914} 914}
915EXPORT_SYMBOL(wait_on_extent_writeback); 915EXPORT_SYMBOL(wait_on_extent_writeback);
916 916
917/*
918 * either insert or lock state struct between start and end use mask to tell
919 * us if waiting is desired.
920 */
917int lock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask) 921int lock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask)
918{ 922{
919 int err; 923 int err;
@@ -982,6 +986,13 @@ int set_range_writeback(struct extent_io_tree *tree, u64 start, u64 end)
982} 986}
983EXPORT_SYMBOL(set_range_writeback); 987EXPORT_SYMBOL(set_range_writeback);
984 988
989/*
990 * find the first offset in the io tree with 'bits' set. zero is
991 * returned if we find something, and *start_ret and *end_ret are
992 * set to reflect the state struct that was found.
993 *
994 * If nothing was found, 1 is returned, < 0 on error
995 */
985int find_first_extent_bit(struct extent_io_tree *tree, u64 start, 996int find_first_extent_bit(struct extent_io_tree *tree, u64 start,
986 u64 *start_ret, u64 *end_ret, int bits) 997 u64 *start_ret, u64 *end_ret, int bits)
987{ 998{
@@ -1017,6 +1028,10 @@ out:
1017} 1028}
1018EXPORT_SYMBOL(find_first_extent_bit); 1029EXPORT_SYMBOL(find_first_extent_bit);
1019 1030
1031/* find the first state struct with 'bits' set after 'start', and
1032 * return it. tree->lock must be held. NULL will returned if
1033 * nothing was found after 'start'
1034 */
1020struct extent_state *find_first_extent_bit_state(struct extent_io_tree *tree, 1035struct extent_state *find_first_extent_bit_state(struct extent_io_tree *tree,
1021 u64 start, int bits) 1036 u64 start, int bits)
1022{ 1037{
@@ -1046,8 +1061,14 @@ out:
1046} 1061}
1047EXPORT_SYMBOL(find_first_extent_bit_state); 1062EXPORT_SYMBOL(find_first_extent_bit_state);
1048 1063
1049u64 find_lock_delalloc_range(struct extent_io_tree *tree, 1064/*
1050 u64 *start, u64 *end, u64 max_bytes) 1065 * find a contiguous range of bytes in the file marked as delalloc, not
1066 * more than 'max_bytes'. start and end are used to return the range,
1067 *
1068 * 1 is returned if we find something, 0 if nothing was in the tree
1069 */
1070static noinline u64 find_lock_delalloc_range(struct extent_io_tree *tree,
1071 u64 *start, u64 *end, u64 max_bytes)
1051{ 1072{
1052 struct rb_node *node; 1073 struct rb_node *node;
1053 struct extent_state *state; 1074 struct extent_state *state;
@@ -1130,6 +1151,11 @@ out:
1130 return found; 1151 return found;
1131} 1152}
1132 1153
1154/*
1155 * count the number of bytes in the tree that have a given bit(s)
1156 * set. This can be fairly slow, except for EXTENT_DIRTY which is
1157 * cached. The total number found is returned.
1158 */
1133u64 count_range_bits(struct extent_io_tree *tree, 1159u64 count_range_bits(struct extent_io_tree *tree,
1134 u64 *start, u64 search_end, u64 max_bytes, 1160 u64 *start, u64 search_end, u64 max_bytes,
1135 unsigned long bits) 1161 unsigned long bits)
@@ -1245,6 +1271,10 @@ int unlock_range(struct extent_io_tree *tree, u64 start, u64 end)
1245} 1271}
1246EXPORT_SYMBOL(unlock_range); 1272EXPORT_SYMBOL(unlock_range);
1247 1273
1274/*
1275 * set the private field for a given byte offset in the tree. If there isn't
1276 * an extent_state there already, this does nothing.
1277 */
1248int set_state_private(struct extent_io_tree *tree, u64 start, u64 private) 1278int set_state_private(struct extent_io_tree *tree, u64 start, u64 private)
1249{ 1279{
1250 struct rb_node *node; 1280 struct rb_node *node;