• Miao Xie's avatar
    Btrfs: use a lock to protect incompat/compat flag of the super block · ceda0864
    Miao Xie authored
    The following case will make the incompat/compat flag of the super block
    be recovered.
     Task1					|Task2
     flags = btrfs_super_incompat_flags();	|
    					|flags = btrfs_super_incompat_flags();
     flags |= new_flag1;			|
    					|flags |= new_flag2;
     btrfs_set_super_incompat_flags(flags);	|
    					|btrfs_set_super_incompat_flags(flags);
    the new_flag1 is recovered.
    
    In order to avoid this problem, we introduce a lock named super_lock into
    the btrfs_fs_info structure. If we want to update incompat/compat flags
    of the super block, we must hold it.
    Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
    Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
    ceda0864
volumes.c 155 KB