diff options
author | Jeff Mahoney <jeffm@suse.de> | 2011-07-21 12:56:09 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-08-01 14:30:43 -0400 |
commit | 1bf85046e493c88be1c1bad9084428373089f618 (patch) | |
tree | e7358cb2dd597c8be7001be4573fa0e53361ebb5 /fs/btrfs/extent_io.c | |
parent | b6973aa62253f3791ef6fa5e9f9de099645fc2bd (diff) |
btrfs: Make extent-io callbacks that never fail return void
The set/clear bit and the extent split/merge hooks only ever return 0.
Changing them to return void simplifies the error handling cases later.
This patch changes the hook prototypes, the single implementation of each,
and the functions that call them to return void instead.
Since all four of these hooks execute under a spinlock, they're necessarily
simple.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r-- | fs/btrfs/extent_io.c | 52 |
1 files changed, 14 insertions, 38 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 5bbdb243bb6f..789d0b23048f 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -254,14 +254,14 @@ static void merge_cb(struct extent_io_tree *tree, struct extent_state *new, | |||
254 | * | 254 | * |
255 | * This should be called with the tree lock held. | 255 | * This should be called with the tree lock held. |
256 | */ | 256 | */ |
257 | static int merge_state(struct extent_io_tree *tree, | 257 | static void merge_state(struct extent_io_tree *tree, |
258 | struct extent_state *state) | 258 | struct extent_state *state) |
259 | { | 259 | { |
260 | struct extent_state *other; | 260 | struct extent_state *other; |
261 | struct rb_node *other_node; | 261 | struct rb_node *other_node; |
262 | 262 | ||
263 | if (state->state & (EXTENT_IOBITS | EXTENT_BOUNDARY)) | 263 | if (state->state & (EXTENT_IOBITS | EXTENT_BOUNDARY)) |
264 | return 0; | 264 | return; |
265 | 265 | ||
266 | other_node = rb_prev(&state->rb_node); | 266 | other_node = rb_prev(&state->rb_node); |
267 | if (other_node) { | 267 | if (other_node) { |
@@ -287,19 +287,13 @@ static int merge_state(struct extent_io_tree *tree, | |||
287 | free_extent_state(other); | 287 | free_extent_state(other); |
288 | } | 288 | } |
289 | } | 289 | } |
290 | |||
291 | return 0; | ||
292 | } | 290 | } |
293 | 291 | ||
294 | static int set_state_cb(struct extent_io_tree *tree, | 292 | static void set_state_cb(struct extent_io_tree *tree, |
295 | struct extent_state *state, int *bits) | 293 | struct extent_state *state, int *bits) |
296 | { | 294 | { |
297 | if (tree->ops && tree->ops->set_bit_hook) { | 295 | if (tree->ops && tree->ops->set_bit_hook) |
298 | return tree->ops->set_bit_hook(tree->mapping->host, | 296 | tree->ops->set_bit_hook(tree->mapping->host, state, bits); |
299 | state, bits); | ||
300 | } | ||
301 | |||
302 | return 0; | ||
303 | } | 297 | } |
304 | 298 | ||
305 | static void clear_state_cb(struct extent_io_tree *tree, | 299 | static void clear_state_cb(struct extent_io_tree *tree, |
@@ -325,7 +319,6 @@ static int insert_state(struct extent_io_tree *tree, | |||
325 | { | 319 | { |
326 | struct rb_node *node; | 320 | struct rb_node *node; |
327 | int bits_to_set = *bits & ~EXTENT_CTLBITS; | 321 | int bits_to_set = *bits & ~EXTENT_CTLBITS; |
328 | int ret; | ||
329 | 322 | ||
330 | if (end < start) { | 323 | if (end < start) { |
331 | printk(KERN_ERR "btrfs end < start %llu %llu\n", | 324 | printk(KERN_ERR "btrfs end < start %llu %llu\n", |
@@ -335,9 +328,7 @@ static int insert_state(struct extent_io_tree *tree, | |||
335 | } | 328 | } |
336 | state->start = start; | 329 | state->start = start; |
337 | state->end = end; | 330 | state->end = end; |
338 | ret = set_state_cb(tree, state, bits); | 331 | set_state_cb(tree, state, bits); |
339 | if (ret) | ||
340 | return ret; | ||
341 | 332 | ||
342 | if (bits_to_set & EXTENT_DIRTY) | 333 | if (bits_to_set & EXTENT_DIRTY) |
343 | tree->dirty_bytes += end - start + 1; | 334 | tree->dirty_bytes += end - start + 1; |
@@ -357,13 +348,11 @@ static int insert_state(struct extent_io_tree *tree, | |||
357 | return 0; | 348 | return 0; |
358 | } | 349 | } |
359 | 350 | ||
360 | static int split_cb(struct extent_io_tree *tree, struct extent_state *orig, | 351 | static void split_cb(struct extent_io_tree *tree, struct extent_state *orig, |
361 | u64 split) | 352 | u64 split) |
362 | { | 353 | { |
363 | if (tree->ops && tree->ops->split_extent_hook) | 354 | if (tree->ops && tree->ops->split_extent_hook) |
364 | return tree->ops->split_extent_hook(tree->mapping->host, | 355 | tree->ops->split_extent_hook(tree->mapping->host, orig, split); |
365 | orig, split); | ||
366 | return 0; | ||
367 | } | 356 | } |
368 | 357 | ||
369 | /* | 358 | /* |
@@ -670,23 +659,18 @@ out: | |||
670 | return 0; | 659 | return 0; |
671 | } | 660 | } |
672 | 661 | ||
673 | static int set_state_bits(struct extent_io_tree *tree, | 662 | static void set_state_bits(struct extent_io_tree *tree, |
674 | struct extent_state *state, | 663 | struct extent_state *state, |
675 | int *bits) | 664 | int *bits) |
676 | { | 665 | { |
677 | int ret; | ||
678 | int bits_to_set = *bits & ~EXTENT_CTLBITS; | 666 | int bits_to_set = *bits & ~EXTENT_CTLBITS; |
679 | 667 | ||
680 | ret = set_state_cb(tree, state, bits); | 668 | set_state_cb(tree, state, bits); |
681 | if (ret) | ||
682 | return ret; | ||
683 | if ((bits_to_set & EXTENT_DIRTY) && !(state->state & EXTENT_DIRTY)) { | 669 | if ((bits_to_set & EXTENT_DIRTY) && !(state->state & EXTENT_DIRTY)) { |
684 | u64 range = state->end - state->start + 1; | 670 | u64 range = state->end - state->start + 1; |
685 | tree->dirty_bytes += range; | 671 | tree->dirty_bytes += range; |
686 | } | 672 | } |
687 | state->state |= bits_to_set; | 673 | state->state |= bits_to_set; |
688 | |||
689 | return 0; | ||
690 | } | 674 | } |
691 | 675 | ||
692 | static void cache_state(struct extent_state *state, | 676 | static void cache_state(struct extent_state *state, |
@@ -779,9 +763,7 @@ hit_next: | |||
779 | goto out; | 763 | goto out; |
780 | } | 764 | } |
781 | 765 | ||
782 | err = set_state_bits(tree, state, &bits); | 766 | set_state_bits(tree, state, &bits); |
783 | if (err) | ||
784 | goto out; | ||
785 | 767 | ||
786 | cache_state(state, cached_state); | 768 | cache_state(state, cached_state); |
787 | merge_state(tree, state); | 769 | merge_state(tree, state); |
@@ -830,9 +812,7 @@ hit_next: | |||
830 | if (err) | 812 | if (err) |
831 | goto out; | 813 | goto out; |
832 | if (state->end <= end) { | 814 | if (state->end <= end) { |
833 | err = set_state_bits(tree, state, &bits); | 815 | set_state_bits(tree, state, &bits); |
834 | if (err) | ||
835 | goto out; | ||
836 | cache_state(state, cached_state); | 816 | cache_state(state, cached_state); |
837 | merge_state(tree, state); | 817 | merge_state(tree, state); |
838 | if (last_end == (u64)-1) | 818 | if (last_end == (u64)-1) |
@@ -893,11 +873,7 @@ hit_next: | |||
893 | err = split_state(tree, state, prealloc, end + 1); | 873 | err = split_state(tree, state, prealloc, end + 1); |
894 | BUG_ON(err == -EEXIST); | 874 | BUG_ON(err == -EEXIST); |
895 | 875 | ||
896 | err = set_state_bits(tree, prealloc, &bits); | 876 | set_state_bits(tree, prealloc, &bits); |
897 | if (err) { | ||
898 | prealloc = NULL; | ||
899 | goto out; | ||
900 | } | ||
901 | cache_state(prealloc, cached_state); | 877 | cache_state(prealloc, cached_state); |
902 | merge_state(tree, prealloc); | 878 | merge_state(tree, prealloc); |
903 | prealloc = NULL; | 879 | prealloc = NULL; |