diff options
Diffstat (limited to 'fs/btrfs')
| -rw-r--r-- | fs/btrfs/inode.c | 19 | ||||
| -rw-r--r-- | fs/btrfs/transaction.c | 29 | ||||
| -rw-r--r-- | fs/btrfs/transaction.h | 15 | 
3 files changed, 21 insertions, 42 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 596305e4d75b..e355eb0aea1e 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c  | |||
| @@ -1363,11 +1363,7 @@ out_check: | |||
| 1363 | } | 1363 | } | 
| 1364 | 1364 | ||
| 1365 | error: | 1365 | error: | 
| 1366 | if (nolock) { | 1366 | err = btrfs_end_transaction(trans, root); | 
| 1367 | err = btrfs_end_transaction_nolock(trans, root); | ||
| 1368 | } else { | ||
| 1369 | err = btrfs_end_transaction(trans, root); | ||
| 1370 | } | ||
| 1371 | if (!ret) | 1367 | if (!ret) | 
| 1372 | ret = err; | 1368 | ret = err; | 
| 1373 | 1369 | ||
| @@ -1957,12 +1953,8 @@ out_unlock: | |||
| 1957 | out: | 1953 | out: | 
| 1958 | if (root != root->fs_info->tree_root) | 1954 | if (root != root->fs_info->tree_root) | 
| 1959 | btrfs_delalloc_release_metadata(inode, ordered_extent->len); | 1955 | btrfs_delalloc_release_metadata(inode, ordered_extent->len); | 
| 1960 | if (trans) { | 1956 | if (trans) | 
| 1961 | if (nolock) | 1957 | btrfs_end_transaction(trans, root); | 
| 1962 | btrfs_end_transaction_nolock(trans, root); | ||
| 1963 | else | ||
| 1964 | btrfs_end_transaction(trans, root); | ||
| 1965 | } | ||
| 1966 | 1958 | ||
| 1967 | if (ret) | 1959 | if (ret) | 
| 1968 | clear_extent_uptodate(io_tree, ordered_extent->file_offset, | 1960 | clear_extent_uptodate(io_tree, ordered_extent->file_offset, | 
| @@ -4524,10 +4516,7 @@ int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
| 4524 | trans = btrfs_join_transaction(root); | 4516 | trans = btrfs_join_transaction(root); | 
| 4525 | if (IS_ERR(trans)) | 4517 | if (IS_ERR(trans)) | 
| 4526 | return PTR_ERR(trans); | 4518 | return PTR_ERR(trans); | 
| 4527 | if (nolock) | 4519 | ret = btrfs_commit_transaction(trans, root); | 
| 4528 | ret = btrfs_end_transaction_nolock(trans, root); | ||
| 4529 | else | ||
| 4530 | ret = btrfs_commit_transaction(trans, root); | ||
| 4531 | } | 4520 | } | 
| 4532 | return ret; | 4521 | return ret; | 
| 4533 | } | 4522 | } | 
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 | /* | 
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index fbf8313b9d67..0630bd19396a 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h  | |||
| @@ -47,6 +47,14 @@ struct btrfs_transaction { | |||
| 47 | int aborted; | 47 | int aborted; | 
| 48 | }; | 48 | }; | 
| 49 | 49 | ||
| 50 | enum btrfs_trans_type { | ||
| 51 | TRANS_START, | ||
| 52 | TRANS_JOIN, | ||
| 53 | TRANS_USERSPACE, | ||
| 54 | TRANS_JOIN_NOLOCK, | ||
| 55 | TRANS_JOIN_FREEZE, | ||
| 56 | }; | ||
| 57 | |||
| 50 | struct btrfs_trans_handle { | 58 | struct btrfs_trans_handle { | 
| 51 | u64 transid; | 59 | u64 transid; | 
| 52 | u64 bytes_reserved; | 60 | u64 bytes_reserved; | 
| @@ -58,8 +66,9 @@ struct btrfs_trans_handle { | |||
| 58 | struct btrfs_transaction *transaction; | 66 | struct btrfs_transaction *transaction; | 
| 59 | struct btrfs_block_rsv *block_rsv; | 67 | struct btrfs_block_rsv *block_rsv; | 
| 60 | struct btrfs_block_rsv *orig_rsv; | 68 | struct btrfs_block_rsv *orig_rsv; | 
| 61 | int aborted; | 69 | short aborted; | 
| 62 | int adding_csums; | 70 | short adding_csums; | 
| 71 | enum btrfs_trans_type type; | ||
| 63 | /* | 72 | /* | 
| 64 | * this root is only needed to validate that the root passed to | 73 | * this root is only needed to validate that the root passed to | 
| 65 | * start_transaction is the same as the one passed to end_transaction. | 74 | * start_transaction is the same as the one passed to end_transaction. | 
| @@ -94,8 +103,6 @@ static inline void btrfs_set_inode_last_trans(struct btrfs_trans_handle *trans, | |||
| 94 | 103 | ||
| 95 | int btrfs_end_transaction(struct btrfs_trans_handle *trans, | 104 | int btrfs_end_transaction(struct btrfs_trans_handle *trans, | 
| 96 | struct btrfs_root *root); | 105 | struct btrfs_root *root); | 
| 97 | int btrfs_end_transaction_nolock(struct btrfs_trans_handle *trans, | ||
| 98 | struct btrfs_root *root); | ||
| 99 | struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, | 106 | struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, | 
| 100 | int num_items); | 107 | int num_items); | 
| 101 | struct btrfs_trans_handle *btrfs_start_transaction_noflush( | 108 | struct btrfs_trans_handle *btrfs_start_transaction_noflush( | 
