diff options
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r-- | fs/btrfs/extent_io.c | 34 |
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 | } |
915 | EXPORT_SYMBOL(wait_on_extent_writeback); | 915 | EXPORT_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 | */ | ||
917 | int lock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask) | 921 | int 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 | } |
983 | EXPORT_SYMBOL(set_range_writeback); | 987 | EXPORT_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 | */ | ||
985 | int find_first_extent_bit(struct extent_io_tree *tree, u64 start, | 996 | int 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 | } |
1018 | EXPORT_SYMBOL(find_first_extent_bit); | 1029 | EXPORT_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 | */ | ||
1020 | struct extent_state *find_first_extent_bit_state(struct extent_io_tree *tree, | 1035 | struct 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 | } |
1047 | EXPORT_SYMBOL(find_first_extent_bit_state); | 1062 | EXPORT_SYMBOL(find_first_extent_bit_state); |
1048 | 1063 | ||
1049 | u64 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 | */ | ||
1070 | static 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 | */ | ||
1133 | u64 count_range_bits(struct extent_io_tree *tree, | 1159 | u64 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 | } |
1246 | EXPORT_SYMBOL(unlock_range); | 1272 | EXPORT_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 | */ | ||
1248 | int set_state_private(struct extent_io_tree *tree, u64 start, u64 private) | 1278 | int set_state_private(struct extent_io_tree *tree, u64 start, u64 private) |
1249 | { | 1279 | { |
1250 | struct rb_node *node; | 1280 | struct rb_node *node; |