[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <53F4B555.7060403@fb.com>
Date: Wed, 20 Aug 2014 10:48:53 -0400
From: Chris Mason <clm@...com>
To: <miaox@...fujitsu.com>, <dsterba@...e.cz>,
Fengguang Wu <fengguang.wu@...el.com>,
Dave Hansen <dave.hansen@...el.com>,
LKML <linux-kernel@...r.kernel.org>, <lkp@...org>,
"linux-btrfs@...r.kernel.org" <linux-btrfs@...r.kernel.org>,
Abhay Sachan <lkp.abhay@...il.com>
Subject: [PATCH] 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@...com>
Reported-by: Miao Xie <miaox@...fujitsu.com>
Reported-by: Fengguang Wu <fengguang.wu@...el.com>
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index f15c13f..36861b7 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;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists