diff options
author | Zhaolei <zhaolei@cn.fujitsu.com> | 2015-08-17 06:44:45 -0400 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2015-08-19 17:24:49 -0400 |
commit | 34eb2a524997e5cd7117569b1fda925516adf6ac (patch) | |
tree | b7d17e3f6a4e78fc51acac6a9260ee901536de05 /fs/btrfs/tree-log.c | |
parent | 46cd28555ffaa40162290dba203daad0ff6f7abd (diff) |
btrfs: Remove useless condition in start_log_trans()
Dan Carpenter <dan.carpenter@oracle.com> reported a smatch warning
for start_log_trans():
fs/btrfs/tree-log.c:178 start_log_trans()
warn: we tested 'root->log_root' before and it was 'false'
fs/btrfs/tree-log.c
147 if (root->log_root) {
We test "root->log_root" here.
...
Reason:
Condition of:
fs/btrfs/tree-log.c:178: if (!root->log_root) {
is not necessary after commit: 7237f1833
It caused a smatch warning, and no functionally error.
Fix:
Deleting above condition will make smatch shut up,
but a better way is to do cleanup for start_log_trans()
to remove duplicated code and make code more readable.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r-- | fs/btrfs/tree-log.c | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 9314adeba946..2e65e8e73844 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
@@ -140,55 +140,46 @@ static int start_log_trans(struct btrfs_trans_handle *trans, | |||
140 | struct btrfs_root *root, | 140 | struct btrfs_root *root, |
141 | struct btrfs_log_ctx *ctx) | 141 | struct btrfs_log_ctx *ctx) |
142 | { | 142 | { |
143 | int index; | 143 | int ret = 0; |
144 | int ret; | ||
145 | 144 | ||
146 | mutex_lock(&root->log_mutex); | 145 | mutex_lock(&root->log_mutex); |
146 | |||
147 | if (root->log_root) { | 147 | if (root->log_root) { |
148 | if (btrfs_need_log_full_commit(root->fs_info, trans)) { | 148 | if (btrfs_need_log_full_commit(root->fs_info, trans)) { |
149 | ret = -EAGAIN; | 149 | ret = -EAGAIN; |
150 | goto out; | 150 | goto out; |
151 | } | 151 | } |
152 | |||
152 | if (!root->log_start_pid) { | 153 | if (!root->log_start_pid) { |
153 | root->log_start_pid = current->pid; | ||
154 | clear_bit(BTRFS_ROOT_MULTI_LOG_TASKS, &root->state); | 154 | clear_bit(BTRFS_ROOT_MULTI_LOG_TASKS, &root->state); |
155 | root->log_start_pid = current->pid; | ||
155 | } else if (root->log_start_pid != current->pid) { | 156 | } else if (root->log_start_pid != current->pid) { |
156 | set_bit(BTRFS_ROOT_MULTI_LOG_TASKS, &root->state); | 157 | set_bit(BTRFS_ROOT_MULTI_LOG_TASKS, &root->state); |
157 | } | 158 | } |
159 | } else { | ||
160 | mutex_lock(&root->fs_info->tree_log_mutex); | ||
161 | if (!root->fs_info->log_root_tree) | ||
162 | ret = btrfs_init_log_root_tree(trans, root->fs_info); | ||
163 | mutex_unlock(&root->fs_info->tree_log_mutex); | ||
164 | if (ret) | ||
165 | goto out; | ||
158 | 166 | ||
159 | atomic_inc(&root->log_batch); | ||
160 | atomic_inc(&root->log_writers); | ||
161 | if (ctx) { | ||
162 | index = root->log_transid % 2; | ||
163 | list_add_tail(&ctx->list, &root->log_ctxs[index]); | ||
164 | ctx->log_transid = root->log_transid; | ||
165 | } | ||
166 | mutex_unlock(&root->log_mutex); | ||
167 | return 0; | ||
168 | } | ||
169 | |||
170 | ret = 0; | ||
171 | mutex_lock(&root->fs_info->tree_log_mutex); | ||
172 | if (!root->fs_info->log_root_tree) | ||
173 | ret = btrfs_init_log_root_tree(trans, root->fs_info); | ||
174 | mutex_unlock(&root->fs_info->tree_log_mutex); | ||
175 | if (ret) | ||
176 | goto out; | ||
177 | |||
178 | if (!root->log_root) { | ||
179 | ret = btrfs_add_log_tree(trans, root); | 167 | ret = btrfs_add_log_tree(trans, root); |
180 | if (ret) | 168 | if (ret) |
181 | goto out; | 169 | goto out; |
170 | |||
171 | clear_bit(BTRFS_ROOT_MULTI_LOG_TASKS, &root->state); | ||
172 | root->log_start_pid = current->pid; | ||
182 | } | 173 | } |
183 | clear_bit(BTRFS_ROOT_MULTI_LOG_TASKS, &root->state); | 174 | |
184 | root->log_start_pid = current->pid; | ||
185 | atomic_inc(&root->log_batch); | 175 | atomic_inc(&root->log_batch); |
186 | atomic_inc(&root->log_writers); | 176 | atomic_inc(&root->log_writers); |
187 | if (ctx) { | 177 | if (ctx) { |
188 | index = root->log_transid % 2; | 178 | int index = root->log_transid % 2; |
189 | list_add_tail(&ctx->list, &root->log_ctxs[index]); | 179 | list_add_tail(&ctx->list, &root->log_ctxs[index]); |
190 | ctx->log_transid = root->log_transid; | 180 | ctx->log_transid = root->log_transid; |
191 | } | 181 | } |
182 | |||
192 | out: | 183 | out: |
193 | mutex_unlock(&root->log_mutex); | 184 | mutex_unlock(&root->log_mutex); |
194 | return ret; | 185 | return ret; |