[kernel/f16] Add patch to invalidate parent cache when fsync is called on a partition

Josh Boyer jwboyer at fedoraproject.org
Wed Jan 25 23:06:05 UTC 2012


commit 8f7167dc2950e1a8c6a4b00e6dd3c1d70d6fd1fb
Author: Josh Boyer <jwboyer at redhat.com>
Date:   Wed Jan 25 17:08:55 2012 -0500

    Add patch to invalidate parent cache when fsync is called on a partition
    
      (rhbz 783211)

 ...rent-block-device-if-fsync-called-on-part.patch |  106 ++++++++++++++++++++
 kernel.spec                                        |   12 ++-
 2 files changed, 117 insertions(+), 1 deletions(-)
---
diff --git a/fs-Inval-cache-for-parent-block-device-if-fsync-called-on-part.patch b/fs-Inval-cache-for-parent-block-device-if-fsync-called-on-part.patch
new file mode 100644
index 0000000..5bab4f4
--- /dev/null
+++ b/fs-Inval-cache-for-parent-block-device-if-fsync-called-on-part.patch
@@ -0,0 +1,106 @@
+Path: news.gmane.org!not-for-mail
+From: Niels de Vos <ndevos at redhat.com>
+Newsgroups: gmane.linux.kernel,gmane.linux.file-systems
+Subject: [PATCH v2] fs: Invalidate the cache for a parent block-device if fsync() is called for a partition
+Date: Mon, 23 Jan 2012 10:38:29 +0000
+Lines: 58
+Approved: news at gmane.org
+Message-ID: <1327315109-7740-1-git-send-email-ndevos at redhat.com>
+References: <4F19356E.3020708 at redhat.com>
+NNTP-Posting-Host: lo.gmane.org
+X-Trace: dough.gmane.org 1327315263 30652 80.91.229.12 (23 Jan 2012 10:41:03 GMT)
+X-Complaints-To: usenet at dough.gmane.org
+NNTP-Posting-Date: Mon, 23 Jan 2012 10:41:03 +0000 (UTC)
+Cc: linux-kernel at vger.kernel.org, Niels de Vos <ndevos at redhat.com>,
+	"Bryn M. Reeves" <bmr at redhat.com>,
+	Mikulas Patocka <mpatocka at redhat.com>
+To: linux-fsdevel at vger.kernel.org
+Original-X-From: linux-kernel-owner at vger.kernel.org Mon Jan 23 11:40:58 2012
+Return-path: <linux-kernel-owner at vger.kernel.org>
+Envelope-to: glk-linux-kernel-3 at lo.gmane.org
+Original-Received: from vger.kernel.org ([209.132.180.67])
+	by lo.gmane.org with esmtp (Exim 4.69)
+	(envelope-from <linux-kernel-owner at vger.kernel.org>)
+	id 1RpHKb-0008Bu-Fh
+	for glk-linux-kernel-3 at lo.gmane.org; Mon, 23 Jan 2012 11:40:57 +0100
+Original-Received: (majordomo at vger.kernel.org) by vger.kernel.org via listexpand
+	id S1753263Ab2AWKkt (ORCPT <rfc822;glk-linux-kernel-3 at m.gmane.org>);
+	Mon, 23 Jan 2012 05:40:49 -0500
+Original-Received: from mx1.redhat.com ([209.132.183.28]:58739 "EHLO mx1.redhat.com"
+	rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
+	id S1751990Ab2AWKks (ORCPT <rfc822;linux-kernel at vger.kernel.org>);
+	Mon, 23 Jan 2012 05:40:48 -0500
+Original-Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25])
+	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0NAelMx027033
+	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
+	Mon, 23 Jan 2012 05:40:47 -0500
+Original-Received: from ndevos.usersys.redhat.com (dhcp-1-51.fab.redhat.com [10.33.1.51])
+	by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q0NAejLn013691;
+	Mon, 23 Jan 2012 05:40:46 -0500
+In-Reply-To: <4F19356E.3020708 at redhat.com>
+X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25
+Original-Sender: linux-kernel-owner at vger.kernel.org
+Precedence: bulk
+List-ID: <linux-kernel.vger.kernel.org>
+X-Mailing-List: linux-kernel at vger.kernel.org
+Xref: news.gmane.org gmane.linux.kernel:1242432 gmane.linux.file-systems:60751
+Archived-At: <http://permalink.gmane.org/gmane.linux.kernel/1242432>
+
+Executing an fsync() on a file-descriptor of a partition flushes the
+caches for that partition by calling blkdev_issue_flush(). However, it
+seems that reading data through the parent device will still return the
+old cached data.
+
+The cache for the block-device is not synced if the block-device is kept
+open (due to a mounted partition, for example). Only when all users for
+the disk have exited, the cache for the disk is made consistent again.
+
+Calling invalidate_bdev() on the parent block-device in case
+blkdev_fsync() was called for a partition, fixes this.
+
+The problem can be worked around by forcing the caches to be flushed
+with either
+	# blockdev --flushbufs ${dev_disk}
+or
+	# echo 3 > /proc/sys/vm/drop_caches
+
+CC: Bryn M. Reeves <bmr at redhat.com>
+CC: Mikulas Patocka <mpatocka at redhat.com>
+Signed-off-by: Niels de Vos <ndevos at redhat.com>
+
+---
+v2:
+- Do not call invalidate_bdev() from blkdev_issue_flush() and prevent
+  performance degration with journalled filesystems.
+
+  Suggested was to call invalidate_bdev() in fsync_bdev(), but this is
+  not in the call-path of mkfs.ext3 and similar tools. Hence the issue
+  persists.
+
+- Correct phrasing a little, changing ioctl-BLKFLSBUF is not required.
+
+- This issue also occurs when doing an ioctl-BLKFLSBUF on a partition.
+  Reading the whole disk will still return cached data. If this is an
+  issue, it will need a seperate patch.
+---
+ fs/block_dev.c |    4 ++++
+ 1 files changed, 4 insertions(+), 0 deletions(-)
+
+diff --git a/fs/block_dev.c b/fs/block_dev.c
+index 0e575d1..433c4de 100644
+--- a/fs/block_dev.c
++++ b/fs/block_dev.c
+@@ -424,6 +424,10 @@ int blkdev_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
+ 	if (error == -EOPNOTSUPP)
+ 		error = 0;
+ 
++	/* invalidate parent block_device */
++	if (!error && bdev != bdev->bd_contains)
++		invalidate_bdev(bdev->bd_contains);
++
+ 	return error;
+ }
+ EXPORT_SYMBOL(blkdev_fsync);
+-- 
+1.7.6.5
+
diff --git a/kernel.spec b/kernel.spec
index f5ea9bd..d6207a7 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -797,6 +797,9 @@ Patch21084: proc-fix-null-pointer-deref-in-proc_pid_permission.patch
 #rhbz 782681
 Patch21085: proc-clean-up-and-fix-proc-pid-mem-handling.patch
 
+#rhbz 783211
+Patch21087: fs-Inval-cache-for-parent-block-device-if-fsync-called-on-part.patch
+
 #rhbz 771058
 Patch22100: msi-irq-sysfs-warning.patch
 
@@ -823,7 +826,6 @@ Patch21230: rds-Make-rds_sock_lock-BH-rather-than-IRQ-safe.patch
 
 Patch22000: rcu-reintroduce-missing-calls.patch
 
-
 # compat-wireless patches
 Patch50000: compat-wireless-config-fixups.patch
 Patch50001: compat-wireless-pr_fmt-warning-avoidance.patch
@@ -834,6 +836,7 @@ Patch50100: compat-wireless-rtl8192cu-Fix-WARNING-on-suspend-resume.patch
 # Remove overlapping hardware support between b43 and brcmsmac
 Patch50101: b43-add-option-to-avoid-duplicating-device-support-w.patch
 
+
 %endif
 
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root
@@ -1535,6 +1538,9 @@ ApplyPatch rcu-reintroduce-missing-calls.patch
 #rhbz 718790
 ApplyPatch rds-Make-rds_sock_lock-BH-rather-than-IRQ-safe.patch
 
+#rhbz 783211
+ApplyPatch fs-Inval-cache-for-parent-block-device-if-fsync-called-on-part.patch
+
 # END OF PATCH APPLICATIONS
 
 %endif
@@ -2306,6 +2312,10 @@ fi
 # and build.
 
 %changelog
+* Wed Jan 25 2012 Josh Boyer <jwboyer at redhat.com>
+- Add patch to invalidate parent cache when fsync is called on a partition 
+  (rhbz 783211)
+
 * Wed Jan 25 2012 John W. Linville <linville at redhat.com>
 - modpost: add option to allow external modules to avoid taint
 - Make integrated compat-wireless take advantage of the above


More information about the scm-commits mailing list