s390-tools/s390-tools-sles15sp3-Format-devices-in-parallel.patch
Nikolay Gueorguiev 089c94ca65 Accepting request 1093105 from home:ngueorguiev:branches:Base:System
- Upgrade to version 2.27.0 (jsc#PED-3275)
- Changes of existing tools:
  * s390-tools cross-compile and non-s390x support:
    - pkg-config is now mandatory for the build process
    - Add PKG_CONFIG Makefile variable to select pkg-config program;
      default pkg-config or $(CROSS_COMPILE)pkg-config if
      CROSS_COMPILE is set
    - Rename Makefile variable ARCH to HOST_ARCH. HOST_ARCH is the
      architecture that will run the produced (executable) objects
    - Add the Makefile variable BUILD_ARCH. BUILD_ARCH is the
      architecture of the build system. For each Makefile variable like
      CC, LINK, CPP, ... there is a suffixed version of it - e.g.
      CC_FOR_BUILD. This is useful for cross compiling, and this naming
      convention is very similar to the Meson convention (see
      https://mesonbuild.com/Reference-tables.html#environment-variables-per-machine).
    - Limit build targets for non-s390x architectures (pvattest)
  * dasdfmt: Fall back to full format if space release fails
  * dbginfo.sh: Add nstat for network and SNMP stats
  * dbginfo.sh: Rework crypto data collection
  * hyptop: Show thread util by default
  * zipl: Add support for list-directed IPL dump from ECKD DASD
- Bug Fixes:
  * lszcrypt: Fix argument parsing
  * zdev/dracut: Fix out-of-memory (OOM) situations in the kdump crashkernel environment
  * ziomon/ziorep_config: Fix for SCSI devices of type disk without block dev
  * pvextract-hdr: Fix parsing issues on little-endian systems
- Amended the .patches to fit the 2.27 version
- Removed obsolete patches (the fixes are included in this version)
  * s390-tools-sles15sp5-zipl-boot-disable-Warray-bounds-for-now.patch
  * s390-tools-sles15sp5-zkey-Support-EP11-host-library-version-4.patch
  * s390-tools-sles15sp5-01-zipl-boot-discard-.eh_frame-and-.interp-input-sectio.patch
  * s390-tools-sles15sp5-02-zipl-boot-declare-that-no-executable-stack-is-requir.patch
  * s390-tools-sles15sp5-03-zipl-boot-use-no-warn-rwx-segments-linker-flag.patch
  * s390-tools-sles15sp5-04-zipl-boot-disable-build-id.patch
  * s390-tools-sles15sp5-05-zipl-boot-simplify-objcopy-commands.patch
  * s390-tools-sles15sp5-06-zipl-move-STAGE2_MAX_SIZE-and-STAGE1B_LOAD_ADDR-to-l.patch
  * s390-tools-sles15sp5-07-zipl-boot-use-linker-scripts-for-all-bootloaders.patch
  * s390-tools-sles15sp5-08-genprotimg-boot-declare-that-no-executable-stack-is-.patch
  * s390-tools-sles15sp5-09-genprotimg-boot-use-no-warn-rwx-segments-linker-flag.patch
  * s390-tools-sles15sp5-10-genprotimg-boot-disable-build-id.patch
  * s390-tools-sles15sp5-11-genprotimg-boot-Makefile-simplify-objcopy-command.patch
  * s390-tools-sles15sp5-12-genprotimg-boot-improve-linker-scripts.patch
  * s390-tools-sles15sp5-13-genprotimg-boot-stage3b-add-size-check-to-the-linker.patch
  * s390-tools-sles15sp5-14-genprotimg-boot-stage3b_reloc.bin-add-linker-script.patch
  * s390-tools-sles15sp5-15-zipl-Embed-loader-data-directly-into-boot-object.patch
  * s390-tools-sles15sp5-lszcrypt-use-separate-index-for-inner-sub-device-loo.patch
  * s390-tools-sles15sp5-01-ziomon-ziorep_config-fix-missing-SG-major-minor-for-.patch
  * s390-tools-sles15sp5-02-ziomon-ziorep_config-fix-for-SCSI-devices-of-type-di.patch
  * s390-tools-sles15sp5-fix-chown-commands-syntax.patch

OBS-URL: https://build.opensuse.org/request/show/1093105
OBS-URL: https://build.opensuse.org/package/show/Base:System/s390-tools?expand=0&rev=174
2023-06-14 11:34:58 +00:00

177 lines
5.0 KiB
Diff

From a61154fd93122f5a0f2b74f21c3ac29eb437f150 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Fri, 6 Oct 2017 09:39:36 +0200
Subject: [PATCH] dasdfmt: Format devices in parallel
Allow dasdfmt to run in parallel when several devices are specified.
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
dasdfmt/dasdfmt.8 | 16 +++++++++++++-
dasdfmt/dasdfmt.c | 58 ++++++++++++++++++++++++++++++++++++++++++------------
2 files changed, 60 insertions(+), 14 deletions(-)
--- a/dasdfmt/dasdfmt.8
+++ b/dasdfmt/dasdfmt.8
@@ -7,7 +7,7 @@
dasdfmt \- formatting of DASD (ECKD) disk drives.
.SH SYNOPSIS
-\fBdasdfmt\fR [-h] [-t] [-v] [-y] [-p] [-P] [-m \fIstep\fR]
+\fBdasdfmt\fR [-h] [-t] [-v] [-y] [-p] [-Q] [-P] [-m \fIstep\fR]
.br
[-r \fIcylinder\fR] [-b \fIblksize\fR] [-l \fIvolser\fR] [-d \fIlayout\fR]
.br
@@ -96,7 +96,7 @@
running in background or redirecting the output to a file.
.TP
-\fB-P\fR or \fB--percentage\fR
+\fB-Q\fR or \fB--percentage\fR
Print one line for each formatted cylinder showing the number of the
cylinder and percentage of formatting process.
Intended to be used by higher level interfaces.
@@ -164,6 +164,18 @@
and always be a power of two. The recommended blocksize is 4096 bytes.
.TP
+\fB-P\fR \fInumdisks\fR or \fB--max_parallel\fR=\fInumdisks\fR
+Specify the number of disks to be formatted in parallel.
+\fInumdisks\fR specifies the number of formatting processed,
+independent on the overall number of disks to be formatted.
+The maximum value for \fInumdisks\fR is 512. Default is 1.
+.br
+Using this option can decrease overall processing time when formatting
+several disks. Please note that the I/O throughput will dramatically
+increase when using this option. Use with care.
+.br
+
+.TP
\fB-l\fR \fIvolser\fR or \fB--label\fR=\fIvolser\fR
Specify the volume serial number or volume identifier to be written
to disk after formatting. If no label is specified, a sensible default
--- a/dasdfmt/dasdfmt.c
+++ b/dasdfmt/dasdfmt.c
@@ -13,6 +13,7 @@
#include <sys/sysmacros.h>
#include <sys/time.h>
#include <sys/utsname.h>
+#include <sys/wait.h>
#include "lib/dasd_base.h"
#include "lib/dasd_sys.h"
@@ -81,6 +82,7 @@
int mode_specified;
int ese;
int no_discard;
+ int procnum;
} g = {
.dasd_info = { 0 },
};
@@ -105,6 +107,11 @@
.desc = "Perform complete format check on device",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
+ {
+ .option = { "max_parallel", required_argument, NULL, 'P' },
+ .desc = "Format devices in parallel",
+ .flags = UTIL_OPT_FLAG_NOLONG,
+ },
UTIL_OPT_SECTION("FORMAT OPTIONS"),
{
.option = { "blocksize", required_argument, NULL, 'b' },
@@ -162,7 +169,7 @@
.desc = "Show a progressbar",
},
{
- .option = { "percentage", no_argument, NULL, 'P' },
+ .option = { "percentage", no_argument, NULL, 'Q' },
.desc = "Show progress in percent",
},
UTIL_OPT_SECTION("MISC"),
@@ -311,7 +318,7 @@
}
if (g.print_hashmarks && (cyl / g.hashstep - hashcount) != 0) {
- printf("#");
+ printf("%d|", g.procnum);
fflush(stdout);
hashcount++;
}
@@ -1573,7 +1580,11 @@
char *reqsize_param_str = NULL;
char *hashstep_str = NULL;
- int rc, numdev = 0, i;
+ int rc, numdev = 0, numproc = 0, status;
+ int max_parallel =1 ;
+ int running = 0;
+ int chpid;
+ int tmp;
/* Establish a handler for interrupt signals. */
signal(SIGTERM, program_interrupt_signal);
@@ -1636,7 +1647,7 @@
g.print_hashmarks = 1;
}
break;
- case 'P':
+ case 'Q':
if (!(g.print_hashmarks || g.print_progressbar))
g.print_percentage = 1;
break;
@@ -1695,6 +1706,9 @@
case OPT_NODISCARD:
g.no_discard = 1;
break;
+ case 'P':
+ max_parallel = atoi(optarg);
+ break;
case OPT_CHECK:
g.check = 1;
break;
@@ -1746,15 +1760,35 @@
if (numdev > 1 && g.labelspec)
error("Specifying a volser to be written doesn't make sense when formatting multiple DASD volumes.");
- for (i = 0; i < numdev; i++)
- {
- strncpy(g.dev_path, g.dev_path_array[i], strlen(g.dev_path_array[i])+1);
- strncpy(g.dev_node, g.dev_node_array[i], strlen(g.dev_node_array[i])+1);
- process_dasd(&vlabel, format_params);
+ for (numproc = 0; numproc < numdev; numproc++) {
+ chpid = fork();
+ if (chpid == -1 )
+ ERRMSG_EXIT(EXIT_FAILURE,
+ "%s: Unable to create child process: %s\n",
+ prog_name, strerror(errno));
+ if (!chpid) {
+ g.procnum = numproc;
+ strncpy(g.dev_path, g.dev_path_array[numproc], strlen(g.dev_path_array[numproc])+1);
+ strncpy(g.dev_node, g.dev_node_array[numproc], strlen(g.dev_node_array[numproc])+1);
+ process_dasd(&vlabel, format_params);
+
+ free(g.dev_path);
+ free(g.dev_node);
+ exit(0);
+ } else {
+ running++;
+ if (running >= max_parallel) {
+ if (wait(&tmp) > 0 && WEXITSTATUS(tmp))
+ rc = WEXITSTATUS(tmp);
+ running--;
+ }
+ }
}
- free(g.dev_path);
- free(g.dev_node);
+ /* wait until all formatting children have finished */
+ while(wait(&status) > 0)
+ if (WEXITSTATUS(status))
+ rc = WEXITSTATUS(status);
- return 0;
+ return rc;
}