From 01fe17fce4135966d6f2467bef4be24523b68a685cd447a166fa8be3608eec5c Mon Sep 17 00:00:00 2001 From: Sebastian Parschauer Date: Thu, 11 Aug 2016 10:30:52 +0000 Subject: [PATCH] Accepting request 417986 from home:sparschauer:branches:Base:System Sync with SLES-12 SP2 for bsc#989751 and bsc#979275 OBS-URL: https://build.opensuse.org/request/show/417986 OBS-URL: https://build.opensuse.org/package/show/Base:System/parted?expand=0&rev=123 --- libparted-Add-support-for-NVMe-devices.patch | 8 +- ...he-device-RO-and-lazily-switch-to-RW.patch | 80 +++++++++++-------- parted.changes | 14 ++++ 3 files changed, 65 insertions(+), 37 deletions(-) diff --git a/libparted-Add-support-for-NVMe-devices.patch b/libparted-Add-support-for-NVMe-devices.patch index 9529a55..7ee9586 100644 --- a/libparted-Add-support-for-NVMe-devices.patch +++ b/libparted-Add-support-for-NVMe-devices.patch @@ -50,8 +50,8 @@ Index: parted-3.2/libparted/arch/linux.c #define SCSI_BLK_MAJOR(M) ( \ (M) == SCSI_DISK0_MAJOR \ -@@ -463,6 +464,12 @@ _ensure_read_write (PedDevice *dev) - _flush_cache (dev); +@@ -461,6 +462,12 @@ _ensure_read_write (PedDevice *dev) + return; } +static int @@ -63,7 +63,7 @@ Index: parted-3.2/libparted/arch/linux.c #ifdef ENABLE_DEVICE_MAPPER static int _dm_task_run_wait (struct dm_task *task, uint32_t cookie) -@@ -714,6 +721,8 @@ _device_probe_type (PedDevice* dev) +@@ -712,6 +719,8 @@ _device_probe_type (PedDevice* dev) dev->type = PED_DEVICE_LOOP; } else if (dev_major == MD_MAJOR) { dev->type = PED_DEVICE_MD; @@ -72,7 +72,7 @@ Index: parted-3.2/libparted/arch/linux.c } else { dev->type = PED_DEVICE_UNKNOWN; } -@@ -1473,6 +1482,11 @@ linux_new (const char* path) +@@ -1471,6 +1480,11 @@ linux_new (const char* path) goto error_free_arch_specific; break; diff --git a/libparted-open-the-device-RO-and-lazily-switch-to-RW.patch b/libparted-open-the-device-RO-and-lazily-switch-to-RW.patch index f9b1024..f166edf 100644 --- a/libparted-open-the-device-RO-and-lazily-switch-to-RW.patch +++ b/libparted-open-the-device-RO-and-lazily-switch-to-RW.patch @@ -4,6 +4,11 @@ Date: Thu, 26 May 2016 09:28:21 +0200 Subject: [PATCH] libparted: open the device RO and lazily switch to RW only if necessary +[sparschauer: Use _flush_cache() also for reads, don't switch to RW + in _flush_cache() to avoid a possible recursion (bnc#989751), open + partitions in _flush_cache() O_RDONLY instead of O_WRONLY] +Signed-off-by: Sebastian Parschauer + Avoid useless udev events triggered by opening the device RW for purely read-only operations. @@ -14,11 +19,11 @@ Author: Michael Matz libparted/arch/linux.h | 1 + 2 files changed, 31 insertions(+), 3 deletions(-) -diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c -index 326b956..0a50452 100644 ---- a/libparted/arch/linux.c -+++ b/libparted/arch/linux.c -@@ -294,6 +294,9 @@ static unsigned int _device_get_partition_range(PedDevice const* dev); +Index: parted-3.2/libparted/arch/linux.c +=================================================================== +--- parted-3.2.orig/libparted/arch/linux.c ++++ parted-3.2/libparted/arch/linux.c +@@ -295,6 +295,9 @@ static unsigned int _device_get_partitio static int _device_open (PedDevice* dev, int flags); static int _device_open_ro (PedDevice* dev); static int _device_close (PedDevice* dev); @@ -28,7 +33,7 @@ index 326b956..0a50452 100644 static int _read_fd (int fd, char **buf) -@@ -441,6 +444,24 @@ _is_virtblk_major (int major) +@@ -442,6 +445,22 @@ _is_virtblk_major (int major) return _major_type_in_devices (major, "virtblk"); } @@ -46,22 +51,21 @@ index 326b956..0a50452 100644 + + if (!_device_open (dev, RW_MODE)) + return; -+ -+ _flush_cache (dev); +} + #ifdef ENABLE_DEVICE_MAPPER static int _dm_task_run_wait (struct dm_task *task, uint32_t cookie) -@@ -1604,6 +1625,7 @@ _flush_cache (PedDevice* dev) - - if (dev->read_only) - return; -+ _ensure_read_write (dev); - dev->dirty = 0; - - ioctl (arch_specific->fd, BLKFLSBUF); -@@ -1647,7 +1669,7 @@ _device_open_ro (PedDevice* dev) +@@ -1603,7 +1622,7 @@ _flush_cache (PedDevice* dev) + if (!name) + break; + if (!_partition_is_mounted_by_path (name)) { +- fd = open (name, WR_MODE, 0); ++ fd = open (name, RD_MODE, 0); + if (fd > 0) { + ioctl (fd, BLKFLSBUF); + retry: +@@ -1634,7 +1653,7 @@ _device_open_ro (PedDevice* dev) static int linux_open (PedDevice* dev) { @@ -70,7 +74,7 @@ index 326b956..0a50452 100644 } static int -@@ -1685,10 +1707,12 @@ retry: +@@ -1672,6 +1691,10 @@ retry: } } else { dev->read_only = 0; @@ -80,12 +84,8 @@ index 326b956..0a50452 100644 + arch_specific->rw = 0; } -- _flush_cache (dev); -- - return 1; - } - -@@ -1920,6 +1944,7 @@ _write_lastoddsector (PedDevice* dev, const void* buffer) + _flush_cache (dev); +@@ -1907,6 +1930,7 @@ _write_lastoddsector (PedDevice* dev, co PED_ASSERT(dev != NULL); PED_ASSERT(buffer != NULL); @@ -93,15 +93,17 @@ index 326b956..0a50452 100644 arch_specific = LINUX_SPECIFIC (dev); -@@ -1968,6 +1993,7 @@ linux_write (PedDevice* dev, const void* buffer, PedSector start, +@@ -1955,6 +1979,9 @@ linux_write (PedDevice* dev, const void* return 1; } + _ensure_read_write (dev); ++ if (count == 0) ++ return 1; /* We just ensured the device is open RW (see call from dasd_write()) */ if (_get_linux_version() < KERNEL_VERSION (2,6,0)) { /* Kludge. This is necessary to read/write the last block of an odd-sized disk, until Linux 2.5.x kernel fixes. -@@ -2497,6 +2523,7 @@ _blkpg_part_command (PedDevice* dev, struct blkpg_partition* part, int op) +@@ -2480,6 +2507,7 @@ _blkpg_part_command (PedDevice* dev, str LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev); struct blkpg_ioctl_arg ioctl_arg; @@ -109,10 +111,10 @@ index 326b956..0a50452 100644 ioctl_arg.op = op; ioctl_arg.flags = 0; ioctl_arg.datalen = sizeof (struct blkpg_partition); -diff --git a/libparted/arch/linux.h b/libparted/arch/linux.h -index 95def1f..926f7e2 100644 ---- a/libparted/arch/linux.h -+++ b/libparted/arch/linux.h +Index: parted-3.2/libparted/arch/linux.h +=================================================================== +--- parted-3.2.orig/libparted/arch/linux.h ++++ parted-3.2/libparted/arch/linux.h @@ -30,6 +30,7 @@ struct _LinuxSpecific { int fd; int major; @@ -121,6 +123,18 @@ index 95def1f..926f7e2 100644 char* dmtype; /**< device map target type */ #if defined __s390__ || defined __s390x__ unsigned int real_sector_size; --- -1.8.4.5 - +Index: parted-3.2/libparted/labels/dasd.c +=================================================================== +--- parted-3.2.orig/libparted/labels/dasd.c ++++ parted-3.2/libparted/labels/dasd.c +@@ -639,6 +639,10 @@ dasd_write (const PedDisk* disk) + if (disk_specific->format_type == 1) + return 1; + ++ /* Ensure the device is open RW */ ++ char dummy[10]; /* to avoid assertion in ped_device_write */ ++ ped_device_write(disk->dev, &dummy, 0, 0); ++ + /* initialize the anchor */ + fdasd_initialize_anchor(&anchor); + fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd); diff --git a/parted.changes b/parted.changes index 69d7f50..9b92b58 100644 --- a/parted.changes +++ b/parted.changes @@ -1,3 +1,17 @@ +------------------------------------------------------------------- +Tue Aug 9 14:36:20 CEST 2016 - sparschauer@suse.de + +- Sync with SLES-12 SP2 for bsc#979275 + - amend: libparted-open-the-device-RO-and-lazily-switch-to-RW.patch + +------------------------------------------------------------------- +Tue Aug 9 14:04:47 CEST 2016 - sparschauer@suse.de + +- Correctly flush caches before reading from the device + (bsc#989751) + - amend: libparted-open-the-device-RO-and-lazily-switch-to-RW.patch + - refresh: libparted-Add-support-for-NVMe-devices.patch + ------------------------------------------------------------------- Sat Jun 18 07:08:01 UTC 2016 - jengelh@inai.de