]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix reported number of inode blocks after buffered append writes
authorFilipe Manana <fdmanana@suse.com>
Sat, 4 Nov 2017 00:16:59 +0000 (00:16 +0000)
committerDavid Sterba <dsterba@suse.com>
Wed, 15 Nov 2017 16:27:46 +0000 (17:27 +0100)
commita60692447b8a308035336e1da584b3919ce14ca3
tree96e5ff78992e66e6eb4e114ca84b2542a61d0bf0
parent87c7b9bc8c932f9555266af8849e94127f4bb54f
Btrfs: fix reported number of inode blocks after buffered append writes

The patch from commit 134792db277c ("Btrfs: fix reported number of inode
blocks") introduced a regression where if we do a buffered write starting
at position equal to or greater than the file's size and then stat(2) the
file before writeback is triggered, the number of used blocks does not
change (unless there's a prealloc/unwritten extent). Example:

  $ xfs_io -f -c "pwrite -S 0xab 0 64K" foobar
  $ du -h foobar
  0 foobar
  $ sync
  $ du -h foobar
  64K foobar

The first version of that patch didn't had this regression and the second
version, which was the one committed, was made only to address some
performance regression detected by the intel test robots using fs_mark.

This fixes the regression by setting the new delaloc bit in the range, and
doing it at btrfs_dirty_pages() while setting the regular dealloc bit as
well, so that this way we set both bits at once avoiding navigation of the
inode's io tree twice. Doing it at btrfs_dirty_pages() is also the most
meaninful place, as we should set the new dellaloc bit when if we set the
delalloc bit, which happens only if we copied bytes into the pages at
__btrfs_buffered_write().

This was making some of LTP's du tests fail, which can be quickly run
using a command line like the following:

  $ ./runltp -q -p -l /ltp.log -f commands -s du -d /mnt

Fixes: 134792db277c ("Btrfs: fix reported number of inode blocks")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/extent_io.h
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/relocation.c
fs/btrfs/tests/extent-io-tests.c
fs/btrfs/tests/inode-tests.c