Zhao Lei b5282220fd btrfs: Continue write in case of can_not_nocow
[ Upstream commit 4da2e26a2a32b174878744bd0f07db180c875f26 ]

btrfs failed in xfstests btrfs/080 with -o nodatacow.

Can be reproduced by following script:
  DEV=/dev/vdg
  MNT=/mnt/tmp

  umount $DEV &>/dev/null
  mkfs.btrfs -f $DEV
  mount -o nodatacow $DEV $MNT

  dd if=/dev/zero of=$MNT/test bs=1 count=2048 &
  btrfs subvolume snapshot -r $MNT $MNT/test_snap &
  wait
  --
  We can see dd failed on NO_SPACE.

Reason:
  __btrfs_buffered_write should run cow write when no_cow impossible,
  and current code is designed with above logic.
  But check_can_nocow() have 2 type of return value(0 and <0) on
  can_not_no_cow, and current code only continue write on first case,
  the second case happened in doing subvolume.

Fix:
  Continue write when check_can_nocow() return 0 and <0.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-15 08:27:47 +02:00
..
2016-08-10 11:49:27 +02:00
2015-06-30 19:44:57 -07:00
2016-03-03 15:07:12 -08:00
2016-08-20 18:09:20 +02:00
2015-11-13 20:34:33 -05:00
2015-11-23 21:11:08 -05:00
2016-07-27 09:47:31 -07:00
2015-11-10 12:07:22 -08:00
2015-11-16 23:54:45 -08:00
2015-11-16 23:54:45 -08:00
2015-08-12 15:28:45 -05:00
2016-08-10 11:49:27 +02:00
2016-05-18 17:06:48 -07:00
2016-07-27 09:47:30 -07:00
2016-09-07 08:32:43 +02:00
2015-11-13 20:34:33 -05:00