aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/ctree.h2
-rw-r--r--fs/btrfs/disk-io.c2
-rw-r--r--fs/btrfs/file.c4
-rw-r--r--fs/btrfs/tree-log.c12
4 files changed, 9 insertions, 11 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 2990a7ea6248..6923b9e4f90d 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1491,9 +1491,9 @@ struct btrfs_root {
1491 wait_queue_head_t log_commit_wait[2]; 1491 wait_queue_head_t log_commit_wait[2];
1492 atomic_t log_writers; 1492 atomic_t log_writers;
1493 atomic_t log_commit[2]; 1493 atomic_t log_commit[2];
1494 atomic_t log_batch;
1494 unsigned long log_transid; 1495 unsigned long log_transid;
1495 unsigned long last_log_commit; 1496 unsigned long last_log_commit;
1496 unsigned long log_batch;
1497 pid_t log_start_pid; 1497 pid_t log_start_pid;
1498 bool log_multiple_pids; 1498 bool log_multiple_pids;
1499 1499
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 0dcfb998229e..34717ac2416a 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1168,8 +1168,8 @@ static void __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
1168 atomic_set(&root->log_commit[0], 0); 1168 atomic_set(&root->log_commit[0], 0);
1169 atomic_set(&root->log_commit[1], 0); 1169 atomic_set(&root->log_commit[1], 0);
1170 atomic_set(&root->log_writers, 0); 1170 atomic_set(&root->log_writers, 0);
1171 atomic_set(&root->log_batch, 0);
1171 atomic_set(&root->orphan_inodes, 0); 1172 atomic_set(&root->orphan_inodes, 0);
1172 root->log_batch = 0;
1173 root->log_transid = 0; 1173 root->log_transid = 0;
1174 root->last_log_commit = 0; 1174 root->last_log_commit = 0;
1175 extent_io_tree_init(&root->dirty_log_pages, 1175 extent_io_tree_init(&root->dirty_log_pages,
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index a9d7815cf58e..793bc89c660f 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1551,9 +1551,9 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
1551 * ordered range does a filemape_write_and_wait_range which is why we 1551 * ordered range does a filemape_write_and_wait_range which is why we
1552 * don't do it above like other file systems. 1552 * don't do it above like other file systems.
1553 */ 1553 */
1554 root->log_batch++; 1554 atomic_inc(&root->log_batch);
1555 btrfs_wait_ordered_range(inode, start, end); 1555 btrfs_wait_ordered_range(inode, start, end);
1556 root->log_batch++; 1556 atomic_inc(&root->log_batch);
1557 1557
1558 /* 1558 /*
1559 * check the transaction that last modified this inode 1559 * check the transaction that last modified this inode
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index f9b0fc911661..038a5229404a 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -147,7 +147,7 @@ static int start_log_trans(struct btrfs_trans_handle *trans,
147 root->log_multiple_pids = true; 147 root->log_multiple_pids = true;
148 } 148 }
149 149
150 root->log_batch++; 150 atomic_inc(&root->log_batch);
151 atomic_inc(&root->log_writers); 151 atomic_inc(&root->log_writers);
152 mutex_unlock(&root->log_mutex); 152 mutex_unlock(&root->log_mutex);
153 return 0; 153 return 0;
@@ -166,7 +166,7 @@ static int start_log_trans(struct btrfs_trans_handle *trans,
166 err = ret; 166 err = ret;
167 } 167 }
168 mutex_unlock(&root->fs_info->tree_log_mutex); 168 mutex_unlock(&root->fs_info->tree_log_mutex);
169 root->log_batch++; 169 atomic_inc(&root->log_batch);
170 atomic_inc(&root->log_writers); 170 atomic_inc(&root->log_writers);
171 mutex_unlock(&root->log_mutex); 171 mutex_unlock(&root->log_mutex);
172 return err; 172 return err;
@@ -2036,7 +2036,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2036 if (atomic_read(&root->log_commit[(index1 + 1) % 2])) 2036 if (atomic_read(&root->log_commit[(index1 + 1) % 2]))
2037 wait_log_commit(trans, root, root->log_transid - 1); 2037 wait_log_commit(trans, root, root->log_transid - 1);
2038 while (1) { 2038 while (1) {
2039 unsigned long batch = root->log_batch; 2039 int batch = atomic_read(&root->log_batch);
2040 /* when we're on an ssd, just kick the log commit out */ 2040 /* when we're on an ssd, just kick the log commit out */
2041 if (!btrfs_test_opt(root, SSD) && root->log_multiple_pids) { 2041 if (!btrfs_test_opt(root, SSD) && root->log_multiple_pids) {
2042 mutex_unlock(&root->log_mutex); 2042 mutex_unlock(&root->log_mutex);
@@ -2044,7 +2044,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2044 mutex_lock(&root->log_mutex); 2044 mutex_lock(&root->log_mutex);
2045 } 2045 }
2046 wait_for_writer(trans, root); 2046 wait_for_writer(trans, root);
2047 if (batch == root->log_batch) 2047 if (batch == atomic_read(&root->log_batch))
2048 break; 2048 break;
2049 } 2049 }
2050 2050
@@ -2073,7 +2073,6 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2073 2073
2074 btrfs_set_root_node(&log->root_item, log->node); 2074 btrfs_set_root_node(&log->root_item, log->node);
2075 2075
2076 root->log_batch = 0;
2077 root->log_transid++; 2076 root->log_transid++;
2078 log->log_transid = root->log_transid; 2077 log->log_transid = root->log_transid;
2079 root->log_start_pid = 0; 2078 root->log_start_pid = 0;
@@ -2086,7 +2085,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2086 mutex_unlock(&root->log_mutex); 2085 mutex_unlock(&root->log_mutex);
2087 2086
2088 mutex_lock(&log_root_tree->log_mutex); 2087 mutex_lock(&log_root_tree->log_mutex);
2089 log_root_tree->log_batch++; 2088 atomic_inc(&log_root_tree->log_batch);
2090 atomic_inc(&log_root_tree->log_writers); 2089 atomic_inc(&log_root_tree->log_writers);
2091 mutex_unlock(&log_root_tree->log_mutex); 2090 mutex_unlock(&log_root_tree->log_mutex);
2092 2091
@@ -2156,7 +2155,6 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2156 btrfs_set_super_log_root_level(root->fs_info->super_for_commit, 2155 btrfs_set_super_log_root_level(root->fs_info->super_for_commit,
2157 btrfs_header_level(log_root_tree->node)); 2156 btrfs_header_level(log_root_tree->node));
2158 2157
2159 log_root_tree->log_batch = 0;
2160 log_root_tree->log_transid++; 2158 log_root_tree->log_transid++;
2161 smp_mb(); 2159 smp_mb();
2162 2160