• Miao Xie's avatar
    Btrfs: fix the race between write back and nocow buffered write · f1de9683
    Miao Xie authored
    When we ran the 274th case of xfstests with nodatacow mount option,
    We met the following warning message:
    WARNING: CPU: 1 PID: 14185 at fs/btrfs/extent-tree.c:3734 btrfs_free_reserved_data_space+0xa6/0xd0
    
    It is caused by the race between the write back and nocow buffered
    write:
      Task1				Task2
      __btrfs_buffered_write()
        skip data reservation
        reserve the metadata space
        copy the data
        dirty the pages
        unlock the pages
    				write back the pages
    				release the data space
       				  becasue there is no
    				  noreserve flag
       set the noreserve flag
    
    This patch fixes this problem by unlocking the pages after
    the noreserve flag is set.
    Reported-by: default avatarTsutomu Itoh <t-itoh@jp.fujitsu.com>
    Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
    Signed-off-by: default avatarJosef Bacik <jbacik@fb.com>
    Signed-off-by: default avatarChris Mason <clm@fb.com>
    f1de9683
file.c 67.9 KB