[parted-devel] [PATCH] libparted: Fixed bug in initializing and re-reading partition table of FBA devices
Nageswara R Sastry
rnsastry at linux.vnet.ibm.com
Fri Oct 25 05:45:50 UTC 2013
Subject: [PATCH] libparted: Fixed bug in initializing and re-reading partition
table of FBA devices
From: Nageswara R Sastry <rnsastry at linux.vnet.ibm.com>
Fixed Block Access (FBA) DASDs are mainframe-specific disk devices
that are layred 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 fixes the initialization of FBA DASD. For re-reading of FBA
partitions used the old BLKRRPART IOCTL. With the current blk_pg
IOCTL more hacking is required to re-read partitions from FBA devices.
* libparted/arch/linux.c (_disk_sync_part_table): For FBA devices
added BLKRRPART IOCTL to re-read kernel partition
* libparted/labels/dasd.c (dasd_alloc): For FBA devices corrected the
initialization.
Signed-off-by: Nageswara R Sastry <rnsastry at linux.vnet.ibm.com>
---
libparted/arch/linux.c | 31 +++++++++++++++++++++++++++++++
libparted/labels/dasd.c | 16 +++++++++++++---
2 files changed, 44 insertions(+), 3 deletions(-)
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2669,6 +2669,37 @@ _disk_sync_part_table (PedDisk* disk)
ret = 1;
free (bad_part_list);
}
+ /* For FBA kind of devices it is required to re-read the partitions
+ when this is not done the implicit partition is not identified by
+ the kernel and device node is not created. */
+
+ #if defined __s390__ || defined __s390x__
+ LinuxSpecific* arch_specific = LINUX_SPECIFIC (disk->dev);
+ int retry_count = 5;
+
+ if (disk->dev->type == PED_DEVICE_DASD && lpn == 1) {
+ sync();
+ while (ioctl (arch_specific->fd, BLKRRPART)) {
+ retry_count--;
+ sync();
+ if (!retry_count) {
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_IGNORE,
+ _("WARNING: the kernel failed to re-read the "
+ "partition table on %s (%s). As a result, it"
+ " may not reflect all of your changes until "
+ "after reboot."),
+ disk->dev->path, strerror (errno));
+ ret = 0;
+ goto cleanup;
+
+ }
+ }
+ ret = 1;
+ }
+ #endif
+
cleanup:
free (errnums);
free (ok);
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -150,9 +150,19 @@ dasd_alloc (const PedDevice* dev)
return NULL;
}
- /* CDL format, newer */
- disk_specific->format_type = 2;
- disk_specific->label_block = 2;
+ /* Correct assignment is required to pass the correct values
+ according to the disk type. For FBA disk values are '1'
+ and for CDL formatted disk values are '2'*/
+ struct fdasd_anchor anchor;
+ fdasd_initialize_anchor(&anchor);
+ fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd);
+ if (anchor.FBA_layout == 1) {
+ disk_specific->format_type = 1;
+ disk_specific->label_block = 1;
+ }else{
+ disk_specific->label_block = 2;
+ disk_specific->format_type = 2;
+ }
/* Setup volume label (for fresh disks) */
snprintf(volser, sizeof(volser), "0X%04X", arch_specific->devno);
More information about the parted-devel
mailing list