- change partition UUID to use partX-UUID (#858704)

- fixup losetup usage in tests
- add support for implicit FBA DASD partitions (#707027)
- add support for EAV DASD partitions (#707032)
This commit is contained in:
Brian C. Lane 2012-10-16 16:53:14 -07:00
parent 1ca859a3e8
commit 68f2aab138
6 changed files with 1400 additions and 9 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,187 @@
Subject: [PATCH] libparted: add support for implicit FBA DASD partitions
From: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
Fixed Block Access (FBA) DASDs are mainframe-specific disk devices
which are layed out as a sequence of 512-byte sectors. In contrast
to ECKD DASDs, these disks do not require formatting and resemble
the LBA layout of non-mainframe disks. Despite this resemblance,
the Linux kernel applies special handling during partition detection
for FBA DASDs, resulting in a single, immutable partition being
reported.
While actual FBA DASD hardware is no longer available, the z/VM
hypervisor can simulate FBA DASD disks, backed by either ECKD or
SCSI devices.
This patch adds support for recognizing FBA DASD partitions
to parted.
Signed-off-by: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
---
include/parted/fdasd.h | 2 +
libparted/labels/dasd.c | 63 ++++++++++++++++++++++++++++++++++++++++-------
libparted/labels/fdasd.c | 5 +++
3 files changed, 61 insertions(+), 9 deletions(-)
--- a/include/parted/fdasd.h
+++ b/include/parted/fdasd.h
@@ -194,6 +194,8 @@ typedef struct fdasd_anchor {
volume_label_t *vlabel;
config_data_t confdata[USABLE_PARTITIONS];
struct fdasd_hd_geometry geo;
+ unsigned int label_block;
+ unsigned int FBA_layout;
} fdasd_anchor_t;
enum offset {lower, upper};
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -71,6 +71,7 @@ typedef struct {
typedef struct {
unsigned int format_type;
+ unsigned int label_block;
volume_label_t vlabel;
} DasdDiskSpecific;
@@ -151,6 +152,7 @@ dasd_alloc (const PedDevice* dev)
/* CDL format, newer */
disk_specific->format_type = 2;
+ disk_specific->label_block = 2;
/* Setup volume label (for fresh disks) */
snprintf(volser, sizeof(volser), "0X%04X", arch_specific->devno);
@@ -226,7 +228,9 @@ dasd_probe (const PedDevice *dev)
fdasd_check_api_version(&anchor, arch_specific->fd);
- if (fdasd_check_volume(&anchor, arch_specific->fd))
+ /* Labels are required on CDL formatted DASDs. */
+ if (fdasd_check_volume(&anchor, arch_specific->fd) &&
+ anchor.FBA_layout == 0)
goto error_cleanup;
fdasd_cleanup(&anchor);
@@ -273,17 +277,53 @@ dasd_read (PedDisk* disk)
fdasd_initialize_anchor(&anchor);
fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd);
+ disk_specific->label_block = anchor.label_block;
+
+ if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE)
+ anchor.big_disk++;
/* check dasd for labels and vtoc */
- if (fdasd_check_volume(&anchor, arch_specific->fd))
- goto error_close_dev;
+ if (fdasd_check_volume(&anchor, arch_specific->fd)) {
+ DasdPartitionData* dasd_data;
+
+ /* Kernel partitioning code will report 'implicit' partitions
+ * for non-CDL format DASDs even when there is no
+ * label/VTOC. */
+ if (anchor.FBA_layout == 0)
+ goto error_close_dev;
+
+ disk_specific->format_type = 1;
+
+ /* Register implicit partition */
+ ped_disk_delete_all (disk);
+
+ start = (PedSector) arch_specific->real_sector_size /
+ (PedSector) disk->dev->sector_size *
+ (PedSector) (anchor.label_block + 1);
+ end = disk->dev->length - 1;
+ part = ped_partition_new (disk, PED_PARTITION_NORMAL, NULL,
+ start, end);
+ if (!part)
+ goto error_close_dev;
+
+ part->num = 1;
+ part->fs_type = ped_file_system_probe (&part->geom);
+ dasd_data = part->disk_specific;
+ dasd_data->raid = 0;
+ dasd_data->lvm = 0;
+ dasd_data->type = 0;
+
+ if (!ped_disk_add_partition (disk, part, NULL))
+ goto error_close_dev;
+
+ fdasd_cleanup(&anchor);
+
+ return 1;
+ }
/* Save volume label (read by fdasd_check_volume) for writing */
memcpy(&disk_specific->vlabel, anchor.vlabel, sizeof(volume_label_t));
- if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE)
- anchor.big_disk++;
-
ped_disk_delete_all (disk);
bool is_ldl = strncmp(anchor.vlabel->volkey,
@@ -348,7 +388,7 @@ dasd_read (PedDisk* disk)
/ (long long) disk->dev->sector_size
* (long long) (cms_ptr->block_count - 1) - 1;
- part = ped_partition_new (disk, PED_PARTITION_PROTECTED, NULL, start, end);
+ part = ped_partition_new (disk, PED_PARTITION_NORMAL, NULL, start, end);
if (!part)
goto error_close_dev;
@@ -923,7 +963,12 @@ dasd_alloc_metadata (PedDisk* disk)
the start of the first partition */
if (disk_specific->format_type == 1) {
part = ped_disk_get_partition(disk, 1);
- vtoc_end = part->geom.start - 1;
+ if (part)
+ vtoc_end = part->geom.start - 1;
+ else
+ vtoc_end = (PedSector) arch_specific->real_sector_size /
+ (PedSector) disk->dev->sector_size *
+ (PedSector) disk_specific->label_block;
}
else {
if (disk->dev->type == PED_DEVICE_FILE)
@@ -943,7 +988,7 @@ dasd_alloc_metadata (PedDisk* disk)
goto error;
}
- if (disk_specific->format_type == 1) {
+ if (disk_specific->format_type == 1 && part) {
/*
For LDL or CMS there may be trailing metadata as well.
For example: the last block of a CMS reserved file,
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -721,6 +721,7 @@ fdasd_check_volume (fdasd_anchor_t *anc,
unsigned long b = -1;
char str[LINE_LENGTH];
+ memset(v, 0, sizeof(volume_label_t));
vtoc_read_volume_label (fd, anc->label_pos, v);
if (strncmp(v->vollbl, vtoc_ebcdic_enc ("VOL1", str, 4), 4) == 0) {
@@ -800,6 +801,8 @@ fdasd_get_geometry (const PedDevice *dev
dasd_info.dev_type = 13200;
dasd_info.label_block = 2;
dasd_info.devno = 513;
+ dasd_info.label_block = 2;
+ dasd_info.FBA_layout = 0;
} else {
if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0)
fdasd_error(anc, unable_to_ioctl,
@@ -820,6 +823,8 @@ fdasd_get_geometry (const PedDevice *dev
anc->label_pos = dasd_info.label_block * blksize;
anc->devno = dasd_info.devno;
anc->fspace_trk = anc->geo.cylinders * anc->geo.heads - FIRST_USABLE_TRK;
+ anc->label_block = dasd_info.label_block;
+ anc->FBA_layout = dasd_info.FBA_layout;
}
/*

View File

@ -1,16 +1,16 @@
From 399cfc2a9cfc60a46ab9094b4c999bb11a36033e Mon Sep 17 00:00:00 2001
From: Fedora Ninjas <parted-owner@fedoraproject.org>
From e2b9f9051c8d9905b15af0f7fa79c85502370b25 Mon Sep 17 00:00:00 2001
From: Brian C. Lane <bcl@redhat.com>
Date: Fri, 3 Aug 2012 17:03:50 -0700
Subject: [PATCH] libparted: preserve the uuid on dm partitions (#832145)
* libparted/arch/linux.c (_dm_add_partition): Set the uuid if there was
one.
---
libparted/arch/linux.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
libparted/arch/linux.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 37ddb5f..9f0434a 100644
index 37ddb5f..2c410a0 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2803,6 +2803,8 @@ _dm_add_partition (PedDisk* disk, PedPartition* part)
@ -35,7 +35,7 @@ index 37ddb5f..9f0434a 100644
goto err;
+ if ( dev_uuid && (strlen(dev_uuid) > 0) \
+ && ! (vol_uuid = zasprintf ("%sp%d", dev_uuid, part->num)))
+ && ! (vol_uuid = zasprintf ("part%d-%s", part->num, dev_uuid)))
+ goto err;
+
/* Caution: dm_task_destroy frees dev_name. */
@ -67,5 +67,5 @@ index 37ddb5f..9f0434a 100644
return 0;
}
--
1.7.7.6
1.7.11.4

View File

@ -1,5 +1,5 @@
From cc96f793bb4fb088123a40fb9d802e7db1fdbffb Mon Sep 17 00:00:00 2001
From: Fedora Ninjas <parted-owner@fedoraproject.org>
From: Brian C. Lane <bcl@redhat.com>
Date: Tue, 7 Aug 2012 10:14:03 -0700
Subject: [PATCH] tests: Make sure dm UUIDs are not erased

View File

@ -0,0 +1,137 @@
From a1aa9eb26f357bb1a5111eb332594dfb7b39ace0 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 15 Oct 2012 17:27:18 -0700
Subject: [PATCH 1/2] tests: cleanup losetup usage
The unsafe_losetup_ function was failing because losetup didn't
recognize that the 'private' /dev/loopX devices were the same as
/dev/loopX, it would fail even if one was in use. Switch to using
losetup --show which is a cleaner solution.
Also use sparse file for loop_setup to save space.
---
tests/lvm-utils.sh | 24 ++----------------------
tests/t-lvm.sh | 24 ++----------------------
tests/t6001-psep.sh | 8 ++------
tests/t6003-dm-uuid.sh | 3 +--
4 files changed, 7 insertions(+), 52 deletions(-)
diff --git a/tests/lvm-utils.sh b/tests/lvm-utils.sh
index 456d265..a204b08 100644
--- a/tests/lvm-utils.sh
+++ b/tests/lvm-utils.sh
@@ -16,34 +16,14 @@ export LVM_SUPPRESS_FD_WARNINGS=1
ME=$(basename "$0")
warn() { echo >&2 "$ME: $@"; }
-unsafe_losetup_()
-{
- f=$1
-
- test -n "$G_dev_" \
- || fail_ "Internal error: unsafe_losetup_ called before init_root_dir_"
-
- # Iterate through $G_dev_/loop{,/}{0,1,2,3,4,5,6,7,8,9}
- for slash in '' /; do
- for i in 0 1 2 3 4 5 6 7 8 9; do
- dev=$G_dev_/loop$slash$i
- losetup $dev > /dev/null 2>&1 && continue;
- losetup "$dev" "$f" > /dev/null && { echo "$dev"; return 0; }
- break
- done
- done
-
- return 1
-}
-
loop_setup_()
{
file=$1
- dd if=/dev/zero of="$file" bs=1M count=1 seek=1000 > /dev/null 2>&1 \
+ dd if=/dev/null of="$file" bs=1M count=1 seek=1000 > /dev/null 2>&1 \
|| { warn "loop_setup_ failed: Unable to create tmp file $file"; return 1; }
# NOTE: this requires a new enough version of losetup
- dev=$(unsafe_losetup_ "$file") \
+ dev=$(losetup --show -f "$file") 2>/dev/null \
|| { warn "loop_setup_ failed: Unable to create loopback device"; return 1; }
echo "$dev"
diff --git a/tests/t-lvm.sh b/tests/t-lvm.sh
index b08f934..3c7657b 100644
--- a/tests/t-lvm.sh
+++ b/tests/t-lvm.sh
@@ -16,34 +16,14 @@ export LVM_SUPPRESS_FD_WARNINGS=1
ME=$(basename "$0")
warn() { echo >&2 "$ME: $@"; }
-unsafe_losetup_()
-{
- f=$1
-
- test -n "$G_dev_" \
- || error "Internal error: unsafe_losetup_ called before init_root_dir_"
-
- # Iterate through $G_dev_/loop{,/}{0,1,2,3,4,5,6,7,8,9}
- for slash in '' /; do
- for i in 0 1 2 3 4 5 6 7 8 9; do
- dev=$G_dev_/loop$slash$i
- losetup $dev > /dev/null 2>&1 && continue;
- losetup "$dev" "$f" > /dev/null && { echo "$dev"; return 0; }
- break
- done
- done
-
- return 1
-}
-
loop_setup_()
{
file=$1
- dd if=/dev/zero of="$file" bs=1M count=1 seek=1000 > /dev/null 2>&1 \
+ dd if=/dev/null of="$file" bs=1M count=1 seek=1000 > /dev/null 2>&1 \
|| { warn "loop_setup_ failed: Unable to create tmp file $file"; return 1; }
# NOTE: this requires a new enough version of losetup
- dev=$(unsafe_losetup_ "$file" 2>/dev/null) \
+ dev=$(losetup --show -f "$file") 2>/dev/null \
|| { warn "loop_setup_ failed: Unable to create loopback device"; return 1; }
echo "$dev"
diff --git a/tests/t6001-psep.sh b/tests/t6001-psep.sh
index 490c6d2..1859ac9 100644
--- a/tests/t6001-psep.sh
+++ b/tests/t6001-psep.sh
@@ -44,14 +44,10 @@ cleanup_fn_() {
# create a file of size N bytes
N=10M
-# create the test file
-f1=$(pwd)/1; dd if=/dev/null of=$f1 bs=1 seek=$N 2> /dev/null || fail=1
-f2=$(pwd)/2; dd if=/dev/null of=$f2 bs=1 seek=$N 2> /dev/null || fail=1
-
-d1=$(loop_setup_ "$f1") \
+f1=$(pwd)/1; d1=$(loop_setup_ "$f1") \
|| skip_ "is this partition mounted with 'nodev'?"
-d2=$(loop_setup_ "$f2") \
+f2=$(pwd)/2 ;d2=$(loop_setup_ "$f2") \
|| skip_ "is this partition mounted with 'nodev'?"
dmsetup_cmd="0 `blockdev --getsz $d1` linear $d1 0"
diff --git a/tests/t6003-dm-uuid.sh b/tests/t6003-dm-uuid.sh
index 1751cb4..f58cb06 100755
--- a/tests/t6003-dm-uuid.sh
+++ b/tests/t6003-dm-uuid.sh
@@ -36,8 +36,7 @@ cleanup_() {
}
# create a file large enough to hold a GPT partition table
-dd if=/dev/null of=$loop_file bs=$ss seek=$ns || framework_failure
-dev=$(losetup --show -f $loop_file) || framework_failure
+dev=$(loop_setup_ $loop_file) || framework_failure
dmsetup create $dm_name --table "0 $ns linear $dev 0" || framework_failure
dmsetup rename $dm_name --setuuid f139317b-f98a-45d7-ab3b-9b4e0a336872 || framework_failure
--
1.7.11.4

View File

@ -4,7 +4,7 @@
Summary: The GNU disk partition manipulation program
Name: parted
Version: 3.1
Release: 7%{?dist}
Release: 8%{?dist}
License: GPLv3+
Group: Applications/System
URL: http://www.gnu.org/software/parted
@ -23,6 +23,9 @@ patch6: parted-3.1-test-creating-20-device-mapper-partitions.patch
Patch7: parted-3.1-libparted-preserve-the-uuid-on-dm-partitions.patch
Patch8: parted-3.1-tests-Make-sure-dm-UUIDs-are-not-erased.patch
Patch9: parted-3.1-libparted-reallocate-buf-after-_disk_analyse_block_s.patch
Patch10: parted-3.1-tests-cleanup-losetup-usage.patch
Patch11: parted-3.1-libparted-add-support-for-implicit-FBA-DASD-partitions.patch
Patch12: parted-3.1-libparted-add-support-for-EAV-DASD-partitions.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: e2fsprogs-devel
@ -158,6 +161,12 @@ fi
%changelog
* Tue Oct 16 2012 Brian C. Lane <bcl@redhat.com> 3.1-8
- change partition UUID to use partX-UUID (#858704)
- fixup losetup usage in tests
- add support for implicit FBA DASD partitions (#707027)
- add support for EAV DASD partitions (#707032)
* Tue Sep 04 2012 Brian C. Lane <bcl@redhat.com> 3.1-7
- reallocate buf after _disk_analyse_block_size (#835601)