diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2013-01-29 10:07:33 +0000 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-02-20 12:59:02 -0500 |
commit | c018daecead7a46a575e2a1397fea850b83396c8 (patch) | |
tree | f6a68357fbc230b8894a6f19b0ecfae40c1de6d3 /usr | |
parent | 8c6a3ee6dbd564d05019d396ecb5dc5b35cbc273 (diff) | |
download | linux-3.10-c018daecead7a46a575e2a1397fea850b83396c8.tar.gz linux-3.10-c018daecead7a46a575e2a1397fea850b83396c8.tar.bz2 linux-3.10-c018daecead7a46a575e2a1397fea850b83396c8.zip |
Btrfs: protect fs_info->alloc_start
fs_info->alloc_start is a 64bits variant, can be accessed by
multi-task, but it is not protected strictly, it can be changed
while we are accessing it. On 32bit machine, we will get wrong
value because we access it by two instructions.(In fact, it is
also possible that the same problem happens on the 64bit machine,
because the compiler may split the 64bit operation into two 32bit
operation.)
For example:
Assuming -> alloc_start is 0x0000 0000 0001 0000 at the beginning,
then we remount and set ->alloc_start to 0x0000 0100 0000 0000.
Task0 Task1
load high 32 bits
set high 32 bits
set low 32 bits
load low 32 bits
Task1 will get 0.
This patch fixes this problem by using two locks to protect it
fs_info->chunk_mutex
sb->s_umount
On the read side, we just need get one of these two locks, and on
the write side, we must lock all of them.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'usr')
0 files changed, 0 insertions, 0 deletions