aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2014-02-20 05:08:53 -0500
committerJosef Bacik <jbacik@fb.com>2014-03-10 15:16:40 -0400
commite87ac1368700af66c295afa47e5c7df0d9d8b919 (patch)
tree6e6aefc816113049e3296d979c4d7a32e97324e3 /fs/btrfs/tree-log.c
parent48cab2e0714913a63155f800a55609a4ff6a36b9 (diff)
Btrfs: don't start the log transaction if the log tree init fails
The old code would start the log transaction even the log tree init failed, it was unnecessary. Fix it. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fb.com>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 8a03b39648be..ca960ad271fe 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -139,7 +139,6 @@ static int start_log_trans(struct btrfs_trans_handle *trans,
139 struct btrfs_root *root) 139 struct btrfs_root *root)
140{ 140{
141 int ret; 141 int ret;
142 int err = 0;
143 142
144 mutex_lock(&root->log_mutex); 143 mutex_lock(&root->log_mutex);
145 if (root->log_root) { 144 if (root->log_root) {
@@ -155,24 +154,27 @@ static int start_log_trans(struct btrfs_trans_handle *trans,
155 mutex_unlock(&root->log_mutex); 154 mutex_unlock(&root->log_mutex);
156 return 0; 155 return 0;
157 } 156 }
158 root->log_multiple_pids = false; 157
159 root->log_start_pid = current->pid; 158 ret = 0;
160 mutex_lock(&root->fs_info->tree_log_mutex); 159 mutex_lock(&root->fs_info->tree_log_mutex);
161 if (!root->fs_info->log_root_tree) { 160 if (!root->fs_info->log_root_tree)
162 ret = btrfs_init_log_root_tree(trans, root->fs_info); 161 ret = btrfs_init_log_root_tree(trans, root->fs_info);
163 if (ret) 162 mutex_unlock(&root->fs_info->tree_log_mutex);
164 err = ret; 163 if (ret)
165 } 164 goto out;
166 if (err == 0 && !root->log_root) { 165
166 if (!root->log_root) {
167 ret = btrfs_add_log_tree(trans, root); 167 ret = btrfs_add_log_tree(trans, root);
168 if (ret) 168 if (ret)
169 err = ret; 169 goto out;
170 } 170 }
171 mutex_unlock(&root->fs_info->tree_log_mutex); 171 root->log_multiple_pids = false;
172 root->log_start_pid = current->pid;
172 atomic_inc(&root->log_batch); 173 atomic_inc(&root->log_batch);
173 atomic_inc(&root->log_writers); 174 atomic_inc(&root->log_writers);
175out:
174 mutex_unlock(&root->log_mutex); 176 mutex_unlock(&root->log_mutex);
175 return err; 177 return ret;
176} 178}
177 179
178/* 180/*
@@ -4116,7 +4118,7 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
4116 4118
4117 ret = start_log_trans(trans, root); 4119 ret = start_log_trans(trans, root);
4118 if (ret) 4120 if (ret)
4119 goto end_trans; 4121 goto end_no_trans;
4120 4122
4121 ret = btrfs_log_inode(trans, root, inode, inode_only); 4123 ret = btrfs_log_inode(trans, root, inode, inode_only);
4122 if (ret) 4124 if (ret)