]> git.hungrycats.org Git - linux/commit
Btrfs: add missing inode item update in fallocate()
authorFilipe Manana <fdmanana@suse.com>
Thu, 12 Mar 2015 23:23:13 +0000 (23:23 +0000)
committerZygo Blaxell <zblaxell@waya.furryterror.org>
Sun, 29 Mar 2015 16:38:04 +0000 (12:38 -0400)
commitaa8693cb691a5c20efef9482bb1e50e88fd5b4a4
treefbaf6ac550df7d48bfae5131e990a78b7d5869cd
parent173daf0c8906c485f5747c30ce602f0e7bb9df44
Btrfs: add missing inode item update in fallocate()

If we fallocate(), without the keep size flag, into an area already covered
by an extent previously fallocated, we were updating the inode's i_size but
we weren't updating the inode item in the fs/subvol tree. A following umount
+ mount would result in a loss of the inode's size (and an fsync would miss
too the fact that the inode changed).

Reproducer:

  $ mkfs.btrfs -f /dev/sdd
  $ mount /dev/sdd /mnt
  $ fallocate -n -l 1M /mnt/foobar
  $ fallocate -l 512K /mnt/foobar
  $ umount /mnt
  $ mount /dev/sdd /mnt
  $ od -t x1 /mnt/foobar
  0000000

The expected result is:

  $ od -t x1 /mnt/foobar
  0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  *
  2000000

A test case for fstests follows soon.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Chris Mason <clm@fb.com>
(cherry picked from commit 3d850dd44889d3aa67d0b8007c2cdd259bff7da4)
fs/btrfs/file.c