diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2012-09-20 03:51:59 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2012-10-09 09:15:38 -0400 |
commit | a698d0755adb6f27289d1e6610b2240595d27e8c (patch) | |
tree | bf54f9bcd6941a459be5aeaf22299547c693c0aa /fs/btrfs/transaction.c | |
parent | e8830e606ffee383f073e32313f11fc5692813fe (diff) |
Btrfs: add a type field for the transaction handle
This patch add a type field into the transaction handle structure,
in this way, we needn't implement various end-transaction functions
and can make the code more simple and readable.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r-- | fs/btrfs/transaction.c | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 35489644c247..d0a2b7e49381 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -267,14 +267,6 @@ static void wait_current_trans(struct btrfs_root *root) | |||
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | enum btrfs_trans_type { | ||
271 | TRANS_START, | ||
272 | TRANS_JOIN, | ||
273 | TRANS_USERSPACE, | ||
274 | TRANS_JOIN_NOLOCK, | ||
275 | TRANS_JOIN_FREEZE, | ||
276 | }; | ||
277 | |||
278 | static int may_wait_transaction(struct btrfs_root *root, int type) | 270 | static int may_wait_transaction(struct btrfs_root *root, int type) |
279 | { | 271 | { |
280 | if (root->fs_info->log_root_recovering) | 272 | if (root->fs_info->log_root_recovering) |
@@ -388,6 +380,7 @@ again: | |||
388 | h->aborted = 0; | 380 | h->aborted = 0; |
389 | h->qgroup_reserved = qgroup_reserved; | 381 | h->qgroup_reserved = qgroup_reserved; |
390 | h->delayed_ref_elem.seq = 0; | 382 | h->delayed_ref_elem.seq = 0; |
383 | h->type = type; | ||
391 | INIT_LIST_HEAD(&h->qgroup_ref_list); | 384 | INIT_LIST_HEAD(&h->qgroup_ref_list); |
392 | INIT_LIST_HEAD(&h->new_bgs); | 385 | INIT_LIST_HEAD(&h->new_bgs); |
393 | 386 | ||
@@ -540,11 +533,12 @@ int btrfs_should_end_transaction(struct btrfs_trans_handle *trans, | |||
540 | } | 533 | } |
541 | 534 | ||
542 | static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, | 535 | static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, |
543 | struct btrfs_root *root, int throttle, int lock) | 536 | struct btrfs_root *root, int throttle) |
544 | { | 537 | { |
545 | struct btrfs_transaction *cur_trans = trans->transaction; | 538 | struct btrfs_transaction *cur_trans = trans->transaction; |
546 | struct btrfs_fs_info *info = root->fs_info; | 539 | struct btrfs_fs_info *info = root->fs_info; |
547 | int count = 0; | 540 | int count = 0; |
541 | int lock = (trans->type != TRANS_JOIN_NOLOCK); | ||
548 | int err = 0; | 542 | int err = 0; |
549 | 543 | ||
550 | if (--trans->use_count) { | 544 | if (--trans->use_count) { |
@@ -645,7 +639,7 @@ int btrfs_end_transaction(struct btrfs_trans_handle *trans, | |||
645 | { | 639 | { |
646 | int ret; | 640 | int ret; |
647 | 641 | ||
648 | ret = __btrfs_end_transaction(trans, root, 0, 1); | 642 | ret = __btrfs_end_transaction(trans, root, 0); |
649 | if (ret) | 643 | if (ret) |
650 | return ret; | 644 | return ret; |
651 | return 0; | 645 | return 0; |
@@ -656,18 +650,7 @@ int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans, | |||
656 | { | 650 | { |
657 | int ret; | 651 | int ret; |
658 | 652 | ||
659 | ret = __btrfs_end_transaction(trans, root, 1, 1); | 653 | ret = __btrfs_end_transaction(trans, root, 1); |
660 | if (ret) | ||
661 | return ret; | ||
662 | return 0; | ||
663 | } | ||
664 | |||
665 | int btrfs_end_transaction_nolock(struct btrfs_trans_handle *trans, | ||
666 | struct btrfs_root *root) | ||
667 | { | ||
668 | int ret; | ||
669 | |||
670 | ret = __btrfs_end_transaction(trans, root, 0, 0); | ||
671 | if (ret) | 654 | if (ret) |
672 | return ret; | 655 | return ret; |
673 | return 0; | 656 | return 0; |
@@ -676,7 +659,7 @@ int btrfs_end_transaction_nolock(struct btrfs_trans_handle *trans, | |||
676 | int btrfs_end_transaction_dmeta(struct btrfs_trans_handle *trans, | 659 | int btrfs_end_transaction_dmeta(struct btrfs_trans_handle *trans, |
677 | struct btrfs_root *root) | 660 | struct btrfs_root *root) |
678 | { | 661 | { |
679 | return __btrfs_end_transaction(trans, root, 1, 1); | 662 | return __btrfs_end_transaction(trans, root, 1); |
680 | } | 663 | } |
681 | 664 | ||
682 | /* | 665 | /* |