blob: b5378119e76cf7251b77f4292f41f547df8bb94b [file] [log] [blame]
Chris Masone089f052007-03-16 16:20:31 -04001#ifndef __TRANSACTION__
2#define __TRANSACTION__
Chris Mason31f3c992007-04-30 15:25:45 -04003#include "btrfs_inode.h"
Chris Masone089f052007-03-16 16:20:31 -04004
Chris Mason79154b12007-03-22 15:59:16 -04005struct btrfs_transaction {
6 u64 transid;
7 unsigned long num_writers;
8 int in_commit;
9 int use_count;
10 int commit_done;
Chris Mason2c90e5d2007-04-02 10:50:19 -040011 int magic;
Chris Mason8fd17792007-04-19 21:01:03 -040012 struct list_head list;
Chris Mason7c4452b2007-04-28 09:29:35 -040013 struct radix_tree_root dirty_pages;
Chris Mason79154b12007-03-22 15:59:16 -040014 wait_queue_head_t writer_wait;
15 wait_queue_head_t commit_wait;
16};
17
Chris Masone089f052007-03-16 16:20:31 -040018struct btrfs_trans_handle {
Chris Mason2c90e5d2007-04-02 10:50:19 -040019 int magic;
Chris Masone089f052007-03-16 16:20:31 -040020 u64 transid;
21 unsigned long blocks_reserved;
22 unsigned long blocks_used;
Chris Mason79154b12007-03-22 15:59:16 -040023 struct btrfs_transaction *transaction;
Chris Mason31f3c992007-04-30 15:25:45 -040024 struct btrfs_block_group_cache *block_group;
Chris Mason2c90e5d2007-04-02 10:50:19 -040025 int magic2;
Chris Masone089f052007-03-16 16:20:31 -040026};
27
Chris Masone089f052007-03-16 16:20:31 -040028
Chris Mason31f3c992007-04-30 15:25:45 -040029static inline void btrfs_set_trans_block_group(struct btrfs_trans_handle *trans,
30 struct inode *inode)
31{
32 trans->block_group = BTRFS_I(inode)->block_group;
33}
34
35static inline void btrfs_update_inode_block_group(struct
36 btrfs_trans_handle *trans,
37 struct inode *inode)
38{
39 BTRFS_I(inode)->block_group = trans->block_group;
40}
41
Chris Mason79154b12007-03-22 15:59:16 -040042int btrfs_end_transaction(struct btrfs_trans_handle *trans,
43 struct btrfs_root *root);
44struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root,
45 int num_blocks);
46int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
47 struct btrfs_root *root);
48int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans,
49 struct btrfs_root *root);
Chris Masone089f052007-03-16 16:20:31 -040050#endif