diff options
Diffstat (limited to 'fs/btrfs/transaction.h')
-rw-r--r-- | fs/btrfs/transaction.h | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index 24c97335a59f..defbc4269897 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h | |||
@@ -22,21 +22,33 @@ | |||
22 | #include "delayed-ref.h" | 22 | #include "delayed-ref.h" |
23 | #include "ctree.h" | 23 | #include "ctree.h" |
24 | 24 | ||
25 | enum btrfs_trans_state { | ||
26 | TRANS_STATE_RUNNING = 0, | ||
27 | TRANS_STATE_BLOCKED = 1, | ||
28 | TRANS_STATE_COMMIT_START = 2, | ||
29 | TRANS_STATE_COMMIT_DOING = 3, | ||
30 | TRANS_STATE_UNBLOCKED = 4, | ||
31 | TRANS_STATE_COMPLETED = 5, | ||
32 | TRANS_STATE_MAX = 6, | ||
33 | }; | ||
34 | |||
25 | struct btrfs_transaction { | 35 | struct btrfs_transaction { |
26 | u64 transid; | 36 | u64 transid; |
27 | /* | 37 | /* |
38 | * total external writers(USERSPACE/START/ATTACH) in this | ||
39 | * transaction, it must be zero before the transaction is | ||
40 | * being committed | ||
41 | */ | ||
42 | atomic_t num_extwriters; | ||
43 | /* | ||
28 | * total writers in this transaction, it must be zero before the | 44 | * total writers in this transaction, it must be zero before the |
29 | * transaction can end | 45 | * transaction can end |
30 | */ | 46 | */ |
31 | atomic_t num_writers; | 47 | atomic_t num_writers; |
32 | atomic_t use_count; | 48 | atomic_t use_count; |
33 | 49 | ||
34 | unsigned long num_joined; | 50 | /* Be protected by fs_info->trans_lock when we want to change it. */ |
35 | 51 | enum btrfs_trans_state state; | |
36 | spinlock_t commit_lock; | ||
37 | int in_commit; | ||
38 | int commit_done; | ||
39 | int blocked; | ||
40 | struct list_head list; | 52 | struct list_head list; |
41 | struct extent_io_tree dirty_pages; | 53 | struct extent_io_tree dirty_pages; |
42 | unsigned long start_time; | 54 | unsigned long start_time; |
@@ -44,17 +56,27 @@ struct btrfs_transaction { | |||
44 | wait_queue_head_t commit_wait; | 56 | wait_queue_head_t commit_wait; |
45 | struct list_head pending_snapshots; | 57 | struct list_head pending_snapshots; |
46 | struct list_head ordered_operations; | 58 | struct list_head ordered_operations; |
59 | struct list_head pending_chunks; | ||
47 | struct btrfs_delayed_ref_root delayed_refs; | 60 | struct btrfs_delayed_ref_root delayed_refs; |
48 | int aborted; | 61 | int aborted; |
49 | }; | 62 | }; |
50 | 63 | ||
51 | enum btrfs_trans_type { | 64 | #define __TRANS_FREEZABLE (1U << 0) |
52 | TRANS_START, | 65 | |
53 | TRANS_JOIN, | 66 | #define __TRANS_USERSPACE (1U << 8) |
54 | TRANS_USERSPACE, | 67 | #define __TRANS_START (1U << 9) |
55 | TRANS_JOIN_NOLOCK, | 68 | #define __TRANS_ATTACH (1U << 10) |
56 | TRANS_ATTACH, | 69 | #define __TRANS_JOIN (1U << 11) |
57 | }; | 70 | #define __TRANS_JOIN_NOLOCK (1U << 12) |
71 | |||
72 | #define TRANS_USERSPACE (__TRANS_USERSPACE | __TRANS_FREEZABLE) | ||
73 | #define TRANS_START (__TRANS_START | __TRANS_FREEZABLE) | ||
74 | #define TRANS_ATTACH (__TRANS_ATTACH) | ||
75 | #define TRANS_JOIN (__TRANS_JOIN | __TRANS_FREEZABLE) | ||
76 | #define TRANS_JOIN_NOLOCK (__TRANS_JOIN_NOLOCK) | ||
77 | |||
78 | #define TRANS_EXTWRITERS (__TRANS_USERSPACE | __TRANS_START | \ | ||
79 | __TRANS_ATTACH) | ||
58 | 80 | ||
59 | struct btrfs_trans_handle { | 81 | struct btrfs_trans_handle { |
60 | u64 transid; | 82 | u64 transid; |
@@ -70,7 +92,7 @@ struct btrfs_trans_handle { | |||
70 | short aborted; | 92 | short aborted; |
71 | short adding_csums; | 93 | short adding_csums; |
72 | bool allocating_chunk; | 94 | bool allocating_chunk; |
73 | enum btrfs_trans_type type; | 95 | unsigned int type; |
74 | /* | 96 | /* |
75 | * this root is only needed to validate that the root passed to | 97 | * this root is only needed to validate that the root passed to |
76 | * start_transaction is the same as the one passed to end_transaction. | 98 | * start_transaction is the same as the one passed to end_transaction. |
@@ -121,7 +143,7 @@ int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid); | |||
121 | int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans, | 143 | int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans, |
122 | struct btrfs_root *root); | 144 | struct btrfs_root *root); |
123 | 145 | ||
124 | int btrfs_add_dead_root(struct btrfs_root *root); | 146 | void btrfs_add_dead_root(struct btrfs_root *root); |
125 | int btrfs_defrag_root(struct btrfs_root *root); | 147 | int btrfs_defrag_root(struct btrfs_root *root); |
126 | int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root); | 148 | int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root); |
127 | int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | 149 | int btrfs_commit_transaction(struct btrfs_trans_handle *trans, |