95 lines
3.1 KiB
Diff
95 lines
3.1 KiB
Diff
|
From a8dc525bdab612551a5859b8a8bd2b944a259766 Mon Sep 17 00:00:00 2001
|
||
|
From: Joel Granados Moreno <jgranado@redhat.com>
|
||
|
Date: Mon, 31 Aug 2009 13:44:02 +0200
|
||
|
Subject: [PATCH 3/3] Dont touch part nodes
|
||
|
|
||
|
---
|
||
|
libparted/arch/linux.c | 47 ++++++++++++++++++++++++++++++++---------------
|
||
|
1 files changed, 32 insertions(+), 15 deletions(-)
|
||
|
|
||
|
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
|
||
|
index e47030f..1d4fc7e 100644
|
||
|
--- a/libparted/arch/linux.c
|
||
|
+++ b/libparted/arch/linux.c
|
||
|
@@ -586,6 +586,19 @@ _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;
|
||
|
+}
|
||
|
+
|
||
|
static void
|
||
|
_device_set_sector_size (PedDevice* dev)
|
||
|
{
|
||
|
@@ -1354,8 +1367,8 @@ linux_is_busy (PedDevice* dev)
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
-/* we need to flush the master device, and all the partition devices,
|
||
|
- * because there is no coherency between the caches.
|
||
|
+/* 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 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
|
||
|
@@ -1373,21 +1386,23 @@ _flush_cache (PedDevice* dev)
|
||
|
|
||
|
ioctl (arch_specific->fd, BLKFLSBUF);
|
||
|
|
||
|
- for (i = 1; i < 16; i++) {
|
||
|
- char* name;
|
||
|
- int fd;
|
||
|
+ if (!_have_kern26()) {
|
||
|
+ for (i = 1; i < 16; i++) {
|
||
|
+ char* name;
|
||
|
+ int fd;
|
||
|
|
||
|
- name = _device_get_part_path (dev, i);
|
||
|
- if (!name)
|
||
|
- break;
|
||
|
- if (!_partition_is_mounted_by_path (name)) {
|
||
|
- fd = open (name, WR_MODE, 0);
|
||
|
- if (fd > 0) {
|
||
|
- ioctl (fd, BLKFLSBUF);
|
||
|
- close (fd);
|
||
|
+ name = _device_get_part_path (dev, i);
|
||
|
+ if (!name)
|
||
|
+ break;
|
||
|
+ if (!_partition_is_mounted_by_path (name)) {
|
||
|
+ fd = open (name, WR_MODE, 0);
|
||
|
+ if (fd > 0) {
|
||
|
+ ioctl (fd, BLKFLSBUF);
|
||
|
+ close (fd);
|
||
|
+ }
|
||
|
}
|
||
|
+ free (name);
|
||
|
}
|
||
|
- free (name);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@@ -1428,7 +1443,9 @@ retry:
|
||
|
dev->read_only = 0;
|
||
|
}
|
||
|
|
||
|
- _flush_cache (dev);
|
||
|
+ /* With kernels < 2.6 flush cache for cache coherence issues */
|
||
|
+ if (!_have_kern26())
|
||
|
+ _flush_cache (dev);
|
||
|
|
||
|
return 1;
|
||
|
}
|
||
|
--
|
||
|
1.6.4
|
||
|
|