File Revert-linux-commit-do-not-unnecessarily-open-partition.patch of Package parted
From: Phillip Susi <psusi@ubuntu.com>
Date: Sat, 5 Jan 2013 22:59:35 -0500
Subject: Revert "linux-commit: do not unnecessarily open partition
device nodes"
References: bnc#989751
Patch-Mainline: v3.2
Git-commit: fb99ba5ebd0dc34204fc9f1014131d5d494805bc
This reverts commit 2a6936fab4d4499a4b812dd330d3db50549029e0. The commit
disabled flushing the block buffer caches on the partition nodes to ensure
cache consistency on 2.6 kernels, supposedly because this was no longer
required. It appears this was incorrect, and the caches DO still need
flushed, otherwise a new fs written to the partition device does not show
up in the disk device cache, causing parted to still identify the old fs.
[sparschauer: Backport on top of SUSE parted 3.1]
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
NEWS | 5 +++++
libparted/arch/linux.c | 25 +++----------------------
2 files changed, 8 insertions(+), 22 deletions(-)
Index: parted-3.1/NEWS
===================================================================
--- parted-3.1.orig/NEWS
+++ parted-3.1/NEWS
@@ -29,6 +29,11 @@ GNU parted NEWS
** Bug fixes
+ Fix cache coherency issue by flushing partition block devices.
+ This had been mistakenly disabled in parted 2.0, and resulted
+ in parted sometimes identifying the previous filesystem type
+ after running an mkfs to format a partition to a new type.
+
libparted: avoid an invalid free when creating many partitions in
a GPT partition table. [bug introduced in parted-1.9.0]
Index: parted-3.1/libparted/arch/linux.c
===================================================================
--- parted-3.1.orig/libparted/arch/linux.c
+++ parted-3.1/libparted/arch/linux.c
@@ -296,7 +296,6 @@ static int _device_open_ro (PedDevice* d
static int _device_close (PedDevice* dev);
static int linux_close (PedDevice* dev);
static void _flush_cache (PedDevice* dev);
-static int _have_kern26 ();
static int
@@ -659,19 +658,6 @@ _get_linux_version ()
return kver = KERNEL_VERSION (major, minor, teeny);
}
-static int
-_have_kern26 ()
-{
- static int have_kern26 = -1;
- int kver;
-
- if (have_kern26 != -1)
- return have_kern26;
-
- kver = _get_linux_version();
- return have_kern26 = kver >= KERNEL_VERSION (2,6,0) ? 1 : 0;
-}
-
#if USE_BLKID
static void
get_blkid_topology (LinuxSpecific *arch_specific)
@@ -1532,8 +1518,8 @@ linux_is_busy (PedDevice* dev)
return 0;
}
-/* we need to flush the master device, and with kernel < 2.6 all the partition
- * devices, because there is no coherency between the caches with old kernels.
+/* we need to flush the master device, and all the partition devices,
+ * because there is no coherency between the caches.
* We should only flush unmounted partition devices, because:
* - there is never a need to flush them (we're not doing IO there)
* - flushing a device that is mounted causes unnecessary IO, and can
@@ -1551,10 +1537,6 @@ _flush_cache (PedDevice* dev)
ioctl (arch_specific->fd, BLKFLSBUF);
- /* With linux-2.6.0 and newer, we're done. */
- if (_have_kern26())
- return;
-
for (i = 1; i < 16; i++) {
char* name;
int fd;
@@ -1638,9 +1620,7 @@ retry:
arch_specific->rw = 0;
}
- /* With kernels < 2.6 flush cache for cache coherence issues */
- if (!_have_kern26())
- _flush_cache (dev);
+ _flush_cache (dev);
return 1;
}