diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2014-02-20 14:08:53 +0400 |
---|---|---|
committer | Josef Bacik <jbacik@fb.com> | 2014-03-10 23:16:40 +0400 |
commit | e87ac1368700af66c295afa47e5c7df0d9d8b919 (patch) | |
tree | 6e6aefc816113049e3296d979c4d7a32e97324e3 /fs | |
parent | 48cab2e0714913a63155f800a55609a4ff6a36b9 (diff) | |
download | linux-e87ac1368700af66c295afa47e5c7df0d9d8b919.tar.xz |
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')
-rw-r--r-- | fs/btrfs/tree-log.c | 26 |
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, struct btrfs_root *root) { int ret; - int err = 0; mutex_lock(&root->log_mutex); if (root->log_root) { @@ -155,24 +154,27 @@ static int start_log_trans(struct btrfs_trans_handle *trans, mutex_unlock(&root->log_mutex); return 0; } - root->log_multiple_pids = false; - root->log_start_pid = current->pid; + + ret = 0; mutex_lock(&root->fs_info->tree_log_mutex); - if (!root->fs_info->log_root_tree) { + if (!root->fs_info->log_root_tree) ret = btrfs_init_log_root_tree(trans, root->fs_info); - if (ret) - err = ret; - } - if (err == 0 && !root->log_root) { + mutex_unlock(&root->fs_info->tree_log_mutex); + if (ret) + goto out; + + if (!root->log_root) { ret = btrfs_add_log_tree(trans, root); if (ret) - err = ret; + goto out; } - mutex_unlock(&root->fs_info->tree_log_mutex); + root->log_multiple_pids = false; + root->log_start_pid = current->pid; atomic_inc(&root->log_batch); atomic_inc(&root->log_writers); +out: mutex_unlock(&root->log_mutex); - return err; + return ret; } /* @@ -4116,7 +4118,7 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans, ret = start_log_trans(trans, root); if (ret) - goto end_trans; + goto end_no_trans; ret = btrfs_log_inode(trans, root, inode, inode_only); if (ret) |