提交 20c7bcec 编写于 作者: S Seraphime Kirkovski 提交者: David Sterba

Btrfs: ACCESS_ONCE cleanup

This replaces ACCESS_ONCE macro with the corresponding
READ|WRITE macros
Signed-off-by: NSeraphime Kirkovski <kirkseraph@gmail.com>
Reviewed-by: NDavid Sterba <dsterba@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 50d0446e
...@@ -79,7 +79,7 @@ static struct btrfs_delayed_node *btrfs_get_delayed_node(struct inode *inode) ...@@ -79,7 +79,7 @@ static struct btrfs_delayed_node *btrfs_get_delayed_node(struct inode *inode)
u64 ino = btrfs_ino(inode); u64 ino = btrfs_ino(inode);
struct btrfs_delayed_node *node; struct btrfs_delayed_node *node;
node = ACCESS_ONCE(btrfs_inode->delayed_node); node = READ_ONCE(btrfs_inode->delayed_node);
if (node) { if (node) {
atomic_inc(&node->refs); atomic_inc(&node->refs);
return node; return node;
...@@ -1292,7 +1292,7 @@ void btrfs_remove_delayed_node(struct inode *inode) ...@@ -1292,7 +1292,7 @@ void btrfs_remove_delayed_node(struct inode *inode)
{ {
struct btrfs_delayed_node *delayed_node; 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) if (!delayed_node)
return; return;
......
...@@ -265,7 +265,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans, ...@@ -265,7 +265,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
function, line, errstr); function, line, errstr);
return; 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 anybody who may be waiting on this transaction */
wake_up(&fs_info->transaction_wait); wake_up(&fs_info->transaction_wait);
wake_up(&fs_info->transaction_blocked_wait); wake_up(&fs_info->transaction_blocked_wait);
......
...@@ -866,14 +866,14 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, ...@@ -866,14 +866,14 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
if (lock && !atomic_read(&info->open_ioctl_trans) && if (lock && !atomic_read(&info->open_ioctl_trans) &&
should_end_transaction(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); spin_lock(&info->trans_lock);
if (cur_trans->state == TRANS_STATE_RUNNING) if (cur_trans->state == TRANS_STATE_RUNNING)
cur_trans->state = TRANS_STATE_BLOCKED; cur_trans->state = TRANS_STATE_BLOCKED;
spin_unlock(&info->trans_lock); 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) if (throttle)
return btrfs_commit_transaction(trans); return btrfs_commit_transaction(trans);
else else
...@@ -1940,7 +1940,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) ...@@ -1940,7 +1940,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
int ret; int ret;
/* Stop the commit early if ->aborted is set */ /* 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; ret = cur_trans->aborted;
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
return ret; return ret;
...@@ -2080,7 +2080,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) ...@@ -2080,7 +2080,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
atomic_read(&cur_trans->num_writers) == 1); atomic_read(&cur_trans->num_writers) == 1);
/* ->aborted might be set after the previous check, so check it */ /* ->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; ret = cur_trans->aborted;
goto scrub_continue; goto scrub_continue;
} }
...@@ -2194,7 +2194,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) ...@@ -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 * The tasks which save the space cache and inode cache may also
* update ->aborted, check it. * update ->aborted, check it.
*/ */
if (unlikely(ACCESS_ONCE(cur_trans->aborted))) { if (unlikely(READ_ONCE(cur_trans->aborted))) {
ret = cur_trans->aborted; ret = cur_trans->aborted;
mutex_unlock(&fs_info->tree_log_mutex); mutex_unlock(&fs_info->tree_log_mutex);
mutex_unlock(&fs_info->reloc_mutex); mutex_unlock(&fs_info->reloc_mutex);
......
...@@ -48,13 +48,13 @@ static inline void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx, ...@@ -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, static inline void btrfs_set_log_full_commit(struct btrfs_fs_info *fs_info,
struct btrfs_trans_handle *trans) 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, static inline int btrfs_need_log_full_commit(struct btrfs_fs_info *fs_info,
struct btrfs_trans_handle *trans) 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; trans->transid;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册