Chris Mason | 6cbd557 | 2007-06-12 09:07:21 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 Oracle. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public |
| 6 | * License v2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | * General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public |
| 14 | * License along with this program; if not, write to the |
| 15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 16 | * Boston, MA 021110-1307, USA. |
| 17 | */ |
| 18 | |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 19 | #include <linux/fs.h> |
Chris Mason | 3408878 | 2007-06-12 11:36:58 -0400 | [diff] [blame] | 20 | #include <linux/sched.h> |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 21 | #include "ctree.h" |
| 22 | #include "disk-io.h" |
| 23 | #include "transaction.h" |
| 24 | |
Chris Mason | 78fae27 | 2007-03-25 11:35:08 -0400 | [diff] [blame] | 25 | static int total_trans = 0; |
Chris Mason | 2c90e5d | 2007-04-02 10:50:19 -0400 | [diff] [blame] | 26 | extern struct kmem_cache *btrfs_trans_handle_cachep; |
| 27 | extern struct kmem_cache *btrfs_transaction_cachep; |
| 28 | |
Chris Mason | 08607c1 | 2007-06-08 15:33:54 -0400 | [diff] [blame] | 29 | static struct workqueue_struct *trans_wq; |
| 30 | |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 31 | #define BTRFS_ROOT_TRANS_TAG 0 |
Chris Mason | 6702ed4 | 2007-08-07 16:15:09 -0400 | [diff] [blame] | 32 | #define BTRFS_ROOT_DEFRAG_TAG 1 |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 33 | |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 34 | static void put_transaction(struct btrfs_transaction *transaction) |
| 35 | { |
Chris Mason | 2c90e5d | 2007-04-02 10:50:19 -0400 | [diff] [blame] | 36 | WARN_ON(transaction->use_count == 0); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 37 | transaction->use_count--; |
Chris Mason | 78fae27 | 2007-03-25 11:35:08 -0400 | [diff] [blame] | 38 | if (transaction->use_count == 0) { |
| 39 | WARN_ON(total_trans == 0); |
| 40 | total_trans--; |
Chris Mason | 8fd1779 | 2007-04-19 21:01:03 -0400 | [diff] [blame] | 41 | list_del_init(&transaction->list); |
Chris Mason | 2c90e5d | 2007-04-02 10:50:19 -0400 | [diff] [blame] | 42 | memset(transaction, 0, sizeof(*transaction)); |
| 43 | kmem_cache_free(btrfs_transaction_cachep, transaction); |
Chris Mason | 78fae27 | 2007-03-25 11:35:08 -0400 | [diff] [blame] | 44 | } |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | static int join_transaction(struct btrfs_root *root) |
| 48 | { |
| 49 | struct btrfs_transaction *cur_trans; |
| 50 | cur_trans = root->fs_info->running_transaction; |
| 51 | if (!cur_trans) { |
Chris Mason | 2c90e5d | 2007-04-02 10:50:19 -0400 | [diff] [blame] | 52 | cur_trans = kmem_cache_alloc(btrfs_transaction_cachep, |
| 53 | GFP_NOFS); |
Chris Mason | 78fae27 | 2007-03-25 11:35:08 -0400 | [diff] [blame] | 54 | total_trans++; |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 55 | BUG_ON(!cur_trans); |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 56 | root->fs_info->generation++; |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 57 | root->fs_info->running_transaction = cur_trans; |
Josef Bacik | 15ee9bc | 2007-08-10 16:22:09 -0400 | [diff] [blame^] | 58 | cur_trans->num_writers = 1; |
| 59 | cur_trans->num_joined = 0; |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 60 | cur_trans->transid = root->fs_info->generation; |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 61 | init_waitqueue_head(&cur_trans->writer_wait); |
| 62 | init_waitqueue_head(&cur_trans->commit_wait); |
| 63 | cur_trans->in_commit = 0; |
Chris Mason | d571976 | 2007-03-23 10:01:08 -0400 | [diff] [blame] | 64 | cur_trans->use_count = 1; |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 65 | cur_trans->commit_done = 0; |
Chris Mason | 08607c1 | 2007-06-08 15:33:54 -0400 | [diff] [blame] | 66 | cur_trans->start_time = get_seconds(); |
Chris Mason | 8fd1779 | 2007-04-19 21:01:03 -0400 | [diff] [blame] | 67 | list_add_tail(&cur_trans->list, &root->fs_info->trans_list); |
Chris Mason | 7c4452b | 2007-04-28 09:29:35 -0400 | [diff] [blame] | 68 | init_bit_radix(&cur_trans->dirty_pages); |
Josef Bacik | 15ee9bc | 2007-08-10 16:22:09 -0400 | [diff] [blame^] | 69 | } else { |
| 70 | cur_trans->num_writers++; |
| 71 | cur_trans->num_joined++; |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 72 | } |
Josef Bacik | 15ee9bc | 2007-08-10 16:22:09 -0400 | [diff] [blame^] | 73 | |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 74 | return 0; |
| 75 | } |
| 76 | |
Chris Mason | 6702ed4 | 2007-08-07 16:15:09 -0400 | [diff] [blame] | 77 | static int record_root_in_trans(struct btrfs_root *root) |
| 78 | { |
| 79 | u64 running_trans_id = root->fs_info->running_transaction->transid; |
| 80 | if (root->ref_cows && root->last_trans < running_trans_id) { |
| 81 | WARN_ON(root == root->fs_info->extent_root); |
| 82 | if (root->root_item.refs != 0) { |
| 83 | radix_tree_tag_set(&root->fs_info->fs_roots_radix, |
| 84 | (unsigned long)root->root_key.objectid, |
| 85 | BTRFS_ROOT_TRANS_TAG); |
| 86 | radix_tree_tag_set(&root->fs_info->fs_roots_radix, |
| 87 | (unsigned long)root->root_key.objectid, |
| 88 | BTRFS_ROOT_DEFRAG_TAG); |
| 89 | root->commit_root = root->node; |
| 90 | get_bh(root->node); |
| 91 | } else { |
| 92 | WARN_ON(1); |
| 93 | } |
| 94 | root->last_trans = running_trans_id; |
| 95 | } |
| 96 | return 0; |
| 97 | } |
| 98 | |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 99 | struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, |
| 100 | int num_blocks) |
| 101 | { |
Chris Mason | 2c90e5d | 2007-04-02 10:50:19 -0400 | [diff] [blame] | 102 | struct btrfs_trans_handle *h = |
| 103 | kmem_cache_alloc(btrfs_trans_handle_cachep, GFP_NOFS); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 104 | int ret; |
| 105 | |
| 106 | mutex_lock(&root->fs_info->trans_mutex); |
| 107 | ret = join_transaction(root); |
| 108 | BUG_ON(ret); |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 109 | |
Chris Mason | 6702ed4 | 2007-08-07 16:15:09 -0400 | [diff] [blame] | 110 | record_root_in_trans(root); |
| 111 | h->transid = root->fs_info->running_transaction->transid; |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 112 | h->transaction = root->fs_info->running_transaction; |
| 113 | h->blocks_reserved = num_blocks; |
| 114 | h->blocks_used = 0; |
Chris Mason | 31f3c99 | 2007-04-30 15:25:45 -0400 | [diff] [blame] | 115 | h->block_group = NULL; |
Chris Mason | 26b8003 | 2007-08-08 20:17:12 -0400 | [diff] [blame] | 116 | h->alloc_exclude_nr = 0; |
| 117 | h->alloc_exclude_start = 0; |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 118 | root->fs_info->running_transaction->use_count++; |
| 119 | mutex_unlock(&root->fs_info->trans_mutex); |
| 120 | return h; |
| 121 | } |
| 122 | |
| 123 | int btrfs_end_transaction(struct btrfs_trans_handle *trans, |
| 124 | struct btrfs_root *root) |
| 125 | { |
| 126 | struct btrfs_transaction *cur_trans; |
Chris Mason | d6e4a42 | 2007-04-06 15:37:36 -0400 | [diff] [blame] | 127 | |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 128 | mutex_lock(&root->fs_info->trans_mutex); |
| 129 | cur_trans = root->fs_info->running_transaction; |
Chris Mason | ccd467d | 2007-06-28 15:57:36 -0400 | [diff] [blame] | 130 | WARN_ON(cur_trans != trans->transaction); |
Chris Mason | d571976 | 2007-03-23 10:01:08 -0400 | [diff] [blame] | 131 | WARN_ON(cur_trans->num_writers < 1); |
Chris Mason | ccd467d | 2007-06-28 15:57:36 -0400 | [diff] [blame] | 132 | cur_trans->num_writers--; |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 133 | if (waitqueue_active(&cur_trans->writer_wait)) |
| 134 | wake_up(&cur_trans->writer_wait); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 135 | put_transaction(cur_trans); |
| 136 | mutex_unlock(&root->fs_info->trans_mutex); |
Chris Mason | d602557 | 2007-03-30 14:27:56 -0400 | [diff] [blame] | 137 | memset(trans, 0, sizeof(*trans)); |
Chris Mason | 2c90e5d | 2007-04-02 10:50:19 -0400 | [diff] [blame] | 138 | kmem_cache_free(btrfs_trans_handle_cachep, trans); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | |
| 143 | int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans, |
| 144 | struct btrfs_root *root) |
| 145 | { |
Chris Mason | 7c4452b | 2007-04-28 09:29:35 -0400 | [diff] [blame] | 146 | unsigned long gang[16]; |
| 147 | int ret; |
| 148 | int i; |
| 149 | int err; |
| 150 | int werr = 0; |
| 151 | struct page *page; |
| 152 | struct radix_tree_root *dirty_pages; |
| 153 | struct inode *btree_inode = root->fs_info->btree_inode; |
| 154 | |
| 155 | if (!trans || !trans->transaction) { |
| 156 | return filemap_write_and_wait(btree_inode->i_mapping); |
| 157 | } |
| 158 | dirty_pages = &trans->transaction->dirty_pages; |
| 159 | while(1) { |
Chris Mason | e37c9e6 | 2007-05-09 20:13:14 -0400 | [diff] [blame] | 160 | ret = find_first_radix_bit(dirty_pages, gang, |
| 161 | 0, ARRAY_SIZE(gang)); |
Chris Mason | 7c4452b | 2007-04-28 09:29:35 -0400 | [diff] [blame] | 162 | if (!ret) |
| 163 | break; |
| 164 | for (i = 0; i < ret; i++) { |
| 165 | /* FIXME EIO */ |
| 166 | clear_radix_bit(dirty_pages, gang[i]); |
| 167 | page = find_lock_page(btree_inode->i_mapping, |
| 168 | gang[i]); |
| 169 | if (!page) |
| 170 | continue; |
Chris Mason | 6702ed4 | 2007-08-07 16:15:09 -0400 | [diff] [blame] | 171 | if (PageWriteback(page)) { |
| 172 | if (PageDirty(page)) |
| 173 | wait_on_page_writeback(page); |
| 174 | else { |
| 175 | unlock_page(page); |
| 176 | page_cache_release(page); |
| 177 | continue; |
| 178 | } |
| 179 | } |
Chris Mason | 7c4452b | 2007-04-28 09:29:35 -0400 | [diff] [blame] | 180 | err = write_one_page(page, 0); |
| 181 | if (err) |
| 182 | werr = err; |
| 183 | page_cache_release(page); |
| 184 | } |
| 185 | } |
| 186 | err = filemap_fdatawait(btree_inode->i_mapping); |
| 187 | if (err) |
| 188 | werr = err; |
| 189 | return werr; |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans, |
| 193 | struct btrfs_root *root) |
| 194 | { |
| 195 | int ret; |
| 196 | u64 old_extent_block; |
| 197 | struct btrfs_fs_info *fs_info = root->fs_info; |
| 198 | struct btrfs_root *tree_root = fs_info->tree_root; |
| 199 | struct btrfs_root *extent_root = fs_info->extent_root; |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 200 | |
Chris Mason | 9078a3e | 2007-04-26 16:46:15 -0400 | [diff] [blame] | 201 | btrfs_write_dirty_block_groups(trans, extent_root); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 202 | while(1) { |
| 203 | old_extent_block = btrfs_root_blocknr(&extent_root->root_item); |
Chris Mason | 7eccb90 | 2007-04-11 15:53:25 -0400 | [diff] [blame] | 204 | if (old_extent_block == bh_blocknr(extent_root->node)) |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 205 | break; |
| 206 | btrfs_set_root_blocknr(&extent_root->root_item, |
Chris Mason | 7eccb90 | 2007-04-11 15:53:25 -0400 | [diff] [blame] | 207 | bh_blocknr(extent_root->node)); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 208 | ret = btrfs_update_root(trans, tree_root, |
| 209 | &extent_root->root_key, |
| 210 | &extent_root->root_item); |
| 211 | BUG_ON(ret); |
Chris Mason | 9078a3e | 2007-04-26 16:46:15 -0400 | [diff] [blame] | 212 | btrfs_write_dirty_block_groups(trans, extent_root); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 213 | } |
| 214 | return 0; |
| 215 | } |
| 216 | |
| 217 | static int wait_for_commit(struct btrfs_root *root, |
| 218 | struct btrfs_transaction *commit) |
| 219 | { |
| 220 | DEFINE_WAIT(wait); |
Chris Mason | ccd467d | 2007-06-28 15:57:36 -0400 | [diff] [blame] | 221 | mutex_lock(&root->fs_info->trans_mutex); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 222 | while(!commit->commit_done) { |
| 223 | prepare_to_wait(&commit->commit_wait, &wait, |
| 224 | TASK_UNINTERRUPTIBLE); |
| 225 | if (commit->commit_done) |
| 226 | break; |
| 227 | mutex_unlock(&root->fs_info->trans_mutex); |
| 228 | schedule(); |
| 229 | mutex_lock(&root->fs_info->trans_mutex); |
| 230 | } |
Chris Mason | ccd467d | 2007-06-28 15:57:36 -0400 | [diff] [blame] | 231 | mutex_unlock(&root->fs_info->trans_mutex); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 232 | finish_wait(&commit->commit_wait, &wait); |
| 233 | return 0; |
| 234 | } |
| 235 | |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 236 | struct dirty_root { |
| 237 | struct list_head list; |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 238 | struct btrfs_root *root; |
| 239 | }; |
| 240 | |
Chris Mason | 5eda7b5 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 241 | int btrfs_add_dead_root(struct btrfs_root *root, struct list_head *dead_list) |
| 242 | { |
| 243 | struct dirty_root *dirty; |
| 244 | |
| 245 | dirty = kmalloc(sizeof(*dirty), GFP_NOFS); |
| 246 | if (!dirty) |
| 247 | return -ENOMEM; |
Chris Mason | 5eda7b5 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 248 | dirty->root = root; |
Chris Mason | 5eda7b5 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 249 | list_add(&dirty->list, dead_list); |
| 250 | return 0; |
| 251 | } |
| 252 | |
Chris Mason | 35b7e47 | 2007-05-02 15:53:43 -0400 | [diff] [blame] | 253 | static int add_dirty_roots(struct btrfs_trans_handle *trans, |
| 254 | struct radix_tree_root *radix, |
| 255 | struct list_head *list) |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 256 | { |
| 257 | struct dirty_root *dirty; |
| 258 | struct btrfs_root *gang[8]; |
| 259 | struct btrfs_root *root; |
| 260 | int i; |
| 261 | int ret; |
Chris Mason | 54aa1f4 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 262 | int err = 0; |
Chris Mason | 5eda7b5 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 263 | u32 refs; |
Chris Mason | 54aa1f4 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 264 | |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 265 | while(1) { |
| 266 | ret = radix_tree_gang_lookup_tag(radix, (void **)gang, 0, |
| 267 | ARRAY_SIZE(gang), |
| 268 | BTRFS_ROOT_TRANS_TAG); |
| 269 | if (ret == 0) |
| 270 | break; |
| 271 | for (i = 0; i < ret; i++) { |
| 272 | root = gang[i]; |
Chris Mason | 2619ba1 | 2007-04-10 16:58:11 -0400 | [diff] [blame] | 273 | radix_tree_tag_clear(radix, |
| 274 | (unsigned long)root->root_key.objectid, |
| 275 | BTRFS_ROOT_TRANS_TAG); |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 276 | if (root->commit_root == root->node) { |
Chris Mason | 7eccb90 | 2007-04-11 15:53:25 -0400 | [diff] [blame] | 277 | WARN_ON(bh_blocknr(root->node) != |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 278 | btrfs_root_blocknr(&root->root_item)); |
| 279 | brelse(root->commit_root); |
| 280 | root->commit_root = NULL; |
| 281 | continue; |
| 282 | } |
| 283 | dirty = kmalloc(sizeof(*dirty), GFP_NOFS); |
| 284 | BUG_ON(!dirty); |
Chris Mason | 9f3a742 | 2007-08-07 15:52:19 -0400 | [diff] [blame] | 285 | dirty->root = kmalloc(sizeof(*dirty->root), GFP_NOFS); |
| 286 | BUG_ON(!dirty->root); |
| 287 | |
| 288 | memset(&root->root_item.drop_progress, 0, |
| 289 | sizeof(struct btrfs_disk_key)); |
| 290 | root->root_item.drop_level = 0; |
| 291 | |
| 292 | memcpy(dirty->root, root, sizeof(*root)); |
| 293 | dirty->root->node = root->commit_root; |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 294 | root->commit_root = NULL; |
Chris Mason | 5eda7b5 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 295 | |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 296 | root->root_key.offset = root->fs_info->generation; |
| 297 | btrfs_set_root_blocknr(&root->root_item, |
Chris Mason | 7eccb90 | 2007-04-11 15:53:25 -0400 | [diff] [blame] | 298 | bh_blocknr(root->node)); |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 299 | err = btrfs_insert_root(trans, root->fs_info->tree_root, |
| 300 | &root->root_key, |
| 301 | &root->root_item); |
Chris Mason | 54aa1f4 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 302 | if (err) |
| 303 | break; |
Chris Mason | 9f3a742 | 2007-08-07 15:52:19 -0400 | [diff] [blame] | 304 | |
| 305 | refs = btrfs_root_refs(&dirty->root->root_item); |
| 306 | btrfs_set_root_refs(&dirty->root->root_item, refs - 1); |
Chris Mason | 5eda7b5 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 307 | err = btrfs_update_root(trans, root->fs_info->tree_root, |
Chris Mason | 9f3a742 | 2007-08-07 15:52:19 -0400 | [diff] [blame] | 308 | &dirty->root->root_key, |
| 309 | &dirty->root->root_item); |
Chris Mason | 5eda7b5 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 310 | |
| 311 | BUG_ON(err); |
Chris Mason | 9f3a742 | 2007-08-07 15:52:19 -0400 | [diff] [blame] | 312 | if (refs == 1) { |
Chris Mason | 5eda7b5 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 313 | list_add(&dirty->list, list); |
Chris Mason | 9f3a742 | 2007-08-07 15:52:19 -0400 | [diff] [blame] | 314 | } else { |
| 315 | WARN_ON(1); |
| 316 | kfree(dirty->root); |
Chris Mason | 5eda7b5 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 317 | kfree(dirty); |
Chris Mason | 9f3a742 | 2007-08-07 15:52:19 -0400 | [diff] [blame] | 318 | } |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 319 | } |
| 320 | } |
Chris Mason | 54aa1f4 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 321 | return err; |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 322 | } |
| 323 | |
Chris Mason | e9d0b13 | 2007-08-10 14:06:19 -0400 | [diff] [blame] | 324 | int btrfs_defrag_root(struct btrfs_root *root, int cacheonly) |
| 325 | { |
| 326 | struct btrfs_fs_info *info = root->fs_info; |
| 327 | int ret; |
| 328 | struct btrfs_trans_handle *trans; |
| 329 | |
| 330 | if (root->defrag_running) |
| 331 | return 0; |
| 332 | |
| 333 | trans = btrfs_start_transaction(root, 1); |
| 334 | while (1) { |
| 335 | root->defrag_running = 1; |
| 336 | ret = btrfs_defrag_leaves(trans, root, cacheonly); |
| 337 | btrfs_end_transaction(trans, root); |
| 338 | mutex_unlock(&info->fs_mutex); |
| 339 | |
| 340 | btrfs_btree_balance_dirty(root); |
| 341 | cond_resched(); |
| 342 | |
| 343 | mutex_lock(&info->fs_mutex); |
| 344 | trans = btrfs_start_transaction(root, 1); |
| 345 | if (ret != -EAGAIN) |
| 346 | break; |
| 347 | } |
| 348 | root->defrag_running = 0; |
| 349 | radix_tree_tag_clear(&info->fs_roots_radix, |
| 350 | (unsigned long)root->root_key.objectid, |
| 351 | BTRFS_ROOT_DEFRAG_TAG); |
| 352 | btrfs_end_transaction(trans, root); |
| 353 | return 0; |
| 354 | } |
| 355 | |
Chris Mason | 6702ed4 | 2007-08-07 16:15:09 -0400 | [diff] [blame] | 356 | int btrfs_defrag_dirty_roots(struct btrfs_fs_info *info) |
| 357 | { |
| 358 | struct btrfs_root *gang[1]; |
| 359 | struct btrfs_root *root; |
Chris Mason | 6702ed4 | 2007-08-07 16:15:09 -0400 | [diff] [blame] | 360 | int i; |
| 361 | int ret; |
| 362 | int err = 0; |
| 363 | u64 last = 0; |
| 364 | |
Chris Mason | 6702ed4 | 2007-08-07 16:15:09 -0400 | [diff] [blame] | 365 | while(1) { |
| 366 | ret = radix_tree_gang_lookup_tag(&info->fs_roots_radix, |
| 367 | (void **)gang, last, |
| 368 | ARRAY_SIZE(gang), |
| 369 | BTRFS_ROOT_DEFRAG_TAG); |
| 370 | if (ret == 0) |
| 371 | break; |
| 372 | for (i = 0; i < ret; i++) { |
| 373 | root = gang[i]; |
| 374 | last = root->root_key.objectid + 1; |
Chris Mason | e9d0b13 | 2007-08-10 14:06:19 -0400 | [diff] [blame] | 375 | btrfs_defrag_root(root, 1); |
Chris Mason | 6702ed4 | 2007-08-07 16:15:09 -0400 | [diff] [blame] | 376 | } |
| 377 | } |
Chris Mason | e9d0b13 | 2007-08-10 14:06:19 -0400 | [diff] [blame] | 378 | btrfs_defrag_root(info->extent_root, 1); |
Chris Mason | 6702ed4 | 2007-08-07 16:15:09 -0400 | [diff] [blame] | 379 | return err; |
| 380 | } |
| 381 | |
Chris Mason | 35b7e47 | 2007-05-02 15:53:43 -0400 | [diff] [blame] | 382 | static int drop_dirty_roots(struct btrfs_root *tree_root, |
| 383 | struct list_head *list) |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 384 | { |
| 385 | struct dirty_root *dirty; |
| 386 | struct btrfs_trans_handle *trans; |
Chris Mason | 54aa1f4 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 387 | int ret = 0; |
Chris Mason | 9f3a742 | 2007-08-07 15:52:19 -0400 | [diff] [blame] | 388 | int err; |
| 389 | |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 390 | while(!list_empty(list)) { |
Chris Mason | facda1e | 2007-06-08 18:11:48 -0400 | [diff] [blame] | 391 | mutex_lock(&tree_root->fs_info->fs_mutex); |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 392 | dirty = list_entry(list->next, struct dirty_root, list); |
| 393 | list_del_init(&dirty->list); |
Chris Mason | 5eda7b5 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 394 | |
Chris Mason | 9f3a742 | 2007-08-07 15:52:19 -0400 | [diff] [blame] | 395 | while(1) { |
| 396 | trans = btrfs_start_transaction(tree_root, 1); |
| 397 | ret = btrfs_drop_snapshot(trans, dirty->root); |
| 398 | if (ret != -EAGAIN) { |
| 399 | break; |
| 400 | } |
| 401 | err = btrfs_update_root(trans, |
| 402 | tree_root, |
| 403 | &dirty->root->root_key, |
| 404 | &dirty->root->root_item); |
| 405 | if (err) |
| 406 | ret = err; |
| 407 | ret = btrfs_end_transaction(trans, tree_root); |
| 408 | BUG_ON(ret); |
Chris Mason | f4468e9 | 2007-08-08 10:08:58 -0400 | [diff] [blame] | 409 | mutex_unlock(&tree_root->fs_info->fs_mutex); |
| 410 | |
| 411 | btrfs_btree_balance_dirty(tree_root); |
| 412 | schedule(); |
| 413 | |
| 414 | mutex_lock(&tree_root->fs_info->fs_mutex); |
Chris Mason | 9f3a742 | 2007-08-07 15:52:19 -0400 | [diff] [blame] | 415 | } |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 416 | BUG_ON(ret); |
Chris Mason | 9f3a742 | 2007-08-07 15:52:19 -0400 | [diff] [blame] | 417 | ret = btrfs_del_root(trans, tree_root, &dirty->root->root_key); |
Chris Mason | 54aa1f4 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 418 | if (ret) |
| 419 | break; |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 420 | ret = btrfs_end_transaction(trans, tree_root); |
| 421 | BUG_ON(ret); |
Chris Mason | 5eda7b5 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 422 | |
Chris Mason | 9f3a742 | 2007-08-07 15:52:19 -0400 | [diff] [blame] | 423 | kfree(dirty->root); |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 424 | kfree(dirty); |
Chris Mason | facda1e | 2007-06-08 18:11:48 -0400 | [diff] [blame] | 425 | mutex_unlock(&tree_root->fs_info->fs_mutex); |
Chris Mason | 8c2383c | 2007-06-18 09:57:58 -0400 | [diff] [blame] | 426 | btrfs_btree_balance_dirty(tree_root); |
Chris Mason | f4468e9 | 2007-08-08 10:08:58 -0400 | [diff] [blame] | 427 | schedule(); |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 428 | } |
Chris Mason | 54aa1f4 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 429 | return ret; |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 430 | } |
| 431 | |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 432 | int btrfs_commit_transaction(struct btrfs_trans_handle *trans, |
| 433 | struct btrfs_root *root) |
| 434 | { |
Josef Bacik | 15ee9bc | 2007-08-10 16:22:09 -0400 | [diff] [blame^] | 435 | unsigned long joined = 0; |
| 436 | unsigned long timeout = 1; |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 437 | struct btrfs_transaction *cur_trans; |
Chris Mason | 8fd1779 | 2007-04-19 21:01:03 -0400 | [diff] [blame] | 438 | struct btrfs_transaction *prev_trans = NULL; |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 439 | struct list_head dirty_fs_roots; |
Chris Mason | ccd467d | 2007-06-28 15:57:36 -0400 | [diff] [blame] | 440 | struct radix_tree_root pinned_copy; |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 441 | DEFINE_WAIT(wait); |
Josef Bacik | 15ee9bc | 2007-08-10 16:22:09 -0400 | [diff] [blame^] | 442 | int ret; |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 443 | |
Chris Mason | ccd467d | 2007-06-28 15:57:36 -0400 | [diff] [blame] | 444 | init_bit_radix(&pinned_copy); |
Chris Mason | 0f7d52f | 2007-04-09 10:42:37 -0400 | [diff] [blame] | 445 | INIT_LIST_HEAD(&dirty_fs_roots); |
Chris Mason | d6e4a42 | 2007-04-06 15:37:36 -0400 | [diff] [blame] | 446 | |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 447 | mutex_lock(&root->fs_info->trans_mutex); |
| 448 | if (trans->transaction->in_commit) { |
| 449 | cur_trans = trans->transaction; |
| 450 | trans->transaction->use_count++; |
Chris Mason | ccd467d | 2007-06-28 15:57:36 -0400 | [diff] [blame] | 451 | mutex_unlock(&root->fs_info->trans_mutex); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 452 | btrfs_end_transaction(trans, root); |
Chris Mason | ccd467d | 2007-06-28 15:57:36 -0400 | [diff] [blame] | 453 | |
| 454 | mutex_unlock(&root->fs_info->fs_mutex); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 455 | ret = wait_for_commit(root, cur_trans); |
| 456 | BUG_ON(ret); |
Josef Bacik | 15ee9bc | 2007-08-10 16:22:09 -0400 | [diff] [blame^] | 457 | |
| 458 | mutex_lock(&root->fs_info->trans_mutex); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 459 | put_transaction(cur_trans); |
Josef Bacik | 15ee9bc | 2007-08-10 16:22:09 -0400 | [diff] [blame^] | 460 | mutex_unlock(&root->fs_info->trans_mutex); |
| 461 | |
Chris Mason | ccd467d | 2007-06-28 15:57:36 -0400 | [diff] [blame] | 462 | mutex_lock(&root->fs_info->fs_mutex); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 463 | return 0; |
| 464 | } |
Chris Mason | 2c90e5d | 2007-04-02 10:50:19 -0400 | [diff] [blame] | 465 | trans->transaction->in_commit = 1; |
Chris Mason | ccd467d | 2007-06-28 15:57:36 -0400 | [diff] [blame] | 466 | cur_trans = trans->transaction; |
| 467 | if (cur_trans->list.prev != &root->fs_info->trans_list) { |
| 468 | prev_trans = list_entry(cur_trans->list.prev, |
| 469 | struct btrfs_transaction, list); |
| 470 | if (!prev_trans->commit_done) { |
| 471 | prev_trans->use_count++; |
| 472 | mutex_unlock(&root->fs_info->fs_mutex); |
| 473 | mutex_unlock(&root->fs_info->trans_mutex); |
| 474 | |
| 475 | wait_for_commit(root, prev_trans); |
Chris Mason | ccd467d | 2007-06-28 15:57:36 -0400 | [diff] [blame] | 476 | |
| 477 | mutex_lock(&root->fs_info->fs_mutex); |
| 478 | mutex_lock(&root->fs_info->trans_mutex); |
Josef Bacik | 15ee9bc | 2007-08-10 16:22:09 -0400 | [diff] [blame^] | 479 | put_transaction(prev_trans); |
Chris Mason | ccd467d | 2007-06-28 15:57:36 -0400 | [diff] [blame] | 480 | } |
| 481 | } |
Josef Bacik | 15ee9bc | 2007-08-10 16:22:09 -0400 | [diff] [blame^] | 482 | |
| 483 | do { |
| 484 | joined = cur_trans->num_joined; |
Chris Mason | 2c90e5d | 2007-04-02 10:50:19 -0400 | [diff] [blame] | 485 | WARN_ON(cur_trans != trans->transaction); |
Josef Bacik | 15ee9bc | 2007-08-10 16:22:09 -0400 | [diff] [blame^] | 486 | prepare_to_wait(&cur_trans->writer_wait, &wait, |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 487 | TASK_UNINTERRUPTIBLE); |
Josef Bacik | 15ee9bc | 2007-08-10 16:22:09 -0400 | [diff] [blame^] | 488 | |
| 489 | if (cur_trans->num_writers > 1) |
| 490 | timeout = MAX_SCHEDULE_TIMEOUT; |
| 491 | else |
| 492 | timeout = 1; |
| 493 | |
Chris Mason | ccd467d | 2007-06-28 15:57:36 -0400 | [diff] [blame] | 494 | mutex_unlock(&root->fs_info->fs_mutex); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 495 | mutex_unlock(&root->fs_info->trans_mutex); |
Josef Bacik | 15ee9bc | 2007-08-10 16:22:09 -0400 | [diff] [blame^] | 496 | |
| 497 | schedule_timeout(timeout); |
| 498 | |
Chris Mason | ccd467d | 2007-06-28 15:57:36 -0400 | [diff] [blame] | 499 | mutex_lock(&root->fs_info->fs_mutex); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 500 | mutex_lock(&root->fs_info->trans_mutex); |
Josef Bacik | 15ee9bc | 2007-08-10 16:22:09 -0400 | [diff] [blame^] | 501 | finish_wait(&cur_trans->writer_wait, &wait); |
| 502 | } while (cur_trans->num_writers > 1 || |
| 503 | (cur_trans->num_joined != joined)); |
| 504 | |
Chris Mason | 2c90e5d | 2007-04-02 10:50:19 -0400 | [diff] [blame] | 505 | WARN_ON(cur_trans != trans->transaction); |
Chris Mason | 54aa1f4 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 506 | ret = add_dirty_roots(trans, &root->fs_info->fs_roots_radix, |
| 507 | &dirty_fs_roots); |
| 508 | BUG_ON(ret); |
| 509 | |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 510 | ret = btrfs_commit_tree_roots(trans, root); |
| 511 | BUG_ON(ret); |
Chris Mason | 54aa1f4 | 2007-06-22 14:16:25 -0400 | [diff] [blame] | 512 | |
Chris Mason | 78fae27 | 2007-03-25 11:35:08 -0400 | [diff] [blame] | 513 | cur_trans = root->fs_info->running_transaction; |
| 514 | root->fs_info->running_transaction = NULL; |
Chris Mason | 4b52dff | 2007-06-26 10:06:50 -0400 | [diff] [blame] | 515 | btrfs_set_super_generation(&root->fs_info->super_copy, |
| 516 | cur_trans->transid); |
| 517 | btrfs_set_super_root(&root->fs_info->super_copy, |
| 518 | bh_blocknr(root->fs_info->tree_root->node)); |
| 519 | memcpy(root->fs_info->disk_super, &root->fs_info->super_copy, |
| 520 | sizeof(root->fs_info->super_copy)); |
Chris Mason | ccd467d | 2007-06-28 15:57:36 -0400 | [diff] [blame] | 521 | |
| 522 | btrfs_copy_pinned(root, &pinned_copy); |
| 523 | |
Chris Mason | 78fae27 | 2007-03-25 11:35:08 -0400 | [diff] [blame] | 524 | mutex_unlock(&root->fs_info->trans_mutex); |
Chris Mason | 8fd1779 | 2007-04-19 21:01:03 -0400 | [diff] [blame] | 525 | mutex_unlock(&root->fs_info->fs_mutex); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 526 | ret = btrfs_write_and_wait_transaction(trans, root); |
| 527 | BUG_ON(ret); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 528 | write_ctree_super(trans, root); |
Chris Mason | 8fd1779 | 2007-04-19 21:01:03 -0400 | [diff] [blame] | 529 | mutex_lock(&root->fs_info->fs_mutex); |
Chris Mason | ccd467d | 2007-06-28 15:57:36 -0400 | [diff] [blame] | 530 | btrfs_finish_extent_commit(trans, root, &pinned_copy); |
Chris Mason | 78fae27 | 2007-03-25 11:35:08 -0400 | [diff] [blame] | 531 | mutex_lock(&root->fs_info->trans_mutex); |
Chris Mason | 2c90e5d | 2007-04-02 10:50:19 -0400 | [diff] [blame] | 532 | cur_trans->commit_done = 1; |
Josef Bacik | 15ee9bc | 2007-08-10 16:22:09 -0400 | [diff] [blame^] | 533 | root->fs_info->last_trans_committed = cur_trans->transid; |
Chris Mason | 2c90e5d | 2007-04-02 10:50:19 -0400 | [diff] [blame] | 534 | wake_up(&cur_trans->commit_wait); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 535 | put_transaction(cur_trans); |
Chris Mason | 78fae27 | 2007-03-25 11:35:08 -0400 | [diff] [blame] | 536 | put_transaction(cur_trans); |
Chris Mason | facda1e | 2007-06-08 18:11:48 -0400 | [diff] [blame] | 537 | if (root->fs_info->closing) |
| 538 | list_splice_init(&root->fs_info->dead_roots, &dirty_fs_roots); |
| 539 | else |
| 540 | list_splice_init(&dirty_fs_roots, &root->fs_info->dead_roots); |
Chris Mason | 78fae27 | 2007-03-25 11:35:08 -0400 | [diff] [blame] | 541 | mutex_unlock(&root->fs_info->trans_mutex); |
Chris Mason | 2c90e5d | 2007-04-02 10:50:19 -0400 | [diff] [blame] | 542 | kmem_cache_free(btrfs_trans_handle_cachep, trans); |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 543 | |
Chris Mason | facda1e | 2007-06-08 18:11:48 -0400 | [diff] [blame] | 544 | if (root->fs_info->closing) { |
| 545 | mutex_unlock(&root->fs_info->fs_mutex); |
| 546 | drop_dirty_roots(root->fs_info->tree_root, &dirty_fs_roots); |
| 547 | mutex_lock(&root->fs_info->fs_mutex); |
| 548 | } |
Chris Mason | 79154b1 | 2007-03-22 15:59:16 -0400 | [diff] [blame] | 549 | return ret; |
| 550 | } |
| 551 | |
Chris Mason | e9d0b13 | 2007-08-10 14:06:19 -0400 | [diff] [blame] | 552 | int btrfs_clean_old_snapshots(struct btrfs_root *root) |
| 553 | { |
| 554 | struct list_head dirty_roots; |
| 555 | INIT_LIST_HEAD(&dirty_roots); |
| 556 | |
| 557 | mutex_lock(&root->fs_info->trans_mutex); |
| 558 | list_splice_init(&root->fs_info->dead_roots, &dirty_roots); |
| 559 | mutex_unlock(&root->fs_info->trans_mutex); |
| 560 | |
| 561 | if (!list_empty(&dirty_roots)) { |
| 562 | drop_dirty_roots(root, &dirty_roots); |
| 563 | } |
| 564 | return 0; |
| 565 | } |
Chris Mason | 08607c1 | 2007-06-08 15:33:54 -0400 | [diff] [blame] | 566 | void btrfs_transaction_cleaner(struct work_struct *work) |
| 567 | { |
| 568 | struct btrfs_fs_info *fs_info = container_of(work, |
| 569 | struct btrfs_fs_info, |
| 570 | trans_work.work); |
| 571 | |
| 572 | struct btrfs_root *root = fs_info->tree_root; |
| 573 | struct btrfs_transaction *cur; |
| 574 | struct btrfs_trans_handle *trans; |
| 575 | unsigned long now; |
| 576 | unsigned long delay = HZ * 30; |
| 577 | int ret; |
| 578 | |
Chris Mason | 08607c1 | 2007-06-08 15:33:54 -0400 | [diff] [blame] | 579 | mutex_lock(&root->fs_info->fs_mutex); |
| 580 | mutex_lock(&root->fs_info->trans_mutex); |
| 581 | cur = root->fs_info->running_transaction; |
| 582 | if (!cur) { |
| 583 | mutex_unlock(&root->fs_info->trans_mutex); |
| 584 | goto out; |
| 585 | } |
| 586 | now = get_seconds(); |
| 587 | if (now < cur->start_time || now - cur->start_time < 30) { |
| 588 | mutex_unlock(&root->fs_info->trans_mutex); |
| 589 | delay = HZ * 5; |
| 590 | goto out; |
| 591 | } |
| 592 | mutex_unlock(&root->fs_info->trans_mutex); |
Chris Mason | 6702ed4 | 2007-08-07 16:15:09 -0400 | [diff] [blame] | 593 | btrfs_defrag_dirty_roots(root->fs_info); |
Chris Mason | 08607c1 | 2007-06-08 15:33:54 -0400 | [diff] [blame] | 594 | trans = btrfs_start_transaction(root, 1); |
| 595 | ret = btrfs_commit_transaction(trans, root); |
| 596 | out: |
| 597 | mutex_unlock(&root->fs_info->fs_mutex); |
Chris Mason | e9d0b13 | 2007-08-10 14:06:19 -0400 | [diff] [blame] | 598 | btrfs_clean_old_snapshots(root); |
Chris Mason | 08607c1 | 2007-06-08 15:33:54 -0400 | [diff] [blame] | 599 | btrfs_transaction_queue_work(root, delay); |
| 600 | } |
| 601 | |
| 602 | void btrfs_transaction_queue_work(struct btrfs_root *root, int delay) |
| 603 | { |
| 604 | queue_delayed_work(trans_wq, &root->fs_info->trans_work, delay); |
| 605 | } |
| 606 | |
| 607 | void btrfs_transaction_flush_work(struct btrfs_root *root) |
| 608 | { |
| 609 | cancel_rearming_delayed_workqueue(trans_wq, &root->fs_info->trans_work); |
| 610 | flush_workqueue(trans_wq); |
| 611 | } |
| 612 | |
| 613 | void __init btrfs_init_transaction_sys(void) |
| 614 | { |
| 615 | trans_wq = create_workqueue("btrfs"); |
| 616 | } |
| 617 | |
| 618 | void __exit btrfs_exit_transaction_sys(void) |
| 619 | { |
| 620 | destroy_workqueue(trans_wq); |
| 621 | } |
| 622 | |