Blame view
fs/btrfs/transaction.h
7.45 KB
6cbd55707 Btrfs: add GPLv2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
/* * Copyright (C) 2007 Oracle. All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License v2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 021110-1307, USA. */ |
dc17ff8f1 Btrfs: Add data=o... |
18 19 |
#ifndef __BTRFS_TRANSACTION__ #define __BTRFS_TRANSACTION__ |
31f3c99b7 Btrfs: allocator ... |
20 |
#include "btrfs_inode.h" |
56bec294d Btrfs: do extent ... |
21 |
#include "delayed-ref.h" |
bed92eae2 Btrfs: qgroup imp... |
22 |
#include "ctree.h" |
e089f05c1 Btrfs: transactio... |
23 |
|
4a9d8bdee Btrfs: make the s... |
24 25 26 27 28 29 30 31 32 |
enum btrfs_trans_state { TRANS_STATE_RUNNING = 0, TRANS_STATE_BLOCKED = 1, TRANS_STATE_COMMIT_START = 2, TRANS_STATE_COMMIT_DOING = 3, TRANS_STATE_UNBLOCKED = 4, TRANS_STATE_COMPLETED = 5, TRANS_STATE_MAX = 6, }; |
3204d33cd Btrfs: add a flag... |
33 34 |
#define BTRFS_TRANS_HAVE_FREE_BGS 0 #define BTRFS_TRANS_DIRTY_BG_RUN 1 |
2968b1f48 Btrfs: don't cont... |
35 |
#define BTRFS_TRANS_CACHE_ENOSPC 2 |
3204d33cd Btrfs: add a flag... |
36 |
|
79154b1b5 Btrfs: transactio... |
37 38 |
struct btrfs_transaction { u64 transid; |
b7ec40d78 Btrfs: reduce sta... |
39 |
/* |
0860adfdb Btrfs: don't wait... |
40 41 42 43 44 45 |
* total external writers(USERSPACE/START/ATTACH) in this * transaction, it must be zero before the transaction is * being committed */ atomic_t num_extwriters; /* |
b7ec40d78 Btrfs: reduce sta... |
46 47 48 |
* total writers in this transaction, it must be zero before the * transaction can end */ |
13c5a93e7 Btrfs: avoid taki... |
49 |
atomic_t num_writers; |
a4abeea41 Btrfs: kill trans... |
50 |
atomic_t use_count; |
161c3549b Btrfs: change how... |
51 |
atomic_t pending_ordered; |
b7ec40d78 Btrfs: reduce sta... |
52 |
|
3204d33cd Btrfs: add a flag... |
53 |
unsigned long flags; |
13212b54d btrfs: Fix out-of... |
54 |
|
4a9d8bdee Btrfs: make the s... |
55 56 |
/* Be protected by fs_info->trans_lock when we want to change it. */ enum btrfs_trans_state state; |
8fd17795b Btrfs: early fsyn... |
57 |
struct list_head list; |
d1310b2e0 Btrfs: Split the ... |
58 |
struct extent_io_tree dirty_pages; |
08607c1b1 Btrfs: add compat... |
59 |
unsigned long start_time; |
79154b1b5 Btrfs: transactio... |
60 61 |
wait_queue_head_t writer_wait; wait_queue_head_t commit_wait; |
161c3549b Btrfs: change how... |
62 |
wait_queue_head_t pending_wait; |
3063d29f2 Btrfs: Move snaps... |
63 |
struct list_head pending_snapshots; |
6df9a95e6 Btrfs: make the c... |
64 |
struct list_head pending_chunks; |
9e351cc86 Btrfs: remove tra... |
65 |
struct list_head switch_commits; |
ce93ec548 Btrfs: track dirt... |
66 |
struct list_head dirty_bgs; |
1bbc621ef Btrfs: allow bloc... |
67 |
struct list_head io_bgs; |
2b9dbef27 Btrfs: keep dropp... |
68 |
struct list_head dropped_roots; |
cb723e491 Btrfs: reserve sp... |
69 |
u64 num_dirty_bgs; |
1bbc621ef Btrfs: allow bloc... |
70 71 72 73 74 75 76 |
/* * we need to make sure block group deletion doesn't race with * free space cache writeout. This mutex keeps them from stomping * on each other */ struct mutex cache_write_mutex; |
ce93ec548 Btrfs: track dirt... |
77 |
spinlock_t dirty_bgs_lock; |
348a0013d Btrfs: fix unprot... |
78 |
/* Protected by spin lock fs_info->unused_bgs_lock. */ |
e33e17ee1 btrfs: add missin... |
79 |
struct list_head deleted_bgs; |
2b9dbef27 Btrfs: keep dropp... |
80 |
spinlock_t dropped_roots_lock; |
56bec294d Btrfs: do extent ... |
81 |
struct btrfs_delayed_ref_root delayed_refs; |
49b25e054 btrfs: enhance tr... |
82 |
int aborted; |
79154b1b5 Btrfs: transactio... |
83 |
}; |
0860adfdb Btrfs: don't wait... |
84 85 86 87 88 89 90 |
#define __TRANS_FREEZABLE (1U << 0) #define __TRANS_USERSPACE (1U << 8) #define __TRANS_START (1U << 9) #define __TRANS_ATTACH (1U << 10) #define __TRANS_JOIN (1U << 11) #define __TRANS_JOIN_NOLOCK (1U << 12) |
faa2dbf00 Btrfs: add sanity... |
91 |
#define __TRANS_DUMMY (1U << 13) |
0860adfdb Btrfs: don't wait... |
92 93 94 95 96 97 98 99 100 |
#define TRANS_USERSPACE (__TRANS_USERSPACE | __TRANS_FREEZABLE) #define TRANS_START (__TRANS_START | __TRANS_FREEZABLE) #define TRANS_ATTACH (__TRANS_ATTACH) #define TRANS_JOIN (__TRANS_JOIN | __TRANS_FREEZABLE) #define TRANS_JOIN_NOLOCK (__TRANS_JOIN_NOLOCK) #define TRANS_EXTWRITERS (__TRANS_USERSPACE | __TRANS_START | \ __TRANS_ATTACH) |
a698d0755 Btrfs: add a type... |
101 |
|
2755a0de6 btrfs: hide typec... |
102 |
#define BTRFS_SEND_TRANS_STUB ((void *)1) |
a26e8c9f7 Btrfs: don't clea... |
103 |
|
e089f05c1 Btrfs: transactio... |
104 105 |
struct btrfs_trans_handle { u64 transid; |
f0486c68e Btrfs: Introduce ... |
106 |
u64 bytes_reserved; |
4fbcdf669 Btrfs: fix -ENOSP... |
107 |
u64 chunk_bytes_reserved; |
2a1eb4614 Btrfs: if we've a... |
108 |
unsigned long use_count; |
e089f05c1 Btrfs: transactio... |
109 110 |
unsigned long blocks_reserved; unsigned long blocks_used; |
56bec294d Btrfs: do extent ... |
111 |
unsigned long delayed_ref_updates; |
f0486c68e Btrfs: Introduce ... |
112 113 |
struct btrfs_transaction *transaction; struct btrfs_block_rsv *block_rsv; |
2a1eb4614 Btrfs: if we've a... |
114 |
struct btrfs_block_rsv *orig_rsv; |
a698d0755 Btrfs: add a type... |
115 116 |
short aborted; short adding_csums; |
c6b305a89 Btrfs: don't re-e... |
117 |
bool allocating_chunk; |
d9a0540a7 Btrfs: fix deadlo... |
118 |
bool can_flush_pending_bgs; |
20dd2cbf0 Btrfs: fix BUG_ON... |
119 |
bool reloc_reserved; |
5039eddc1 Btrfs: make fsync... |
120 |
bool sync; |
0860adfdb Btrfs: don't wait... |
121 |
unsigned int type; |
d13603ef6 Btrfs: check the ... |
122 123 124 125 126 127 |
/* * this root is only needed to validate that the root passed to * start_transaction is the same as the one passed to end_transaction. * Subvolume quota depends on this */ struct btrfs_root *root; |
bed92eae2 Btrfs: qgroup imp... |
128 129 |
struct seq_list delayed_ref_elem; struct list_head qgroup_ref_list; |
ea658badc Btrfs: delay bloc... |
130 |
struct list_head new_bgs; |
e089f05c1 Btrfs: transactio... |
131 |
}; |
3063d29f2 Btrfs: Move snaps... |
132 |
struct btrfs_pending_snapshot { |
3de4586c5 Btrfs: Allow subv... |
133 |
struct dentry *dentry; |
e9662f701 Btrfs: remove unn... |
134 |
struct inode *dir; |
3063d29f2 Btrfs: Move snaps... |
135 |
struct btrfs_root *root; |
b0c0ea633 btrfs: allocate r... |
136 |
struct btrfs_root_item *root_item; |
a22285a6a Btrfs: Integrate ... |
137 |
struct btrfs_root *snap; |
6f72c7e20 Btrfs: add qgroup... |
138 |
struct btrfs_qgroup_inherit *inherit; |
8546b5705 btrfs: preallocat... |
139 |
struct btrfs_path *path; |
a22285a6a Btrfs: Integrate ... |
140 141 |
/* block reservation for the operation */ struct btrfs_block_rsv block_rsv; |
d5c120701 Btrfs: fix wrong ... |
142 |
u64 qgroup_reserved; |
a22285a6a Btrfs: Integrate ... |
143 144 |
/* extra metadata reseration for relocation */ int error; |
b83cc9693 Btrfs: Add readon... |
145 |
bool readonly; |
3063d29f2 Btrfs: Move snaps... |
146 147 |
struct list_head list; }; |
15ee9bc7e Btrfs: delay comm... |
148 149 150 |
static inline void btrfs_set_inode_last_trans(struct btrfs_trans_handle *trans, struct inode *inode) { |
2f2ff0ee5 Btrfs: fix metada... |
151 |
spin_lock(&BTRFS_I(inode)->lock); |
15ee9bc7e Btrfs: delay comm... |
152 |
BTRFS_I(inode)->last_trans = trans->transaction->transid; |
257c62e1b Btrfs: avoid tree... |
153 |
BTRFS_I(inode)->last_sub_trans = BTRFS_I(inode)->root->log_transid; |
46d8bc342 Btrfs: fix a bug ... |
154 |
BTRFS_I(inode)->last_log_commit = BTRFS_I(inode)->root->last_log_commit; |
2f2ff0ee5 Btrfs: fix metada... |
155 |
spin_unlock(&BTRFS_I(inode)->lock); |
15ee9bc7e Btrfs: delay comm... |
156 |
} |
9086db86e btrfs: qgroup: Ad... |
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
/* * Make qgroup codes to skip given qgroupid, means the old/new_roots for * qgroup won't contain the qgroupid in it. */ static inline void btrfs_set_skip_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid) { struct btrfs_delayed_ref_root *delayed_refs; delayed_refs = &trans->transaction->delayed_refs; WARN_ON(delayed_refs->qgroup_to_skip); delayed_refs->qgroup_to_skip = qgroupid; } static inline void btrfs_clear_skip_qgroup(struct btrfs_trans_handle *trans) { struct btrfs_delayed_ref_root *delayed_refs; delayed_refs = &trans->transaction->delayed_refs; WARN_ON(!delayed_refs->qgroup_to_skip); delayed_refs->qgroup_to_skip = 0; } |
79154b1b5 Btrfs: transactio... |
179 180 181 |
int btrfs_end_transaction(struct btrfs_trans_handle *trans, struct btrfs_root *root); struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, |
5aed1dd8b btrfs: change num... |
182 |
unsigned int num_items); |
8eab77ff1 Btrfs: use global... |
183 184 185 186 |
struct btrfs_trans_handle *btrfs_start_transaction_fallback_global_rsv( struct btrfs_root *root, unsigned int num_items, int min_factor); |
08e007d2e Btrfs: improve th... |
187 |
struct btrfs_trans_handle *btrfs_start_transaction_lflush( |
5aed1dd8b btrfs: change num... |
188 189 |
struct btrfs_root *root, unsigned int num_items); |
7a7eaa40a Btrfs: take away ... |
190 191 |
struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root); struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root); |
354aa0fb6 Btrfs: fix orphan... |
192 |
struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root); |
d4edf39bd Btrfs: fix uncomp... |
193 194 |
struct btrfs_trans_handle *btrfs_attach_transaction_barrier( struct btrfs_root *root); |
7a7eaa40a Btrfs: take away ... |
195 |
struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root); |
462045928 Btrfs: add START_... |
196 |
int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid); |
08607c1b1 Btrfs: add compat... |
197 |
|
cfad392b2 Btrfs: check to s... |
198 |
void btrfs_add_dead_root(struct btrfs_root *root); |
de78b51a2 btrfs: remove cac... |
199 |
int btrfs_defrag_root(struct btrfs_root *root); |
9d1a2a3ad btrfs: clean snap... |
200 |
int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root); |
5f39d397d Btrfs: Create ext... |
201 202 |
int btrfs_commit_transaction(struct btrfs_trans_handle *trans, struct btrfs_root *root); |
bb9c12c94 Btrfs: async tran... |
203 204 205 |
int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans, struct btrfs_root *root, int wait_for_unblock); |
89ce8a63d Add btrfs_end_tra... |
206 207 |
int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans, struct btrfs_root *root); |
8929ecfa5 Btrfs: Introduce ... |
208 209 |
int btrfs_should_end_transaction(struct btrfs_trans_handle *trans, struct btrfs_root *root); |
ab78c84de Btrfs: Throttle o... |
210 |
void btrfs_throttle(struct btrfs_root *root); |
5d4f98a28 Btrfs: Mixed back... |
211 212 |
int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans, struct btrfs_root *root); |
690587d10 Btrfs: streamline... |
213 |
int btrfs_write_marked_extents(struct btrfs_root *root, |
8cef4e160 Btrfs: Avoid supe... |
214 |
struct extent_io_tree *dirty_pages, int mark); |
690587d10 Btrfs: streamline... |
215 |
int btrfs_wait_marked_extents(struct btrfs_root *root, |
8cef4e160 Btrfs: Avoid supe... |
216 |
struct extent_io_tree *dirty_pages, int mark); |
8929ecfa5 Btrfs: Introduce ... |
217 |
int btrfs_transaction_blocked(struct btrfs_fs_info *info); |
f36f3042e Btrfs: be more po... |
218 |
int btrfs_transaction_in_commit(struct btrfs_fs_info *info); |
724e2315d Btrfs: fix two us... |
219 |
void btrfs_put_transaction(struct btrfs_transaction *transaction); |
572d9ab78 btrfs: add suppor... |
220 |
void btrfs_apply_pending_changes(struct btrfs_fs_info *fs_info); |
2b9dbef27 Btrfs: keep dropp... |
221 222 |
void btrfs_add_dropped_root(struct btrfs_trans_handle *trans, struct btrfs_root *root); |
e089f05c1 Btrfs: transactio... |
223 |
#endif |