All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Mason <clm@fb.com>
To: <miaox@cn.fujitsu.com>, <dsterba@suse.cz>,
	Fengguang Wu <fengguang.wu@intel.com>,
	Dave Hansen <dave.hansen@intel.com>,
	LKML <linux-kernel@vger.kernel.org>, <lkp@01.org>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>,
	Abhay Sachan <lkp.abhay@gmail.com>
Subject: [PATCH] Btrfs: fix filemap_flush call in btrfs_file_release
Date: Wed, 20 Aug 2014 10:48:53 -0400	[thread overview]
Message-ID: <53F4B555.7060403@fb.com> (raw)
In-Reply-To: <53F47E07.3080807@cn.fujitsu.com>


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>

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;
 }
 

WARNING: multiple messages have this Message-ID (diff)
From: Chris Mason <clm@fb.com>
To: lkp@lists.01.org
Subject: [PATCH] Btrfs: fix filemap_flush call in btrfs_file_release
Date: Wed, 20 Aug 2014 10:48:53 -0400	[thread overview]
Message-ID: <53F4B555.7060403@fb.com> (raw)
In-Reply-To: <53F47E07.3080807@cn.fujitsu.com>

[-- Attachment #1: Type: text/plain, Size: 1103 bytes --]


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>

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;
 }
 

  parent reply	other threads:[~2014-08-20 14:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-16  7:52 [btrfs] 4c468fd7485: +7.8% blogbench.write_score, -5.1% turbostat.Pkg_W Fengguang Wu
2014-08-16  7:52 ` Fengguang Wu
     [not found] ` <CAKHchJwQcH326Z8otiaXtKoKs6fH9s+e9BqJDi=H1bWKiuybAw@mail.gmail.com>
2014-08-16 13:10   ` Fengguang Wu
2014-08-16 13:10     ` Fengguang Wu
2014-08-19 11:58 ` [btrfs] 8d875f95: xfstests.generic.226.fail Fengguang Wu
2014-08-19 11:58   ` Fengguang Wu
2014-08-19 14:23   ` David Sterba
2014-08-19 14:23     ` David Sterba
2014-08-19 14:58     ` Chris Mason
2014-08-19 14:58       ` Chris Mason
2014-08-20 10:52       ` Miao Xie
2014-08-20 10:52         ` Miao Xie
2014-08-20 14:07         ` Chris Mason
2014-08-20 14:07           ` Chris Mason
2014-08-20 14:48         ` Chris Mason [this message]
2014-08-20 14:48           ` [PATCH] Btrfs: fix filemap_flush call in btrfs_file_release Chris Mason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53F4B555.7060403@fb.com \
    --to=clm@fb.com \
    --cc=dave.hansen@intel.com \
    --cc=dsterba@suse.cz \
    --cc=fengguang.wu@intel.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp.abhay@gmail.com \
    --cc=lkp@01.org \
    --cc=miaox@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.