diff options
Diffstat (limited to 'fs/btrfs/ordered-data.c')
-rw-r--r-- | fs/btrfs/ordered-data.c | 19 |
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 | |||
30 | static u64 entry_end(struct btrfs_ordered_extent *entry) | 29 | static 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 | */ | ||
37 | static struct rb_node *tree_insert(struct rb_root *root, u64 file_offset, | 39 | static 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 | */ | ||
61 | static struct rb_node *__tree_search(struct rb_root *root, u64 file_offset, | 67 | static 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 | */ | ||
111 | static int offset_in_entry(struct btrfs_ordered_extent *entry, u64 file_offset) | 120 | static 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 | */ | ||
119 | static inline struct rb_node *tree_search(struct btrfs_ordered_inode_tree *tree, | 132 | static 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 | */ | ||
308 | int btrfs_wait_ordered_extents(struct btrfs_root *root, int nocow_only) | 325 | int btrfs_wait_ordered_extents(struct btrfs_root *root, int nocow_only) |
309 | { | 326 | { |
310 | struct list_head splice; | 327 | struct list_head splice; |