• Miao Xie's avatar
    Btrfs: use bit operation for ->fs_state · 87533c47
    Miao Xie authored
    There is no lock to protect fs_info->fs_state, it will introduce
    some problems, such as the value may be covered by the other task
    when several tasks modify it. For example:
    	Task0 - CPU0		Task1 - CPU1
    	mov %fs_state rax
    	or $0x1 rax
    				mov %fs_state rax
    				or $0x2 rax
    	mov rax %fs_state
    				mov rax %fs_state
    The expected value is 3, but in fact, it is 2.
    
    Though this problem doesn't happen now (because there is only one
    flag currently), the code is error prone, if we add other flags,
    the above problem will happen to a certainty.
    
    Now we use bit operation for it to fix the above problem.
    In this way, we can make the code more robust and be easy to
    add new flags.
    Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
    Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
    87533c47
file.c 62.9 KB