]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix wrong lock range and write size in check_can_nocow()
authorMiao Xie <miaox@cn.fujitsu.com>
Thu, 27 Feb 2014 05:58:04 +0000 (13:58 +0800)
committerJosef Bacik <jbacik@fb.com>
Mon, 10 Mar 2014 19:17:00 +0000 (15:17 -0400)
commit08f629af1b18723480845751a7f6c2813336ce78
tree0417dba0c65787ad3de69f92563e1824086706a6
parentad0c4f8f0b6f6c66e0d0f828d5d24a0de8a592eb
Btrfs: fix wrong lock range and write size in check_can_nocow()

The write range may not be sector-aligned, for example:

       |--------|--------| <- write range, sector-unaligned, size: 2blocks
  |--------|--------|--------|  <- correct lock range, size: 3blocks

But according to the old code, we used the size of write range to calculate
the lock range directly, not considered the offset, we would get a wrong lock
range:

       |--------|--------| <- write range, sector-unaligned, size: 2blocks
  |--------|--------| <- wrong lock range, size: 2blocks

And besides that, the old code also had the same problem when calculating
the real write size. Correct them.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
fs/btrfs/file.c