diff options
Diffstat (limited to 'fs/btrfs/transaction.h')
-rw-r--r-- | fs/btrfs/transaction.h | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index 9ab27b7491c5..7e6c08a0accd 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h | |||
@@ -1,27 +1,30 @@ | |||
1 | #ifndef __TRANSACTION__ | 1 | #ifndef __TRANSACTION__ |
2 | #define __TRANSACTION__ | 2 | #define __TRANSACTION__ |
3 | 3 | ||
4 | struct btrfs_transaction { | ||
5 | u64 transid; | ||
6 | unsigned long num_writers; | ||
7 | int in_commit; | ||
8 | int use_count; | ||
9 | int commit_done; | ||
10 | wait_queue_head_t writer_wait; | ||
11 | wait_queue_head_t commit_wait; | ||
12 | }; | ||
13 | |||
4 | struct btrfs_trans_handle { | 14 | struct btrfs_trans_handle { |
5 | u64 transid; | 15 | u64 transid; |
6 | unsigned long blocks_reserved; | 16 | unsigned long blocks_reserved; |
7 | unsigned long blocks_used; | 17 | unsigned long blocks_used; |
18 | struct btrfs_transaction *transaction; | ||
8 | }; | 19 | }; |
9 | 20 | ||
10 | static inline struct btrfs_trans_handle * | ||
11 | btrfs_start_transaction(struct btrfs_root *root, int num_blocks) | ||
12 | { | ||
13 | struct btrfs_trans_handle *h = kmalloc(sizeof(*h), GFP_NOFS); | ||
14 | h->transid = root->root_key.offset; | ||
15 | h->blocks_reserved = num_blocks; | ||
16 | h->blocks_used = 0; | ||
17 | return h; | ||
18 | } | ||
19 | |||
20 | static inline void btrfs_free_transaction(struct btrfs_root *root, | ||
21 | struct btrfs_trans_handle *handle) | ||
22 | { | ||
23 | memset(handle, 0, sizeof(*handle)); | ||
24 | kfree(handle); | ||
25 | } | ||
26 | 21 | ||
22 | int btrfs_end_transaction(struct btrfs_trans_handle *trans, | ||
23 | struct btrfs_root *root); | ||
24 | struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, | ||
25 | int num_blocks); | ||
26 | int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans, | ||
27 | struct btrfs_root *root); | ||
28 | int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans, | ||
29 | struct btrfs_root *root); | ||
27 | #endif | 30 | #endif |