diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2013-01-15 06:27:25 +0000 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-01-24 12:51:23 -0500 |
commit | 8d25a086eb104297e3ba1fdd180b04cfaaa84797 (patch) | |
tree | 075e3a0e731b08a418ad65dfd4e0bb53818a40c1 /fs | |
parent | e58dd74bccb4317e39e4b675bf9c6cd133608fac (diff) | |
download | lwn-8d25a086eb104297e3ba1fdd180b04cfaaa84797.tar.gz lwn-8d25a086eb104297e3ba1fdd180b04cfaaa84797.zip |
Btrfs: Add ACCESS_ONCE() to transaction->abort accesses
We may access and update transaction->aborted on the different CPUs without
lock, so we need ACCESS_ONCE() wrapper to prevent the compiler from creating
unsolicited accesses and make sure we can get the right value.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/super.c | 2 | ||||
-rw-r--r-- | fs/btrfs/transaction.c | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 99545df1b86c..d8982e9601d3 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -267,7 +267,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans, function, line, errstr); return; } - trans->transaction->aborted = errno; + ACCESS_ONCE(trans->transaction->aborted) = errno; __btrfs_std_error(root->fs_info, function, line, errno, NULL); } /* diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 87fac9a21ea5..0ef29611fade 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1468,7 +1468,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, goto cleanup_transaction; } - if (cur_trans->aborted) { + /* Stop the commit early if ->aborted is set */ + if (unlikely(ACCESS_ONCE(cur_trans->aborted))) { ret = cur_trans->aborted; goto cleanup_transaction; } |