parted/libparted-use-BLKRRPART-only-when-needed.patch
Marcus Meissner 5631eac2bb Accepting request 760713 from home:anicka:branches:Base:System
- fix crash in do_resizepart
  + parted-fix-end_input-usage.patch: Fix end_input usage in
    do_resizepart 

- update to version 3.3, noteworthy changes:
 - s390: Re-enabled virtio-attached DASD heuristics by using
   HDIO_GETGEO when probing device geometry. Fixes a bug with
   KVM virtio-blk backed by a DASD.
   Parted now recognizes NVMe devices, NVDIMM, and RAM drives.
 - Fix atari disklabel false positives by probing other labels first.
 - Fix resizepart to adjust the end to be -1 sector when using iec
   power of 2 units so that the next partition can start immediately
   following the new end, just like mkpart does.
 - Fix set and disk_set to not crash when there are no flags to set.
 - Fix a udev cookie leak when using resizepart on device-mapper devices.
 - Fix a gettext crash/error sometimes when using localized languages.
 - Fix fat resize to preverve boot code, and thus not render the
   filesystem unreconized by Windows.
 - Fix rescue command: the rescue command often failed to find
   filesystems due to leaving on cylinder alignment.
 - libparted-fs-resize: Prevent crash resizing FAT file systems with very
   deep directories with path names over 512 bytes long.
 - Use 512b sector size when communicating with device-mapper. Fixes
   problems with partitions being created too small on dm devices
   with sector sizes > 5121b
 - Don't crash in the disk_set command when a disk label is not found
 - libparted-fs-resize: Prevent crash resizing FAT16 file systems.
 - libparted-fs-resize: Prevent crash resizing FAT16 file systems.
 - If the user specifies start/end of the partition as cylinders
   and a cylinder has a size which is power of 2, then such address

OBS-URL: https://build.opensuse.org/request/show/760713
OBS-URL: https://build.opensuse.org/package/show/Base:System/parted?expand=0&rev=144
2020-01-12 13:40:37 +00:00

110 lines
4.2 KiB
Diff

From: Sebastian Parschauer <sparschauer@suse.de>
Date: Thu, 25 Jan 2018 17:06:00 +0100
Subject: libparted: dasd: Use BLKRRPART only when needed
References: bsc#1065197, bsc#1067435
Patch-mainline: no, upstream dropped proper DASD support
The BLKRRPART ioctl is required due to limitations of the DASD
disk layout. We use it always for those devices right now but when
adding or removing a partition at the end, then it is enough to use
the BLKPG* ioctls. The problem with BLKRRPART occurs when one of the
first partitions is busy. BLKRRPART touches all partitions and the
parted command fails in this case.
So detect that situation and use BLKRRPART only when needed instead.
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
include/parted/disk.in.h | 1 +
libparted/arch/linux.c | 13 +++++++------
libparted/disk.c | 15 +++++++++++++--
3 files changed, 21 insertions(+), 8 deletions(-)
Index: parted-3.3/include/parted/disk.in.h
===================================================================
--- parted-3.3.orig/include/parted/disk.in.h
+++ parted-3.3/include/parted/disk.in.h
@@ -195,6 +195,7 @@ struct _PedDisk {
int update_mode; /**< mode without free/metadata
partitions, for easier
update */
+ int needs_blkrrpart; /* special cases on DASDs */
};
struct _PedDiskOps {
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -3324,15 +3324,15 @@ static int
linux_disk_commit (PedDisk* disk)
{
if (disk->dev->type != PED_DEVICE_FILE) {
-
- /* The ioctl() command BLKPG_ADD_PARTITION does not notify
- * the devfs system; consequently, /proc/partitions will not
- * be up to date, and the proper links in /dev are not
- * created. Therefore, if using DevFS, we must get the kernel
- * to re-read and grok the partition table.
+ /* If adding or removing partitions not at the end, then the
+ * ioctl() command BLKPG_ADD_PARTITION does not notify the
+ * devfs system; consequently, /proc/partitions will not be up
+ * to date, and the proper links in /dev are not created.
+ * Therefore, if using DevFS, we must get the kernel to re-read
+ * and grok the partition table.
*/
/* Work around kernel dasd problem so we really do BLKRRPART */
- if (disk->dev->type == PED_DEVICE_DASD)
+ if (disk->dev->type == PED_DEVICE_DASD && disk->needs_blkrrpart)
return _kernel_reread_part_table(disk->dev);
assert(_have_blkpg());
Index: parted-3.3/libparted/disk.c
===================================================================
--- parted-3.3.orig/libparted/disk.c
+++ parted-3.3/libparted/disk.c
@@ -407,6 +407,7 @@ _ped_disk_alloc (const PedDevice* dev, c
disk->update_mode = 1;
disk->part_list = NULL;
disk->needs_clobber = 0;
+ disk->needs_blkrrpart = 0;
return disk;
error:
@@ -1734,8 +1735,12 @@ _disk_raw_remove (PedDisk* disk, PedPart
if (part->prev) {
part->prev->next = part->next;
- if (part->next)
+ if (part->next) {
+ /* remove partition in the middle */
+ if (part->type == PED_PARTITION_NORMAL)
+ disk->needs_blkrrpart = 1;
part->next->prev = part->prev;
+ }
} else {
if (part->type & PED_PARTITION_LOGICAL) {
ped_disk_extended_partition (disk)->part_list
@@ -1743,8 +1748,12 @@ _disk_raw_remove (PedDisk* disk, PedPart
} else {
disk->part_list = part->next;
}
- if (part->next)
+ if (part->next) {
+ /* remove first partition */
+ if (part->type == PED_PARTITION_NORMAL)
+ disk->needs_blkrrpart = 1;
part->next->prev = NULL;
+ }
}
return 1;
@@ -1774,6 +1783,8 @@ _disk_raw_add (PedDisk* disk, PedPartiti
}
if (walk) {
+ if (part->type == PED_PARTITION_NORMAL)
+ disk->needs_blkrrpart = 1;
return _disk_raw_insert_before (disk, walk, part);
} else {
if (last) {