diff options
author | Jan Schmidt <list.btrfs@jan-o-sch.net> | 2012-05-20 09:42:19 -0400 |
---|---|---|
committer | Jan Schmidt <list.btrfs@jan-o-sch.net> | 2012-05-30 09:17:35 -0400 |
commit | 19ae4e8133f370d820c4cdd61a4b703235664a5f (patch) | |
tree | 3d8e34c149ea6a6ed4bdc5c176a4967e5ce37f39 /fs/btrfs/transaction.c | |
parent | 8445f61cad927b6efffdd4e042a51a783ff8853f (diff) |
Btrfs: fs_info variable for join_transaction
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r-- | fs/btrfs/transaction.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 36422254ef67..eb2bd826bb04 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -55,48 +55,49 @@ static noinline void switch_commit_root(struct btrfs_root *root) | |||
55 | static noinline int join_transaction(struct btrfs_root *root, int nofail) | 55 | static noinline int join_transaction(struct btrfs_root *root, int nofail) |
56 | { | 56 | { |
57 | struct btrfs_transaction *cur_trans; | 57 | struct btrfs_transaction *cur_trans; |
58 | struct btrfs_fs_info *fs_info = root->fs_info; | ||
58 | 59 | ||
59 | spin_lock(&root->fs_info->trans_lock); | 60 | spin_lock(&fs_info->trans_lock); |
60 | loop: | 61 | loop: |
61 | /* The file system has been taken offline. No new transactions. */ | 62 | /* The file system has been taken offline. No new transactions. */ |
62 | if (root->fs_info->fs_state & BTRFS_SUPER_FLAG_ERROR) { | 63 | if (fs_info->fs_state & BTRFS_SUPER_FLAG_ERROR) { |
63 | spin_unlock(&root->fs_info->trans_lock); | 64 | spin_unlock(&fs_info->trans_lock); |
64 | return -EROFS; | 65 | return -EROFS; |
65 | } | 66 | } |
66 | 67 | ||
67 | if (root->fs_info->trans_no_join) { | 68 | if (fs_info->trans_no_join) { |
68 | if (!nofail) { | 69 | if (!nofail) { |
69 | spin_unlock(&root->fs_info->trans_lock); | 70 | spin_unlock(&fs_info->trans_lock); |
70 | return -EBUSY; | 71 | return -EBUSY; |
71 | } | 72 | } |
72 | } | 73 | } |
73 | 74 | ||
74 | cur_trans = root->fs_info->running_transaction; | 75 | cur_trans = fs_info->running_transaction; |
75 | if (cur_trans) { | 76 | if (cur_trans) { |
76 | if (cur_trans->aborted) { | 77 | if (cur_trans->aborted) { |
77 | spin_unlock(&root->fs_info->trans_lock); | 78 | spin_unlock(&fs_info->trans_lock); |
78 | return cur_trans->aborted; | 79 | return cur_trans->aborted; |
79 | } | 80 | } |
80 | atomic_inc(&cur_trans->use_count); | 81 | atomic_inc(&cur_trans->use_count); |
81 | atomic_inc(&cur_trans->num_writers); | 82 | atomic_inc(&cur_trans->num_writers); |
82 | cur_trans->num_joined++; | 83 | cur_trans->num_joined++; |
83 | spin_unlock(&root->fs_info->trans_lock); | 84 | spin_unlock(&fs_info->trans_lock); |
84 | return 0; | 85 | return 0; |
85 | } | 86 | } |
86 | spin_unlock(&root->fs_info->trans_lock); | 87 | spin_unlock(&fs_info->trans_lock); |
87 | 88 | ||
88 | cur_trans = kmem_cache_alloc(btrfs_transaction_cachep, GFP_NOFS); | 89 | cur_trans = kmem_cache_alloc(btrfs_transaction_cachep, GFP_NOFS); |
89 | if (!cur_trans) | 90 | if (!cur_trans) |
90 | return -ENOMEM; | 91 | return -ENOMEM; |
91 | 92 | ||
92 | spin_lock(&root->fs_info->trans_lock); | 93 | spin_lock(&fs_info->trans_lock); |
93 | if (root->fs_info->running_transaction) { | 94 | if (fs_info->running_transaction) { |
94 | /* | 95 | /* |
95 | * someone started a transaction after we unlocked. Make sure | 96 | * someone started a transaction after we unlocked. Make sure |
96 | * to redo the trans_no_join checks above | 97 | * to redo the trans_no_join checks above |
97 | */ | 98 | */ |
98 | kmem_cache_free(btrfs_transaction_cachep, cur_trans); | 99 | kmem_cache_free(btrfs_transaction_cachep, cur_trans); |
99 | cur_trans = root->fs_info->running_transaction; | 100 | cur_trans = fs_info->running_transaction; |
100 | goto loop; | 101 | goto loop; |
101 | } | 102 | } |
102 | 103 | ||
@@ -127,14 +128,14 @@ loop: | |||
127 | INIT_LIST_HEAD(&cur_trans->delayed_refs.seq_head); | 128 | INIT_LIST_HEAD(&cur_trans->delayed_refs.seq_head); |
128 | 129 | ||
129 | INIT_LIST_HEAD(&cur_trans->pending_snapshots); | 130 | INIT_LIST_HEAD(&cur_trans->pending_snapshots); |
130 | list_add_tail(&cur_trans->list, &root->fs_info->trans_list); | 131 | list_add_tail(&cur_trans->list, &fs_info->trans_list); |
131 | extent_io_tree_init(&cur_trans->dirty_pages, | 132 | extent_io_tree_init(&cur_trans->dirty_pages, |
132 | root->fs_info->btree_inode->i_mapping); | 133 | fs_info->btree_inode->i_mapping); |
133 | root->fs_info->generation++; | 134 | fs_info->generation++; |
134 | cur_trans->transid = root->fs_info->generation; | 135 | cur_trans->transid = fs_info->generation; |
135 | root->fs_info->running_transaction = cur_trans; | 136 | fs_info->running_transaction = cur_trans; |
136 | cur_trans->aborted = 0; | 137 | cur_trans->aborted = 0; |
137 | spin_unlock(&root->fs_info->trans_lock); | 138 | spin_unlock(&fs_info->trans_lock); |
138 | 139 | ||
139 | return 0; | 140 | return 0; |
140 | } | 141 | } |