- Improve DASD label handling; backport following patches

from upstream (bnc#887333):
  - libparted-add-support-for-implicit-FBA-DASD-partition.patch
  - libparted-add-support-for-EAV-DASD-partitions.patch
  - libparted-mklabel-to-support-EAV-DASD.patch
  - libparted-Avoid-dasd-as-default-disk-type-while-probe.patch
  - libparted-mklabel-to-support-EDEV-DASD.patch

OBS-URL: https://build.opensuse.org/package/show/Base:System/parted?expand=0&rev=96
This commit is contained in:
Petr Uzel 2014-07-18 09:34:42 +00:00 committed by Git OBS Bridge
parent 295facd1e7
commit 4f4200ec76
7 changed files with 1567 additions and 0 deletions

View File

@ -0,0 +1,67 @@
From 0673dabee6f5b19317b0d85e399e9f876a2c2ea7 Mon Sep 17 00:00:00 2001
From: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
Date: Wed, 21 Aug 2013 16:37:17 -0700
Subject: [PATCH] libparted: Avoid dasd as default disk type while probe
This patch avoids setting 'dasd' as a default disk type for
'disk image file' at the time of probe.
Signed-off-by: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
---
include/parted/fdasd.in.h | 1 +
libparted/labels/fdasd.c | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/parted/fdasd.in.h b/include/parted/fdasd.in.h
index 3692596..6f6a7e0 100644
--- a/include/parted/fdasd.in.h
+++ b/include/parted/fdasd.in.h
@@ -261,6 +261,7 @@ typedef struct fdasd_anchor {
struct fdasd_hd_geometry geo;
unsigned int label_block;
unsigned int FBA_layout;
+ bool is_file;
} fdasd_anchor_t;
enum offset {lower, upper};
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index b58b2be..7de5f34 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -301,6 +301,7 @@ fdasd_initialize_anchor (fdasd_anchor_t * anc)
}
anc->hw_cylinders = 0;
anc->formatted_cylinders = 0;
+ anc->is_file = 0;
}
/*
@@ -890,7 +891,7 @@ fdasd_check_volume (fdasd_anchor_t *anc, int fd)
/* Some times LDL formatted disks does not
contain any volume label */
return 1;
- } else {
+ } else if (! anc->is_file) {
/* didn't find VOL1 volume label */
anc->formatted_cylinders = anc->hw_cylinders;
anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads
@@ -974,6 +975,7 @@ fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f)
dasd_info.FBA_layout = 0;
anc->hw_cylinders = ((st.st_size / blksize) / anc->geo.sectors) /
anc->geo.heads;
+ anc->is_file = 1;
} else {
if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0)
fdasd_error(anc, unable_to_ioctl,
@@ -995,6 +997,8 @@ fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f)
anc->hw_cylinders = characteristics->long_no_cyl;
else
anc->hw_cylinders = characteristics->no_cyl;
+
+ anc->is_file = 0;
}
anc->dev_type = dasd_info.dev_type;
--
1.8.4.5

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,193 @@
From f70ff1fc474764c3a71318ddb4e0d26afc52ac47 Mon Sep 17 00:00:00 2001
From: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
Date: Wed, 21 Aug 2013 16:09:56 -0700
Subject: [PATCH] libparted: add support for implicit FBA DASD partitions
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.in.h | 2 +
libparted/labels/dasd.c | 63 +++++++++++++++++++++++++++++++++++++++-------
libparted/labels/fdasd.c | 5 +++
3 files changed, 61 insertions(+), 9 deletions(-)
Index: parted-3.1/include/parted/fdasd.in.h
===================================================================
--- parted-3.1.orig/include/parted/fdasd.in.h
+++ parted-3.1/include/parted/fdasd.in.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};
Index: parted-3.1/libparted/labels/dasd.c
===================================================================
--- parted-3.1.orig/libparted/labels/dasd.c
+++ parted-3.1/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;
@@ -926,7 +966,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)
@@ -946,7 +991,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,
Index: parted-3.1/libparted/labels/fdasd.c
===================================================================
--- parted-3.1.orig/libparted/labels/fdasd.c
+++ parted-3.1/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

@ -0,0 +1,159 @@
From 95649fc7d025a68074c8a00581bd24d2bd7751bc Mon Sep 17 00:00:00 2001
From: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
Date: Wed, 21 Aug 2013 16:36:08 -0700
Subject: [PATCH] libparted: mklabel to support EAV DASD
Extended Address Volume (EAV) DASDs are ECKD DASDs with more than
65520 cylinders. This patch adds support for mklabel to properly
handle unformatted EAV DASDs.
Signed-off-by: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
---
include/parted/fdasd.in.h | 1 -
libparted/labels/fdasd.c | 92 +++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 90 insertions(+), 3 deletions(-)
diff --git a/include/parted/fdasd.in.h b/include/parted/fdasd.in.h
index b4e7dd1..3692596 100644
--- a/include/parted/fdasd.in.h
+++ b/include/parted/fdasd.in.h
@@ -288,7 +288,6 @@ void fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int fd);
void fdasd_check_api_version (fdasd_anchor_t *anc, int fd);
int fdasd_check_volume (fdasd_anchor_t *anc, int fd);
int fdasd_write_labels (fdasd_anchor_t *anc, int fd);
-int fdasd_invalid_vtoc_pointer(fdasd_anchor_t *anc);
void fdasd_recreate_vtoc(fdasd_anchor_t *anc);
partition_info_t * fdasd_add_partition (fdasd_anchor_t *anc,
unsigned int start, unsigned int stop);
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index 2735b2a..b58b2be 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -581,6 +581,22 @@ fdasd_recreate_vtoc (fdasd_anchor_t *anc)
anc->vtoc_changed++;
}
+ /*
+ * initialize the VOL1 volume label
+ */
+static void
+fdasd_init_volume_label(fdasd_anchor_t *anc, int fd)
+{
+ volume_label_t *vlabel = anc->vlabel;
+
+ vtoc_volume_label_init(vlabel);
+ vtoc_volume_label_set_key(vlabel, "VOL1");
+ vtoc_volume_label_set_label(vlabel, "VOL1");
+
+ vtoc_set_cchhb(&vlabel->vtoc, VTOC_START_CC, VTOC_START_HH, 0x01);
+}
+
+
/*
* sets some important partition data
* (like used, start_trk, end_trk, len_trk)
@@ -769,6 +785,52 @@ fdasd_process_valid_vtoc (fdasd_anchor_t * anc, unsigned long b, int fd)
fdasd_update_partition_info (anc);
}
+static void
+fdasd_invalid_vtoc_pointer(fdasd_anchor_t *anc)
+{
+ PDEBUG
+ anc->formatted_cylinders = anc->hw_cylinders;
+ anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads
+ - FIRST_USABLE_TRK;
+ vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS,
+ anc->geo.cylinders, anc->formatted_cylinders,
+ anc->geo.heads, anc->geo.sectors,
+ anc->blksize, anc->dev_type);
+
+ vtoc_init_format5_label(anc->f5);
+ vtoc_init_format7_label(anc->f7);
+
+ vtoc_set_freespace(anc->f4, anc->f5, anc->f7, '+', anc->verbose,
+ FIRST_USABLE_TRK,
+ anc->formatted_cylinders * anc->geo.heads - 1,
+ anc->formatted_cylinders, anc->geo.heads);
+
+ vtoc_set_cchhb(&anc->vlabel->vtoc, VTOC_START_CC, VTOC_START_HH, 0x01);
+}
+
+/*
+ * we have a invalid FMT4 DSCB and therefore we will re-create the VTOC
+ */
+static void
+fdasd_process_invalid_vtoc(fdasd_anchor_t *anc)
+{
+ anc->formatted_cylinders = anc->hw_cylinders;
+ anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads
+ - FIRST_USABLE_TRK;
+ vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS,
+ anc->geo.cylinders, anc->formatted_cylinders,
+ anc->geo.heads, anc->geo.sectors,
+ anc->blksize, anc->dev_type);
+
+ vtoc_init_format5_label(anc->f5);
+ vtoc_init_format7_label(anc->f7);
+ vtoc_set_freespace(anc->f4, anc->f5, anc->f7, '+', anc->verbose,
+ FIRST_USABLE_TRK,
+ anc->formatted_cylinders * anc->geo.heads - 1,
+ anc->formatted_cylinders, anc->geo.heads);
+}
+
+
static int
fdasd_valid_vtoc_pointer(fdasd_anchor_t *anc, unsigned long b, int fd)
{
@@ -781,6 +843,8 @@ fdasd_valid_vtoc_pointer(fdasd_anchor_t *anc, unsigned long b, int fd)
if (anc->f4->DS4IDFMT == 0xf4) {
fdasd_process_valid_vtoc (anc, b, fd);
return 0;
+ } else {
+ fdasd_process_invalid_vtoc(anc);
}
if (strncmp(anc->vlabel->volkey, vtoc_ebcdic_enc("LNX1",str,4),4) == 0 ||
strncmp(anc->vlabel->volkey, vtoc_ebcdic_enc("CMS1",str,4),4) == 0)
@@ -817,13 +881,37 @@ fdasd_check_volume (fdasd_anchor_t *anc, int fd)
else
return 0;
} else {
- return 1;
+ fdasd_invalid_vtoc_pointer(anc);
}
} else if (strncmp (v->volkey, vtoc_ebcdic_enc ("LNX1", str, 4), 4) == 0 ||
strncmp (v->volkey, vtoc_ebcdic_enc ("CMS1", str, 4), 4) == 0) {
return 0;
- }
+ } else if (anc->FBA_layout == 1) {
+ /* Some times LDL formatted disks does not
+ contain any volume label */
+ return 1;
+ } else {
+ /* didn't find VOL1 volume label */
+ anc->formatted_cylinders = anc->hw_cylinders;
+ anc->fspace_trk = anc->formatted_cylinders * anc->geo.heads
+ - FIRST_USABLE_TRK;
+
+ fdasd_init_volume_label(anc, fd);
+ vtoc_init_format4_label(anc->f4, USABLE_PARTITIONS,
+ anc->geo.cylinders, anc->formatted_cylinders,
+ anc->geo.heads, anc->geo.sectors,
+ anc->blksize, anc->dev_type);
+
+ vtoc_init_format5_label(anc->f5);
+ vtoc_init_format7_label(anc->f7);
+
+ vtoc_set_freespace(anc->f4, anc->f5, anc->f7, '+',
+ anc->verbose, FIRST_USABLE_TRK,
+ anc->formatted_cylinders * anc->geo.heads - 1,
+ anc->formatted_cylinders, anc->geo.heads);
+ return 0;
+ }
return 1;
}
--
1.8.4.5

View File

@ -0,0 +1,56 @@
From bdb439f660344404f27084c48fe7b9429436b9e9 Mon Sep 17 00:00:00 2001
From: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
Date: Wed, 21 Aug 2013 16:37:17 -0700
Subject: [PATCH] libparted: mklabel to support EDEV DASD
Fixed Block Access (FBA) DASDs are mainframe-specific disk devices
which are layed out as a sequence of 512-byte sectors. This patch adds
support for mklabel to properly handle FBA devices.
Signed-off-by: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
---
libparted/labels/fdasd.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index 7de5f34..1f87937 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -870,19 +870,21 @@ fdasd_check_volume (fdasd_anchor_t *anc, int fd)
vtoc_read_volume_label (fd, anc->label_pos, v);
if (strncmp(v->vollbl, vtoc_ebcdic_enc ("VOL1", str, 4), 4) == 0) {
- /* found VOL1 volume label */
- b = (cchhb2blk (&v->vtoc, &anc->geo) - 1) * anc->blksize;
-
- if (b > 0) {
- int rc;
- rc = fdasd_valid_vtoc_pointer (anc, b, fd);
-
- if (rc < 0)
- return 1;
- else
- return 0;
- } else {
- fdasd_invalid_vtoc_pointer(anc);
+ if (anc->FBA_layout != 1 ) {
+ /* found VOL1 volume label */
+ b = (cchhb2blk (&v->vtoc, &anc->geo) - 1) * anc->blksize;
+
+ if (b > 0) {
+ int rc;
+ rc = fdasd_valid_vtoc_pointer (anc, b, fd);
+
+ if (rc < 0)
+ return 1;
+ else
+ return 0;
+ } else {
+ fdasd_invalid_vtoc_pointer(anc);
+ }
}
} else if (strncmp (v->volkey, vtoc_ebcdic_enc ("LNX1", str, 4), 4) == 0 ||
strncmp (v->volkey, vtoc_ebcdic_enc ("CMS1", str, 4), 4) == 0) {
--
1.8.4.5

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Wed Jul 16 13:14:09 UTC 2014 - puzel@suse.com
- Improve DASD label handling; backport following patches
from upstream (bnc#887333):
- libparted-add-support-for-implicit-FBA-DASD-partition.patch
- libparted-add-support-for-EAV-DASD-partitions.patch
- libparted-mklabel-to-support-EAV-DASD.patch
- libparted-Avoid-dasd-as-default-disk-type-while-probe.patch
- libparted-mklabel-to-support-EDEV-DASD.patch
-------------------------------------------------------------------
Thu May 29 12:55:29 UTC 2014 - puzel@suse.com

View File

@ -59,6 +59,11 @@ Patch31: libparted-use-BLKRRPART-for-DASD.patch.patch
Patch32: libparted-copy-pmbr_boot-when-duplicating-GPT-disk.patch
Patch33: Fix-help-text-for-disk_-set-toggle.patch
Patch34: libparted-allow-bigger-snap-radius-if-cylinders-are-used.patch
Patch35: libparted-add-support-for-implicit-FBA-DASD-partition.patch
Patch36: libparted-add-support-for-EAV-DASD-partitions.patch
Patch37: libparted-mklabel-to-support-EAV-DASD.patch
Patch38: libparted-Avoid-dasd-as-default-disk-type-while-probe.patch
Patch39: libparted-mklabel-to-support-EDEV-DASD.patch
Patch100: parted-fatresize-autoconf.patch
Requires: /sbin/udevadm
BuildRequires: check-devel
@ -140,6 +145,11 @@ to develop applications that require these.
%patch32 -p1
%patch33 -p1
%patch34 -p1
%patch35 -p1
%patch36 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1
%patch100 -p1
%build