diff options
Diffstat (limited to 'fs/btrfs/delayed-ref.c')
-rw-r--r-- | fs/btrfs/delayed-ref.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index 66e4f29505a3..69f22e3ab3bc 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c | |||
@@ -420,7 +420,7 @@ update_existing_head_ref(struct btrfs_delayed_ref_node *existing, | |||
420 | * this does all the dirty work in terms of maintaining the correct | 420 | * this does all the dirty work in terms of maintaining the correct |
421 | * overall modification count. | 421 | * overall modification count. |
422 | */ | 422 | */ |
423 | static noinline int add_delayed_ref_head(struct btrfs_fs_info *fs_info, | 423 | static noinline void add_delayed_ref_head(struct btrfs_fs_info *fs_info, |
424 | struct btrfs_trans_handle *trans, | 424 | struct btrfs_trans_handle *trans, |
425 | struct btrfs_delayed_ref_node *ref, | 425 | struct btrfs_delayed_ref_node *ref, |
426 | u64 bytenr, u64 num_bytes, | 426 | u64 bytenr, u64 num_bytes, |
@@ -487,20 +487,19 @@ static noinline int add_delayed_ref_head(struct btrfs_fs_info *fs_info, | |||
487 | * we've updated the existing ref, free the newly | 487 | * we've updated the existing ref, free the newly |
488 | * allocated ref | 488 | * allocated ref |
489 | */ | 489 | */ |
490 | kfree(ref); | 490 | kfree(head_ref); |
491 | } else { | 491 | } else { |
492 | delayed_refs->num_heads++; | 492 | delayed_refs->num_heads++; |
493 | delayed_refs->num_heads_ready++; | 493 | delayed_refs->num_heads_ready++; |
494 | delayed_refs->num_entries++; | 494 | delayed_refs->num_entries++; |
495 | trans->delayed_ref_updates++; | 495 | trans->delayed_ref_updates++; |
496 | } | 496 | } |
497 | return 0; | ||
498 | } | 497 | } |
499 | 498 | ||
500 | /* | 499 | /* |
501 | * helper to insert a delayed tree ref into the rbtree. | 500 | * helper to insert a delayed tree ref into the rbtree. |
502 | */ | 501 | */ |
503 | static noinline int add_delayed_tree_ref(struct btrfs_fs_info *fs_info, | 502 | static noinline void add_delayed_tree_ref(struct btrfs_fs_info *fs_info, |
504 | struct btrfs_trans_handle *trans, | 503 | struct btrfs_trans_handle *trans, |
505 | struct btrfs_delayed_ref_node *ref, | 504 | struct btrfs_delayed_ref_node *ref, |
506 | u64 bytenr, u64 num_bytes, u64 parent, | 505 | u64 bytenr, u64 num_bytes, u64 parent, |
@@ -549,18 +548,17 @@ static noinline int add_delayed_tree_ref(struct btrfs_fs_info *fs_info, | |||
549 | * we've updated the existing ref, free the newly | 548 | * we've updated the existing ref, free the newly |
550 | * allocated ref | 549 | * allocated ref |
551 | */ | 550 | */ |
552 | kfree(ref); | 551 | kfree(full_ref); |
553 | } else { | 552 | } else { |
554 | delayed_refs->num_entries++; | 553 | delayed_refs->num_entries++; |
555 | trans->delayed_ref_updates++; | 554 | trans->delayed_ref_updates++; |
556 | } | 555 | } |
557 | return 0; | ||
558 | } | 556 | } |
559 | 557 | ||
560 | /* | 558 | /* |
561 | * helper to insert a delayed data ref into the rbtree. | 559 | * helper to insert a delayed data ref into the rbtree. |
562 | */ | 560 | */ |
563 | static noinline int add_delayed_data_ref(struct btrfs_fs_info *fs_info, | 561 | static noinline void add_delayed_data_ref(struct btrfs_fs_info *fs_info, |
564 | struct btrfs_trans_handle *trans, | 562 | struct btrfs_trans_handle *trans, |
565 | struct btrfs_delayed_ref_node *ref, | 563 | struct btrfs_delayed_ref_node *ref, |
566 | u64 bytenr, u64 num_bytes, u64 parent, | 564 | u64 bytenr, u64 num_bytes, u64 parent, |
@@ -611,12 +609,11 @@ static noinline int add_delayed_data_ref(struct btrfs_fs_info *fs_info, | |||
611 | * we've updated the existing ref, free the newly | 609 | * we've updated the existing ref, free the newly |
612 | * allocated ref | 610 | * allocated ref |
613 | */ | 611 | */ |
614 | kfree(ref); | 612 | kfree(full_ref); |
615 | } else { | 613 | } else { |
616 | delayed_refs->num_entries++; | 614 | delayed_refs->num_entries++; |
617 | trans->delayed_ref_updates++; | 615 | trans->delayed_ref_updates++; |
618 | } | 616 | } |
619 | return 0; | ||
620 | } | 617 | } |
621 | 618 | ||
622 | /* | 619 | /* |
@@ -634,7 +631,6 @@ int btrfs_add_delayed_tree_ref(struct btrfs_fs_info *fs_info, | |||
634 | struct btrfs_delayed_tree_ref *ref; | 631 | struct btrfs_delayed_tree_ref *ref; |
635 | struct btrfs_delayed_ref_head *head_ref; | 632 | struct btrfs_delayed_ref_head *head_ref; |
636 | struct btrfs_delayed_ref_root *delayed_refs; | 633 | struct btrfs_delayed_ref_root *delayed_refs; |
637 | int ret; | ||
638 | 634 | ||
639 | BUG_ON(extent_op && extent_op->is_data); | 635 | BUG_ON(extent_op && extent_op->is_data); |
640 | ref = kmalloc(sizeof(*ref), GFP_NOFS); | 636 | ref = kmalloc(sizeof(*ref), GFP_NOFS); |
@@ -656,14 +652,12 @@ int btrfs_add_delayed_tree_ref(struct btrfs_fs_info *fs_info, | |||
656 | * insert both the head node and the new ref without dropping | 652 | * insert both the head node and the new ref without dropping |
657 | * the spin lock | 653 | * the spin lock |
658 | */ | 654 | */ |
659 | ret = add_delayed_ref_head(fs_info, trans, &head_ref->node, bytenr, | 655 | add_delayed_ref_head(fs_info, trans, &head_ref->node, bytenr, |
660 | num_bytes, action, 0); | 656 | num_bytes, action, 0); |
661 | BUG_ON(ret); | ||
662 | 657 | ||
663 | ret = add_delayed_tree_ref(fs_info, trans, &ref->node, bytenr, | 658 | add_delayed_tree_ref(fs_info, trans, &ref->node, bytenr, |
664 | num_bytes, parent, ref_root, level, action, | 659 | num_bytes, parent, ref_root, level, action, |
665 | for_cow); | 660 | for_cow); |
666 | BUG_ON(ret); | ||
667 | if (!need_ref_seq(for_cow, ref_root) && | 661 | if (!need_ref_seq(for_cow, ref_root) && |
668 | waitqueue_active(&delayed_refs->seq_wait)) | 662 | waitqueue_active(&delayed_refs->seq_wait)) |
669 | wake_up(&delayed_refs->seq_wait); | 663 | wake_up(&delayed_refs->seq_wait); |
@@ -685,7 +679,6 @@ int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info, | |||
685 | struct btrfs_delayed_data_ref *ref; | 679 | struct btrfs_delayed_data_ref *ref; |
686 | struct btrfs_delayed_ref_head *head_ref; | 680 | struct btrfs_delayed_ref_head *head_ref; |
687 | struct btrfs_delayed_ref_root *delayed_refs; | 681 | struct btrfs_delayed_ref_root *delayed_refs; |
688 | int ret; | ||
689 | 682 | ||
690 | BUG_ON(extent_op && !extent_op->is_data); | 683 | BUG_ON(extent_op && !extent_op->is_data); |
691 | ref = kmalloc(sizeof(*ref), GFP_NOFS); | 684 | ref = kmalloc(sizeof(*ref), GFP_NOFS); |
@@ -707,14 +700,12 @@ int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info, | |||
707 | * insert both the head node and the new ref without dropping | 700 | * insert both the head node and the new ref without dropping |
708 | * the spin lock | 701 | * the spin lock |
709 | */ | 702 | */ |
710 | ret = add_delayed_ref_head(fs_info, trans, &head_ref->node, bytenr, | 703 | add_delayed_ref_head(fs_info, trans, &head_ref->node, bytenr, |
711 | num_bytes, action, 1); | 704 | num_bytes, action, 1); |
712 | BUG_ON(ret); | ||
713 | 705 | ||
714 | ret = add_delayed_data_ref(fs_info, trans, &ref->node, bytenr, | 706 | add_delayed_data_ref(fs_info, trans, &ref->node, bytenr, |
715 | num_bytes, parent, ref_root, owner, offset, | 707 | num_bytes, parent, ref_root, owner, offset, |
716 | action, for_cow); | 708 | action, for_cow); |
717 | BUG_ON(ret); | ||
718 | if (!need_ref_seq(for_cow, ref_root) && | 709 | if (!need_ref_seq(for_cow, ref_root) && |
719 | waitqueue_active(&delayed_refs->seq_wait)) | 710 | waitqueue_active(&delayed_refs->seq_wait)) |
720 | wake_up(&delayed_refs->seq_wait); | 711 | wake_up(&delayed_refs->seq_wait); |
@@ -729,7 +720,6 @@ int btrfs_add_delayed_extent_op(struct btrfs_fs_info *fs_info, | |||
729 | { | 720 | { |
730 | struct btrfs_delayed_ref_head *head_ref; | 721 | struct btrfs_delayed_ref_head *head_ref; |
731 | struct btrfs_delayed_ref_root *delayed_refs; | 722 | struct btrfs_delayed_ref_root *delayed_refs; |
732 | int ret; | ||
733 | 723 | ||
734 | head_ref = kmalloc(sizeof(*head_ref), GFP_NOFS); | 724 | head_ref = kmalloc(sizeof(*head_ref), GFP_NOFS); |
735 | if (!head_ref) | 725 | if (!head_ref) |
@@ -740,10 +730,9 @@ int btrfs_add_delayed_extent_op(struct btrfs_fs_info *fs_info, | |||
740 | delayed_refs = &trans->transaction->delayed_refs; | 730 | delayed_refs = &trans->transaction->delayed_refs; |
741 | spin_lock(&delayed_refs->lock); | 731 | spin_lock(&delayed_refs->lock); |
742 | 732 | ||
743 | ret = add_delayed_ref_head(fs_info, trans, &head_ref->node, bytenr, | 733 | add_delayed_ref_head(fs_info, trans, &head_ref->node, bytenr, |
744 | num_bytes, BTRFS_UPDATE_DELAYED_HEAD, | 734 | num_bytes, BTRFS_UPDATE_DELAYED_HEAD, |
745 | extent_op->is_data); | 735 | extent_op->is_data); |
746 | BUG_ON(ret); | ||
747 | 736 | ||
748 | if (waitqueue_active(&delayed_refs->seq_wait)) | 737 | if (waitqueue_active(&delayed_refs->seq_wait)) |
749 | wake_up(&delayed_refs->seq_wait); | 738 | wake_up(&delayed_refs->seq_wait); |