Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f6dc45c7 authored by Chris Mason's avatar Chris Mason
Browse files

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: default avatarChris Mason <clm@fb.com>
Reported-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
Reported-by: default avatarFengguang Wu <fengguang.wu@intel.com>
parent 38c1c2e4
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -1840,6 +1840,14 @@ int btrfs_release_file(struct inode *inode, struct file *filp)
{
	if (filp->private_data)
		btrfs_ioctl_trans_end(filp);
	/*
	 * ordered_data_close is set by settattr when we are about to truncate
	 * a file from a non-zero size to a zero size.  This tries to
	 * flush down new bytes that may have been written if the
	 * application were using truncate to replace a file in place.
	 */
	if (test_and_clear_bit(BTRFS_INODE_ORDERED_DATA_CLOSE,
			       &BTRFS_I(inode)->runtime_flags))
			filemap_flush(inode->i_mapping);
	return 0;
}