Skip to content

Commit f6dc45c

Browse files
author
Chris Mason
committed
Btrfs: fix filemap_flush call in btrfs_file_release
We should only be flushing on close if the file was flagged as needing it during truncate. I broke this with my ordered data vs transaction commit deadlock fix. Thanks to Miao Xie for catching this. Signed-off-by: Chris Mason <clm@fb.com> Reported-by: Miao Xie <miaox@cn.fujitsu.com> Reported-by: Fengguang Wu <fengguang.wu@intel.com>
1 parent 38c1c2e commit f6dc45c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎fs/btrfs/file.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1840,7 +1840,15 @@ int btrfs_release_file(struct inode *inode, struct file *filp)
18401840
{
18411841
if (filp->private_data)
18421842
btrfs_ioctl_trans_end(filp);
1843-
filemap_flush(inode->i_mapping);
1843+
/*
1844+
* ordered_data_close is set by settattr when we are about to truncate
1845+
* a file from a non-zero size to a zero size. This tries to
1846+
* flush down new bytes that may have been written if the
1847+
* application were using truncate to replace a file in place.
1848+
*/
1849+
if (test_and_clear_bit(BTRFS_INODE_ORDERED_DATA_CLOSE,
1850+
&BTRFS_I(inode)->runtime_flags))
1851+
filemap_flush(inode->i_mapping);
18441852
return 0;
18451853
}
18461854

0 commit comments

Comments
 (0)