Btrfs: ACCESS_ONCE cleanup
authorSeraphime Kirkovski <kirkseraph@gmail.com>
Thu, 15 Dec 2016 13:38:16 +0000 (14:38 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 14 Feb 2017 14:50:50 +0000 (15:50 +0100)
This replaces ACCESS_ONCE macro with the corresponding
READ|WRITE macros

Signed-off-by: Seraphime Kirkovski <kirkseraph@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/delayed-inode.c
fs/btrfs/super.c
fs/btrfs/transaction.c
fs/btrfs/tree-log.h

index 80982a83c9fdb9eac6e1fdd97623e836c3f6095f..353e40fceba888cc5363be5eaa5a1827980dda27 100644 (file)
@@ -79,7 +79,7 @@ static struct btrfs_delayed_node *btrfs_get_delayed_node(struct inode *inode)
        u64 ino = btrfs_ino(inode);
        struct btrfs_delayed_node *node;
 
-       node = ACCESS_ONCE(btrfs_inode->delayed_node);
+       node = READ_ONCE(btrfs_inode->delayed_node);
        if (node) {
                atomic_inc(&node->refs);
                return node;
@@ -1292,7 +1292,7 @@ void btrfs_remove_delayed_node(struct inode *inode)
 {
        struct btrfs_delayed_node *delayed_node;
 
-       delayed_node = ACCESS_ONCE(BTRFS_I(inode)->delayed_node);
+       delayed_node = READ_ONCE(BTRFS_I(inode)->delayed_node);
        if (!delayed_node)
                return;
 
index b5ae7d3d189629ce3751d816b31b344fa4ad9999..93ed29c2a38b85cf1de156477c77b512b62ea0dc 100644 (file)
@@ -265,7 +265,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
                           function, line, errstr);
                return;
        }
-       ACCESS_ONCE(trans->transaction->aborted) = errno;
+       WRITE_ONCE(trans->transaction->aborted, errno);
        /* Wake up anybody who may be waiting on this transaction */
        wake_up(&fs_info->transaction_wait);
        wake_up(&fs_info->transaction_blocked_wait);
index 0e0508f488b273929a783ec1048d57cb4b9d1761..bd2890c2c9d3f5d6edbe351fc8d003a9fbffe9af 100644 (file)
@@ -866,14 +866,14 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
 
        if (lock && !atomic_read(&info->open_ioctl_trans) &&
            should_end_transaction(trans) &&
-           ACCESS_ONCE(cur_trans->state) == TRANS_STATE_RUNNING) {
+           READ_ONCE(cur_trans->state) == TRANS_STATE_RUNNING) {
                spin_lock(&info->trans_lock);
                if (cur_trans->state == TRANS_STATE_RUNNING)
                        cur_trans->state = TRANS_STATE_BLOCKED;
                spin_unlock(&info->trans_lock);
        }
 
-       if (lock && ACCESS_ONCE(cur_trans->state) == TRANS_STATE_BLOCKED) {
+       if (lock && READ_ONCE(cur_trans->state) == TRANS_STATE_BLOCKED) {
                if (throttle)
                        return btrfs_commit_transaction(trans);
                else
@@ -1940,7 +1940,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
        int ret;
 
        /* Stop the commit early if ->aborted is set */
-       if (unlikely(ACCESS_ONCE(cur_trans->aborted))) {
+       if (unlikely(READ_ONCE(cur_trans->aborted))) {
                ret = cur_trans->aborted;
                btrfs_end_transaction(trans);
                return ret;
@@ -2080,7 +2080,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
                   atomic_read(&cur_trans->num_writers) == 1);
 
        /* ->aborted might be set after the previous check, so check it */
-       if (unlikely(ACCESS_ONCE(cur_trans->aborted))) {
+       if (unlikely(READ_ONCE(cur_trans->aborted))) {
                ret = cur_trans->aborted;
                goto scrub_continue;
        }
@@ -2194,7 +2194,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
         * The tasks which save the space cache and inode cache may also
         * update ->aborted, check it.
         */
-       if (unlikely(ACCESS_ONCE(cur_trans->aborted))) {
+       if (unlikely(READ_ONCE(cur_trans->aborted))) {
                ret = cur_trans->aborted;
                mutex_unlock(&fs_info->tree_log_mutex);
                mutex_unlock(&fs_info->reloc_mutex);
index ab858e31ccbc2210a01a9b7ce69bf52127d00b8b..127eae01bb1b54573965f4ce179b44ded6e443a0 100644 (file)
@@ -48,13 +48,13 @@ static inline void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx,
 static inline void btrfs_set_log_full_commit(struct btrfs_fs_info *fs_info,
                                             struct btrfs_trans_handle *trans)
 {
-       ACCESS_ONCE(fs_info->last_trans_log_full_commit) = trans->transid;
+       WRITE_ONCE(fs_info->last_trans_log_full_commit, trans->transid);
 }
 
 static inline int btrfs_need_log_full_commit(struct btrfs_fs_info *fs_info,
                                             struct btrfs_trans_handle *trans)
 {
-       return ACCESS_ONCE(fs_info->last_trans_log_full_commit) ==
+       return READ_ONCE(fs_info->last_trans_log_full_commit) ==
                trans->transid;
 }