diff --git a/libparted-canonicalize-dev-md-paths.patch b/libparted-canonicalize-dev-md-paths.patch new file mode 100644 index 0000000..8b21a94 --- /dev/null +++ b/libparted-canonicalize-dev-md-paths.patch @@ -0,0 +1,36 @@ +From: Sebastian Parschauer +Date: Mon, 19 Feb 2018 17:45:32 +0100 +Subject: libparted: Canonicalize /dev/md/ paths +References: bsc#1078820 +Patch-mainline: submitted, 2018-02-20 + +The BLKPG* ioctl handling relies on getting the current partitions +from /sys/block/$devname/. With an md name like e.g. "vol0", the +block device to be used cannot be found and the BLKPG* ioctls are +used for all partitions. So canonicalize /dev/md/ paths as well. + +Test: t6100-mdraid-partitions + +Signed-off-by: Sebastian Parschauer +--- + libparted/device.c | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +diff --git a/libparted/device.c b/libparted/device.c +index 36fecd2..2fd3c2f 100644 +--- a/libparted/device.c ++++ b/libparted/device.c +@@ -152,11 +152,8 @@ ped_device_get (const char* path) + char* normal_path = NULL; + + PED_ASSERT (path != NULL); +- /* Don't canonicalize /dev/mapper or /dev/md/ paths, see +- tests/symlink.c +- */ +- if (strncmp (path, "/dev/mapper/", 12) && +- strncmp (path, "/dev/md/", 8)) ++ /* Don't canonicalize /dev/mapper/ paths. */ ++ if (strncmp (path, "/dev/mapper/", 12)) + normal_path = canonicalize_file_name (path); + if (!normal_path) + /* Well, maybe it is just that the file does not exist. diff --git a/libparted-fix-NVDIMM-partition-naming.patch b/libparted-fix-NVDIMM-partition-naming.patch index ada00df..78848f7 100644 --- a/libparted-fix-NVDIMM-partition-naming.patch +++ b/libparted-fix-NVDIMM-partition-naming.patch @@ -5,13 +5,19 @@ References: bsc#1064446 Patch-mainline: no, required to fix custom SUSE device naming Signed-off-by: Sebastian Parschauer +--- + libparted/arch/linux.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index 1aef651..cf6c754 100644 --- a/libparted/arch/linux.c +++ b/libparted/arch/linux.c -@@ -2437,6 +2437,7 @@ _device_get_part_path (PedDevice const * - const char *p; - if (dev->type == PED_DEVICE_CPQARRAY || - dev->type == PED_DEVICE_NVME || -+ dev->type == PED_DEVICE_PMEM || - dev->type == PED_DEVICE_SDMMC) - p = "p"; - else if (dev->type == PED_DEVICE_DM) +@@ -2439,6 +2439,7 @@ _device_get_part_path (PedDevice const *dev, int num) + dev->type == PED_DEVICE_CPQARRAY || + dev->type == PED_DEVICE_DAC960 || + dev->type == PED_DEVICE_NVME || ++ dev->type == PED_DEVICE_PMEM || + dev->type == PED_DEVICE_SDMMC) + p = "p"; + else if (dev->type == PED_DEVICE_DM) diff --git a/libparted-fix-nvme-partition-naming.patch b/libparted-fix-nvme-partition-naming.patch index eeeaa9d..43e3bc3 100644 --- a/libparted-fix-nvme-partition-naming.patch +++ b/libparted-fix-nvme-partition-naming.patch @@ -3,18 +3,18 @@ Subject: libparted: Fix NVMe device naming References: bsc#982169 Patch-mainline: no, required to fix custom SUSE device naming --- - libparted/arch/linux.c | 1 + + libparted/arch/linux.c | 1 + 1 file changed, 1 insertion(+) -Index: parted-3.2/libparted/arch/linux.c -=================================================================== ---- parted-3.2.orig/libparted/arch/linux.c -+++ parted-3.2/libparted/arch/linux.c -@@ -2411,6 +2411,7 @@ _device_get_part_path (PedDevice const * - } else { - const char *p; - if (dev->type == PED_DEVICE_CPQARRAY || -+ dev->type == PED_DEVICE_NVME || - dev->type == PED_DEVICE_SDMMC) - p = "p"; - else if (dev->type == PED_DEVICE_DM) +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index e9a694e..69176c6 100644 +--- a/libparted/arch/linux.c ++++ b/libparted/arch/linux.c +@@ -2414,6 +2414,7 @@ _device_get_part_path (PedDevice const *dev, int num) + if (dev->type == PED_DEVICE_ATARAID || + dev->type == PED_DEVICE_CPQARRAY || + dev->type == PED_DEVICE_DAC960 || ++ dev->type == PED_DEVICE_NVME || + dev->type == PED_DEVICE_SDMMC) + p = "p"; + else if (dev->type == PED_DEVICE_DM) diff --git a/libparted-partition-naming.patch b/libparted-partition-naming.patch index b7d2795..c4f433b 100644 --- a/libparted-partition-naming.patch +++ b/libparted-partition-naming.patch @@ -3,46 +3,49 @@ Subject: libparted: Change partition naming for SUSE needs References: bsc#1056508 Patch-mainline: no, custom SUSE patch -Device mapper partitions should always use the suffix "-part%d" -for partition names. CPQ arrays and SDMMC devices should always -use the "p%d" suffix. DAC960, ATARAID, and devices with a trailing -number in their name should always use the "_part%d" suffix. -All other devices should use the "%d" suffix. +Device mapper partitions always use the suffix "-part%d" for +partition names. Other devices with a trailing number in their +name use the "p%d" suffix. All other devices use the "%d" suffix. YaST depends on this. [mwilck: Fixed dm part name in _dm_add_partition(), bsc#1056508] [sparschauer: Fixed dm part name in _dm_resize_partition(), bsc#1056508] [sparschauer: Wrote the patch description] +[sparschauer: Dropped "_part" suffix, bsc#1078820, bsc#1081547] Signed-off-by: Sebastian Parschauer --- - libparted/arch/linux.c | 14 ++++++++++---- - 1 file changed, 10 insertions(+), 4 deletions(-) + libparted/arch/linux.c | 20 +++++++++++++------- + 1 file changed, 13 insertions(+), 7 deletions(-) +diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c +index 0f18904..cad5159 100644 --- a/libparted/arch/linux.c +++ b/libparted/arch/linux.c -@@ -2342,11 +2342,17 @@ _device_get_part_path (PedDevice const * +@@ -2342,11 +2342,17 @@ _device_get_part_path (PedDevice const *dev, int num) result = zasprintf ("%.*s/part%d", (int) (path_len - 5), devpath, num); } else { - char const *p = (dev->type == PED_DEVICE_DAC960 - || dev->type == PED_DEVICE_CPQARRAY -+ const char *p; -+ if (dev->type == PED_DEVICE_CPQARRAY || -+ dev->type == PED_DEVICE_SDMMC) -+ p = "p"; -+ else if (dev->type == PED_DEVICE_DM) -+ p = "-part"; -+ else -+ p = (dev->type == PED_DEVICE_DAC960 - || dev->type == PED_DEVICE_ATARAID - || isdigit (devpath[path_len - 1]) +- || dev->type == PED_DEVICE_ATARAID +- || isdigit (devpath[path_len - 1]) - ? "p" : ""); -+ ? "_part" : ""); ++ const char *p; ++ if (dev->type == PED_DEVICE_ATARAID || ++ dev->type == PED_DEVICE_CPQARRAY || ++ dev->type == PED_DEVICE_DAC960 || ++ dev->type == PED_DEVICE_SDMMC) ++ p = "p"; ++ else if (dev->type == PED_DEVICE_DM) ++ p = "-part"; ++ else ++ p = (isdigit (devpath[path_len - 1]) ++ ? "p" : ""); result = zasprintf ("%s%s%d", devpath, p, num); } if (dev->type == PED_DEVICE_DM) -@@ -2797,7 +2803,7 @@ _dm_add_partition (PedDisk* disk, const +@@ -2797,7 +2803,7 @@ _dm_add_partition (PedDisk* disk, const PedPartition* part) size_t name_len = strlen (dev_name); vol_name = zasprintf ("%s%s%d", dev_name, @@ -51,7 +54,7 @@ Signed-off-by: Sebastian Parschauer part->num); if (vol_name == NULL) goto err; -@@ -2870,7 +2876,7 @@ _dm_resize_partition (PedDisk* disk, con +@@ -2870,7 +2876,7 @@ _dm_resize_partition (PedDisk* disk, const PedPartition* part) size_t name_len = strlen (dev_name); vol_name = zasprintf ("%s%s%d", dev_name, diff --git a/parted.changes b/parted.changes index 2767b58..c2321ee 100644 --- a/parted.changes +++ b/parted.changes @@ -1,3 +1,23 @@ +------------------------------------------------------------------- +Tue Feb 20 15:11:35 UTC 2018 - sparschauer@suse.de + +- libparted: Canonicalize /dev/md/ paths (bsc#1078820) + - add: libparted-canonicalize-dev-md-paths.patch + - add: tests-add-helper-require_swap_.patch + - add: tests-add-dev-md-check-to-t6100.patch + +------------------------------------------------------------------- +Mon Feb 19 16:01:51 UTC 2018 - sparschauer@suse.de + +- libparted: Fix partition device naming for all devices + (bsc#1078820, bsc#1081547) + - The "_part%d" suffix which has been used for SLE10 compatibility + is wrong now as the kernel does not use that any more and + uses "p%d" instead. + - amend: libparted-partition-naming.patch + - refresh: libparted-fix-nvme-partition-naming.patch + - refresh: libparted-fix-NVDIMM-partition-naming.patch + ------------------------------------------------------------------- Fri Jan 26 15:22:20 UTC 2018 - sparschauer@suse.de diff --git a/parted.spec b/parted.spec index 6b62a0c..7b778e4 100644 --- a/parted.spec +++ b/parted.spec @@ -86,6 +86,7 @@ Patch57: parted-escape-printed-device-path.patch Patch58: parted-add-ignore-busy-option.patch Patch59: parted-fix-resizepart-and-rm-command.patch Patch60: libparted-use-BLKRRPART-only-when-needed.patch +Patch61: libparted-canonicalize-dev-md-paths.patch # Fatresize Patch100: parted-fatresize-autoconf.patch Patch101: fatresize-fix-getting-dev-name.patch @@ -96,6 +97,9 @@ Patch152: tests-use-wait_for_dev_to_-functions.patch Patch153: tests-wait_for_-loop.patch Patch154: tests-update-t0220-t0280-for-swap-flag.patch Patch155: tests-check-extended-partition-length.patch +Patch156: tests-add-helper-require_swap_.patch +Patch157: tests-add-dev-md-check-to-t6100.patch + # SUSE tests patches Patch200: tests-adapt-to-SUSE.patch BuildRequires: check-devel @@ -196,6 +200,7 @@ to develop applications that require these. %patch58 -p1 %patch59 -p1 %patch60 -p1 +%patch61 -p1 %patch100 -p1 %patch101 -p1 %patch150 -p1 @@ -204,6 +209,8 @@ to develop applications that require these. %patch153 -p1 %patch154 -p1 %patch155 -p1 +%patch156 -p1 +%patch157 -p1 %patch200 -p1 %build diff --git a/tests-add-dev-md-check-to-t6100.patch b/tests-add-dev-md-check-to-t6100.patch new file mode 100644 index 0000000..3862f9d --- /dev/null +++ b/tests-add-dev-md-check-to-t6100.patch @@ -0,0 +1,116 @@ +From: Sebastian Parschauer +Date: Tue, 20 Feb 2018 12:16:26 +0100 +Subject: tests: Add /dev/md/ check to t6100 +For: libparted-canonicalize-dev-md-paths.patch +References: bsc#1078820 +Patch-mainline: submitted, 2018-02-20 + +The test t6100 checks creating two partitions with /dev/md99 and +a gpt disk label. But using an md name with the symlink in /dev/md/ +is not tested. That path might not be canonicalized and the BLKPG* +handling cannot find the existing partitions in /sys/block/$dev/. +That can be observed when creating the second partition while the +first one is in use. + +So move common code to new functions create_mddev() and +remove_mdparts(), check if the swap tools are available, retest with +/dev/md/pedtest99, msdos disk label, and the first partition as swap. + +Signed-off-by: Sebastian Parschauer +--- + tests/t6100-mdraid-partitions.sh | 62 +++++++++++++++++++++++++++++++++++----- + 1 file changed, 55 insertions(+), 7 deletions(-) + +diff --git a/tests/t6100-mdraid-partitions.sh b/tests/t6100-mdraid-partitions.sh +index dbb1686..b471f56 100755 +--- a/tests/t6100-mdraid-partitions.sh ++++ b/tests/t6100-mdraid-partitions.sh +@@ -21,6 +21,7 @@ + require_root_ + require_scsi_debug_module_ + require_mdadm_ ++require_swap_ + + # create memory-backed device + scsi_debug_setup_ dev_size_mb=10 > dev-name || +@@ -40,13 +41,27 @@ parted -s "$scsi_dev" mklabel gpt \ + compare /dev/null out || fail=1 + wait_for_dev_to_appear_ ${scsi_dev}2 || { fail=1; cat /proc/partitions; } + ++create_mddev() { ++ # create mdraid on top of both partitions ++ mdadm -C $md_dev --force -R -l1 -n2 "${scsi_dev}1" "${scsi_dev}2" ++} ++ + cleanup_fn_() { + # stop mdraid array + mdadm -S $md_dev || warn_ "Failed to stop MD array, $md_dev" + } + +-# create mdraid on top of both partitions +-mdadm -C $md_dev --force -R -l1 -n2 "${scsi_dev}1" "${scsi_dev}2" ++remove_mdparts() { ++ # Remove partitions from the raid device. ++ parted -s $md_dev rm 2 rm 1 > out 2>&1 || fail=1 ++ compare /dev/null out || fail=1 ++ ++ # Verify that kernel has been informed about those removals. ++ wait_for_dev_to_disappear_ ${md_dev}p1 2 || { fail=1; cat /proc/partitions; } ++ wait_for_dev_to_disappear_ ${md_dev}p2 2 || { fail=1; cat /proc/partitions; } ++} ++ ++create_mddev + + # create gpt and two partitions on the raid device + parted -s $md_dev mklabel gpt \ +@@ -57,12 +72,45 @@ compare /dev/null out || fail=1 + # Verify that kernel has been informed about the second device. + wait_for_dev_to_appear_ ${md_dev}p2 || { fail=1; cat /proc/partitions; } + +-# Remove partitions from the raid device. +-parted -s $md_dev rm 2 rm 1 > out 2>&1 || fail=1 ++remove_mdparts ++ ++######################################################################## ++# Second part with /dev/md/ symlink, msdos label and busy swap partition ++ ++cleanup_fn_ ++ ++# Arbitrary name, not likely to be used already ++md_name=pedtest99 ++md_dev=/dev/md/$md_name ++ ++test -b $md_dev && skip_ "$md_dev already exists" ++ ++create_mddev ++ ++# create msdos and one partition on the raid device ++parted -s $md_dev mklabel msdos \ ++ mkpart primary ext2 1M 2M > out 2>&1 || fail=1 ++compare /dev/null out || fail=1 ++ ++# Verify that kernel has been informed about the device. ++wait_for_dev_to_appear_ ${md_dev}p1 || { fail=1; cat /proc/partitions; } ++ ++# Create swap filesystem ++mkswap -f ${md_dev}p1 || fail=1 ++ ++# Use as swap to make it busy ++swapon ${md_dev}p1 || fail=1 ++ ++# create msdos and one partition on the raid device ++parted -s $md_dev mkpart primary ext2 2M 3M > out 2>&1 || fail=1 + compare /dev/null out || fail=1 + +-# Verify that kernel has been informed about those removals. +-wait_for_dev_to_disappear_ ${md_dev}p1 2 || { fail=1; cat /proc/partitions; } +-wait_for_dev_to_disappear_ ${md_dev}p2 2 || { fail=1; cat /proc/partitions; } ++# Verify that kernel has been informed about the second device. ++wait_for_dev_to_appear_ ${md_dev}p2 || { fail=1; cat /proc/partitions; } ++ ++# Disable swap again ++swapoff ${md_dev}p1 || warn_ "Failed to disable swap on ${md_dev}p1" ++ ++remove_mdparts + + Exit $fail diff --git a/tests-add-helper-require_swap_.patch b/tests-add-helper-require_swap_.patch new file mode 100644 index 0000000..8d305b2 --- /dev/null +++ b/tests-add-helper-require_swap_.patch @@ -0,0 +1,32 @@ +From: Sebastian Parschauer +Date: Tue, 20 Feb 2018 12:30:23 +0100 +Subject: tests: Add helper 'require_swap_' +For: libparted-canonicalize-dev-md-paths.patch +References: bsc#1078820 +Patch-mainline: submitted, 2018-02-20 + +To achieve that a partition is busy, it is easiest to use it as swap +partition. So check if mkswap, swapon, and swapoff are available. + +Signed-off-by: Sebastian Parschauer +--- + tests/t-lib-helpers.sh | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/tests/t-lib-helpers.sh b/tests/t-lib-helpers.sh +index 9312343..962b4f1 100644 +--- a/tests/t-lib-helpers.sh ++++ b/tests/t-lib-helpers.sh +@@ -362,6 +362,12 @@ require_xfs_() + mkfs.xfs -V || skip_ "this test requires XFS support" + } + ++require_swap_() ++{ ++ mkswap -V && swapon -V && swapoff -V || \ ++ skip_ "this test requires swap support" ++} ++ + require_dvhtool_() + { + dvhtool --help \