aboutsummaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorChris Mason <clm@fb.com>2014-08-20 07:15:33 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-09-05 16:36:37 -0700
commita1bbac07b61162c67f5d814db0502b188d3eb30e (patch)
tree4b1856042bf6a24b2d65426d05f77c3e0300f0cf /fs
parentddef1474c305ea0d1cb5a93398db014caf141d64 (diff)
Btrfs: fix filemap_flush call in btrfs_file_release
commit f6dc45c7a93a011dff6eb9b2ffda59c390c7705a upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/file.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index d3afac292d6..ab1fd668020 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1840,7 +1840,15 @@ int btrfs_release_file(struct inode *inode, struct file *filp)
{
if (filp->private_data)
btrfs_ioctl_trans_end(filp);
- filemap_flush(inode->i_mapping);
+ /*
+ * 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;
}