summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index de729acee738..3fc8d854d7fb 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3110,6 +3110,12 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
3110 log->log_transid = root->log_transid; 3110 log->log_transid = root->log_transid;
3111 root->log_start_pid = 0; 3111 root->log_start_pid = 0;
3112 /* 3112 /*
3113 * Update or create log root item under the root's log_mutex to prevent
3114 * races with concurrent log syncs that can lead to failure to update
3115 * log root item because it was not created yet.
3116 */
3117 ret = update_log_root(trans, log);
3118 /*
3113 * IO has been started, blocks of the log tree have WRITTEN flag set 3119 * IO has been started, blocks of the log tree have WRITTEN flag set
3114 * in their headers. new modifications of the log will be written to 3120 * in their headers. new modifications of the log will be written to
3115 * new positions. so it's safe to allow log writers to go in. 3121 * new positions. so it's safe to allow log writers to go in.
@@ -3128,8 +3134,6 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
3128 3134
3129 mutex_unlock(&log_root_tree->log_mutex); 3135 mutex_unlock(&log_root_tree->log_mutex);
3130 3136
3131 ret = update_log_root(trans, log);
3132
3133 mutex_lock(&log_root_tree->log_mutex); 3137 mutex_lock(&log_root_tree->log_mutex);
3134 if (atomic_dec_and_test(&log_root_tree->log_writers)) { 3138 if (atomic_dec_and_test(&log_root_tree->log_writers)) {
3135 /* atomic_dec_and_test implies a barrier */ 3139 /* atomic_dec_and_test implies a barrier */