transaction.c (def840ede34ea1fa47494c62fba06479af2abbc1) | transaction.c (575a75d6fabf6e1217204deca79aea26d6670a12) |
---|---|
1/* 2 * Copyright (C) 2007 Oracle. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public 6 * License v2 as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, --- 260 unchanged lines hidden (view full) --- 269 INIT_LIST_HEAD(&cur_trans->switch_commits); 270 INIT_LIST_HEAD(&cur_trans->dirty_bgs); 271 INIT_LIST_HEAD(&cur_trans->io_bgs); 272 INIT_LIST_HEAD(&cur_trans->dropped_roots); 273 mutex_init(&cur_trans->cache_write_mutex); 274 cur_trans->num_dirty_bgs = 0; 275 spin_lock_init(&cur_trans->dirty_bgs_lock); 276 INIT_LIST_HEAD(&cur_trans->deleted_bgs); | 1/* 2 * Copyright (C) 2007 Oracle. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public 6 * License v2 as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, --- 260 unchanged lines hidden (view full) --- 269 INIT_LIST_HEAD(&cur_trans->switch_commits); 270 INIT_LIST_HEAD(&cur_trans->dirty_bgs); 271 INIT_LIST_HEAD(&cur_trans->io_bgs); 272 INIT_LIST_HEAD(&cur_trans->dropped_roots); 273 mutex_init(&cur_trans->cache_write_mutex); 274 cur_trans->num_dirty_bgs = 0; 275 spin_lock_init(&cur_trans->dirty_bgs_lock); 276 INIT_LIST_HEAD(&cur_trans->deleted_bgs); |
277 spin_lock_init(&cur_trans->deleted_bgs_lock); | |
278 spin_lock_init(&cur_trans->dropped_roots_lock); 279 list_add_tail(&cur_trans->list, &fs_info->trans_list); 280 extent_io_tree_init(&cur_trans->dirty_pages, 281 fs_info->btree_inode->i_mapping); 282 fs_info->generation++; 283 cur_trans->transid = fs_info->generation; 284 fs_info->running_transaction = cur_trans; 285 cur_trans->aborted = 0; --- 344 unchanged lines hidden (view full) --- 630 unsigned int num_items) 631{ 632 return start_transaction(root, num_items, TRANS_START, 633 BTRFS_RESERVE_FLUSH_LIMIT); 634} 635 636struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root) 637{ | 277 spin_lock_init(&cur_trans->dropped_roots_lock); 278 list_add_tail(&cur_trans->list, &fs_info->trans_list); 279 extent_io_tree_init(&cur_trans->dirty_pages, 280 fs_info->btree_inode->i_mapping); 281 fs_info->generation++; 282 cur_trans->transid = fs_info->generation; 283 fs_info->running_transaction = cur_trans; 284 cur_trans->aborted = 0; --- 344 unchanged lines hidden (view full) --- 629 unsigned int num_items) 630{ 631 return start_transaction(root, num_items, TRANS_START, 632 BTRFS_RESERVE_FLUSH_LIMIT); 633} 634 635struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root) 636{ |
638 return start_transaction(root, 0, TRANS_JOIN, 0); | 637 return start_transaction(root, 0, TRANS_JOIN, 638 BTRFS_RESERVE_NO_FLUSH); |
639} 640 641struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root) 642{ | 639} 640 641struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root) 642{ |
643 return start_transaction(root, 0, TRANS_JOIN_NOLOCK, 0); | 643 return start_transaction(root, 0, TRANS_JOIN_NOLOCK, 644 BTRFS_RESERVE_NO_FLUSH); |
644} 645 646struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root) 647{ | 645} 646 647struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root) 648{ |
648 return start_transaction(root, 0, TRANS_USERSPACE, 0); | 649 return start_transaction(root, 0, TRANS_USERSPACE, 650 BTRFS_RESERVE_NO_FLUSH); |
649} 650 651/* 652 * btrfs_attach_transaction() - catch the running transaction 653 * 654 * It is used when we want to commit the current the transaction, but 655 * don't want to start a new one. 656 * 657 * Note: If this function return -ENOENT, it just means there is no 658 * running transaction. But it is possible that the inactive transaction 659 * is still in the memory, not fully on disk. If you hope there is no 660 * inactive transaction in the fs when -ENOENT is returned, you should 661 * invoke 662 * btrfs_attach_transaction_barrier() 663 */ 664struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root) 665{ | 651} 652 653/* 654 * btrfs_attach_transaction() - catch the running transaction 655 * 656 * It is used when we want to commit the current the transaction, but 657 * don't want to start a new one. 658 * 659 * Note: If this function return -ENOENT, it just means there is no 660 * running transaction. But it is possible that the inactive transaction 661 * is still in the memory, not fully on disk. If you hope there is no 662 * inactive transaction in the fs when -ENOENT is returned, you should 663 * invoke 664 * btrfs_attach_transaction_barrier() 665 */ 666struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root) 667{ |
666 return start_transaction(root, 0, TRANS_ATTACH, 0); | 668 return start_transaction(root, 0, TRANS_ATTACH, 669 BTRFS_RESERVE_NO_FLUSH); |
667} 668 669/* 670 * btrfs_attach_transaction_barrier() - catch the running transaction 671 * 672 * It is similar to the above function, the differentia is this one 673 * will wait for all the inactive transactions until they fully 674 * complete. 675 */ 676struct btrfs_trans_handle * 677btrfs_attach_transaction_barrier(struct btrfs_root *root) 678{ 679 struct btrfs_trans_handle *trans; 680 | 670} 671 672/* 673 * btrfs_attach_transaction_barrier() - catch the running transaction 674 * 675 * It is similar to the above function, the differentia is this one 676 * will wait for all the inactive transactions until they fully 677 * complete. 678 */ 679struct btrfs_trans_handle * 680btrfs_attach_transaction_barrier(struct btrfs_root *root) 681{ 682 struct btrfs_trans_handle *trans; 683 |
681 trans = start_transaction(root, 0, TRANS_ATTACH, 0); | 684 trans = start_transaction(root, 0, TRANS_ATTACH, 685 BTRFS_RESERVE_NO_FLUSH); |
682 if (IS_ERR(trans) && PTR_ERR(trans) == -ENOENT) 683 btrfs_wait_for_commit(root, 0); 684 685 return trans; 686} 687 688/* wait for a transaction commit to be fully complete */ 689static noinline void wait_for_commit(struct btrfs_root *root, --- 1570 unchanged lines hidden --- | 686 if (IS_ERR(trans) && PTR_ERR(trans) == -ENOENT) 687 btrfs_wait_for_commit(root, 0); 688 689 return trans; 690} 691 692/* wait for a transaction commit to be fully complete */ 693static noinline void wait_for_commit(struct btrfs_root *root, --- 1570 unchanged lines hidden --- |