Chris Mason | e089f05 | 2007-03-16 16:20:31 -0400 | [diff] [blame] | 1 | #ifndef __TRANSACTION__ |
| 2 | #define __TRANSACTION__ |
Chris Mason | 31f3c99 | 2007-04-30 15:25:45 -0400 | [diff] [blame] | 3 | #include "btrfs_inode.h" |
Chris Mason | e089f05 | 2007-03-16 16:20:31 -0400 | [diff] [blame] | 4 | |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 5 | struct btrfs_transaction { |
| 6 | u64 transid; |
| 7 | unsigned long num_writers; |
| 8 | int in_commit; |
| 9 | int use_count; |
| 10 | int commit_done; |
Chris Mason | 2c90e5d | 2007-04-02 10:50:19 -0400 | [diff] [blame] | 11 | int magic; |
Chris Mason | 8fd1779 | 2007-04-19 21:01:03 -0400 | [diff] [blame] | 12 | struct list_head list; |
Chris Mason | 7c4452b | 2007-04-28 09:29:35 -0400 | [diff] [blame] | 13 | struct radix_tree_root dirty_pages; |
Chris Mason | 08607c1 | 2007-06-08 15:33:54 -0400 | [diff] [blame^] | 14 | unsigned long start_time; |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 15 | wait_queue_head_t writer_wait; |
| 16 | wait_queue_head_t commit_wait; |
| 17 | }; |
| 18 | |
Chris Mason | e089f05 | 2007-03-16 16:20:31 -0400 | [diff] [blame] | 19 | struct btrfs_trans_handle { |
Chris Mason | 2c90e5d | 2007-04-02 10:50:19 -0400 | [diff] [blame] | 20 | int magic; |
Chris Mason | e089f05 | 2007-03-16 16:20:31 -0400 | [diff] [blame] | 21 | u64 transid; |
| 22 | unsigned long blocks_reserved; |
| 23 | unsigned long blocks_used; |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 24 | struct btrfs_transaction *transaction; |
Chris Mason | 31f3c99 | 2007-04-30 15:25:45 -0400 | [diff] [blame] | 25 | struct btrfs_block_group_cache *block_group; |
Chris Mason | 2c90e5d | 2007-04-02 10:50:19 -0400 | [diff] [blame] | 26 | int magic2; |
Chris Mason | e089f05 | 2007-03-16 16:20:31 -0400 | [diff] [blame] | 27 | }; |
| 28 | |
Chris Mason | e089f05 | 2007-03-16 16:20:31 -0400 | [diff] [blame] | 29 | |
Chris Mason | 31f3c99 | 2007-04-30 15:25:45 -0400 | [diff] [blame] | 30 | static inline void btrfs_set_trans_block_group(struct btrfs_trans_handle *trans, |
| 31 | struct inode *inode) |
| 32 | { |
| 33 | trans->block_group = BTRFS_I(inode)->block_group; |
| 34 | } |
| 35 | |
| 36 | static inline void btrfs_update_inode_block_group(struct |
| 37 | btrfs_trans_handle *trans, |
| 38 | struct inode *inode) |
| 39 | { |
| 40 | BTRFS_I(inode)->block_group = trans->block_group; |
| 41 | } |
| 42 | |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 43 | int btrfs_end_transaction(struct btrfs_trans_handle *trans, |
| 44 | struct btrfs_root *root); |
| 45 | struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, |
| 46 | int num_blocks); |
| 47 | int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans, |
| 48 | struct btrfs_root *root); |
| 49 | int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans, |
| 50 | struct btrfs_root *root); |
Chris Mason | 08607c1 | 2007-06-08 15:33:54 -0400 | [diff] [blame^] | 51 | |
| 52 | void btrfs_transaction_cleaner(struct work_struct *work); |
| 53 | void btrfs_transaction_flush_work(struct btrfs_root *root); |
| 54 | void btrfs_transaction_queue_work(struct btrfs_root *root, int delay); |
| 55 | void btrfs_init_transaction_sys(void); |
| 56 | void btrfs_exit_transaction_sys(void); |
| 57 | |
Chris Mason | e089f05 | 2007-03-16 16:20:31 -0400 | [diff] [blame] | 58 | #endif |