diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index d5d8b3899258..22ba2b4505b3 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -195,7 +195,7 @@ struct btrfs_root { struct list_head log_ctxs[2]; /* Used only for log trees of subvolumes, not for the log root tree */ atomic_t log_writers; - atomic_t log_commit[2]; + bool log_commit[2]; /* * Protected by the 'log_mutex' lock but can be read without holding * that lock to avoid unnecessary lock contention, in which case it diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index f565d33c1e19..467075a0ebcb 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -666,8 +666,6 @@ static struct btrfs_root *btrfs_alloc_root(struct btrfs_fs_info *fs_info, init_waitqueue_head(&root->log_commit_wait[1]); INIT_LIST_HEAD(&root->log_ctxs[0]); INIT_LIST_HEAD(&root->log_ctxs[1]); - atomic_set(&root->log_commit[0], 0); - atomic_set(&root->log_commit[1], 0); atomic_set(&root->log_writers, 0); refcount_set(&root->refs, 1); atomic_set(&root->snapshot_force_cow, 0); diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index a1a3043a2cad..bafc62cf5ebc 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1517,12 +1517,8 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans) ASSERT(atomic_read(&root->log_writers) == 0, "atomic_read(&root->log_writers)=%d", atomic_read(&root->log_writers)); - ASSERT(atomic_read(&root->log_commit[0]) == 0, - "atomic_read(&root->log_commit[0])=%d", - atomic_read(&root->log_commit[0])); - ASSERT(atomic_read(&root->log_commit[1]) == 0, - "atomic_read(&root->log_commit[1])=%d", - atomic_read(&root->log_commit[1])); + ASSERT(!root->log_commit[0]); + ASSERT(!root->log_commit[1]); radix_tree_tag_clear(&fs_info->fs_roots_radix, (unsigned long)btrfs_root_id(root), diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 7d7a0dbc7b4a..47046dd14997 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -3170,7 +3170,7 @@ static bool wait_log_commit(struct btrfs_root *root, int transid) DEFINE_WAIT(wait); const int index = (transid >= 0 ? transid % 2 : -transid % 2); - if (atomic_read(&root->log_commit[index]) == 0) + if (!root->log_commit[index]) return false; /* @@ -3187,7 +3187,7 @@ static bool wait_log_commit(struct btrfs_root *root, int transid) mutex_lock(&root->log_mutex); if (!(root->log_transid_committed < transid && - atomic_read(&root->log_commit[index]) != 0)) + root->log_commit[index])) break; } finish_wait(&root->log_commit_wait[index], &wait); @@ -3325,7 +3325,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, } ASSERT(log_transid == root->log_transid, "log_transid=%d root->log_transid=%d", log_transid, root->log_transid); - atomic_set(&root->log_commit[index1], 1); + root->log_commit[index1] = true; /* wait for previous tree log sync to complete */ wait_log_commit(root, log_transid - 1); @@ -3445,7 +3445,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, goto out; } - if (atomic_read(&log_root_tree->log_commit[index2])) { + if (log_root_tree->log_commit[index2]) { blk_finish_plug(&plug); ret = btrfs_wait_tree_log_extents(log, mark); wait_log_commit(log_root_tree, @@ -3459,7 +3459,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, ASSERT(root_log_ctx.log_transid == log_root_tree->log_transid, "root_log_ctx.log_transid=%d log_root_tree->log_transid=%d", root_log_ctx.log_transid, log_root_tree->log_transid); - atomic_set(&log_root_tree->log_commit[index2], 1); + log_root_tree->log_commit[index2] = true; wait_log_commit(log_root_tree, root_log_ctx.log_transid - 1); @@ -3559,7 +3559,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, /* * We know there can only be one task here, since we have not yet set - * root->log_commit[index1] to 0 and any task attempting to sync the + * root->log_commit[index1] to false and any task attempting to sync the * log must wait for the previous log transaction to commit if it's * still in progress or wait for the current log transaction commit if * someone else already started it. We use <= and not < because the @@ -3575,7 +3575,7 @@ out_wake_log_root: btrfs_remove_all_log_ctxs(log_root_tree, index2, ret); log_root_tree->log_transid_committed++; - atomic_set(&log_root_tree->log_commit[index2], 0); + log_root_tree->log_commit[index2] = false; mutex_unlock(&log_root_tree->log_mutex); /* @@ -3588,7 +3588,7 @@ out: mutex_lock(&root->log_mutex); btrfs_remove_all_log_ctxs(root, index1, ret); root->log_transid_committed++; - atomic_set(&root->log_commit[index1], 0); + root->log_commit[index1] = false; mutex_unlock(&root->log_mutex); /* diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h index 4c5c47c5edb7..f9d22cd71768 100644 --- a/include/trace/events/btrfs.h +++ b/include/trace/events/btrfs.h @@ -1578,9 +1578,9 @@ TRACE_EVENT(btrfs_sync_log_enter, __entry->log_transid_committed = data_race(root->log_transid_committed); __entry->log_committing = - atomic_read(&root->log_commit[ctx->log_transid % 2]); + data_race(root->log_commit[ctx->log_transid % 2]); __entry->log_committing_prev = - atomic_read(&root->log_commit[(ctx->log_transid + 1) % 2]); + data_race(root->log_commit[(ctx->log_transid + 1) % 2]); __entry->log_writers = atomic_read(&root->log_writers); ),