SHA256
1
0
forked from pool/mdadm
mdadm/0057-util-Introduce-md_get_array_info.patch
Neil Brown 849a39cd07 Accepting request 548207 from home:colyli:branches:Base:System
- Update mdadm for SLE15, for bug fixes and new feature enhancement
- 1000-The-mdcheck-script-now-adds-messages-to-the-system.patch is
  removed because upstream has similar fix with almost identical
  funcationality.
- The following patches are not deleted indeed, they are renamed
  and added into all other new-added patches with different perfix
  numbers,
  0038-Create-Fixup-bad-placement-of-logical-in-multi-line-.patch
  0039-Create-Fixup-various-whitespace-issues.patch
  0040-mdadm.c-fix-compile-warning-mdfd-is-uninitialized.patch
  0041-mdopen-use-parameters-new_array-to-create-arrays-whe.patch
  0042-mdadm-manpage-update-manpage-for-readonly-parameter.patch
  0043-mdadm-manpage-clustered-arrays-don-t-support-array-s.patch
  0044-maps-Terminate-modes-map-correctly.patch
  0045-Grow_continue_command-ensure-content-is-properly-ini.patch
  0046-systemd-mdadm-last-resort-use-ConditionPathExists-in.patch
  0047-Detail-ensure-export-names-are-acceptable-as-shell-v.patch
  0048-Grow-set-component-size-prior-to-array-size.patch
  0049-Grow-don-t-allow-to-enable-PPL-when-reshape-is-in-pr.patch
  0050-Grow-don-t-allow-array-geometry-change-with-ppl-enab.patch
  0051-IMSM-Correct-examine-output-for-4k-disks.patch
  0052-imsm-allow-drives-in-a-container-regardless-of-secto.patch
  0053-imsm-allocate-buffer-to-support-maximum-sector-size.patch
  0054-imsm-don-t-allow-disks-with-different-sector-size-in.patch
  0055-Allow-more-spare-selection-criteria.patch
  0056-Add-sector-size-as-spare-selection-criterion.patch
  0057-super1-fix-sb-max_dev-when-adding-a-new-disk-in-line.patch
  0058-super1-only-set-clustered-flag-when-bitmap-is-presen.patch
  0059-To-support-clustered-raid10.patch
  0060-udev-rules-introduce-rules-for-cluster-md-to-confirm.patch
- The following patche set includes the above renamed patches,
  they have bug fixes for bsc#1068030, bsc#1069165, bsc#1069167,
  and some other fixes and enhancement for raid5 ppl, imsm, and
  general mdadm code,
  0038-mdadm-Create-declaring-an-existing-struct-within-sam.patch
  0039-Create-Fixup-bad-placement-of-logical-in-multi-line-.patch
  0040-Create-Fixup-various-whitespace-issues.patch
  0041-mdadm.c-fix-compile-warning-mdfd-is-uninitialized.patch
  0042-mdopen-use-parameters-new_array-to-create-arrays-whe.patch
  0043-mdadm-manpage-update-manpage-for-readonly-parameter.patch
  0044-mdadm-manpage-clustered-arrays-don-t-support-array-s.patch
  0045-maps-Terminate-modes-map-correctly.patch
  0046-Grow_continue_command-ensure-content-is-properly-ini.patch
  0047-systemd-mdadm-last-resort-use-ConditionPathExists-in.patch
  0048-Detail-ensure-export-names-are-acceptable-as-shell-v.patch
  0049-Grow-set-component-size-prior-to-array-size.patch
  0050-Grow-don-t-allow-to-enable-PPL-when-reshape-is-in-pr.patch
  0051-Grow-don-t-allow-array-geometry-change-with-ppl-enab.patch
  0052-IMSM-Correct-examine-output-for-4k-disks.patch
  0053-imsm-allow-drives-in-a-container-regardless-of-secto.patch
  0054-imsm-allocate-buffer-to-support-maximum-sector-size.patch
  0055-imsm-don-t-allow-disks-with-different-sector-size-in.patch
  0056-mdadm-mdmon-deleted-the-abort_reshape-never-invoked.patch
  0057-util-Introduce-md_get_array_info.patch
  0058-Incremental-Remove-redundant-call-for-GET_ARRAY_INFO.patch
  0059-util-Introduce-md_get_disk_info.patch
  0060-util-Introduce-md_set_array_info.patch
  0061-md_u-Remove-some-unused-ioctl-declarations.patch
  0062-mdadm-grow-reshape-would-be-stuck-from-raid1-to-raid.patch
  0063-sysfs-Use-the-presence-of-sys-block-dev-md-as-indica.patch
  0064-sysfs-Make-sysfs_init-return-an-error-code.patch
  0065-util-must_be_container-Use-sysfs_read-GET_VERSION-to.patch
  0066-util-set_array_info-Simplify-code-since-md_get_versi.patch
  0067-Assemble-Assemble-Stop-checking-kernel-md-driver-ver.patch
  0068-Build-Stop-bothering-about-supporting-md-driver-olde.patch
  0069-Grow-Stop-bothering-about-md-driver-versions-older-t.patch
  0070-Detail-Stop-bothering-about-md-drivers-older-than-0..patch
  0071-Create-Remove-all-attemps-to-handle-md-driver-older-.patch
  0072-Manage-Remove-all-references-to-md_get_version.patch
  0073-Query-Remove-all-references-to-md_get_version.patch
  0074-bitmap-Remove-use-of-md_get_version.patch
  0075-mdmon-Stop-bothering-about-md_get_version.patch
  0076-mdopen-open_mddev-Use-md_get_array_info-to-determine.patch
  0077-mdassemble-Use-md_get_array_info-to-check-for-valid-.patch
  0078-Assemble-Assemble-Get-rid-of-last-use-of-md_get_vers.patch
  0079-util-Finally-kill-off-md_get_version.patch
  0080-mdadm-Fail-for-kernels-older-than-2.6.15.patch
  0081-Revert-mdadm-grow-reshape-would-be-stuck-from-raid1-.patch
  0082-Retire-mdassemble.patch
  0083-super1-Clean-up-various-style-abuses.patch
  0084-Detail-Remove-pre-2.6-code-for-printing-info-on-rebu.patch
  0085-Assemble-Remove-obsolete-test-for-kernels-older-than.patch
  0086-Detail-Fixup-ugly-if-foo-abuse.patch
  0087-Query-Handle-error-returned-by-fstat.patch
  0088-Query-Use-sysfs-to-obtain-data-if-possible.patch
  0089-sysfs-Parse-array_state-in-sysfs_read.patch
  0090-util-Introduce-md_array_active-helper.patch
  0091-maps-Use-keyvalue-for-null-terminator-to-indicate-un.patch
  0092-util-Get-rid-of-unused-enough_fd.patch
  0093-mdadm-retire-mdassemble-in-make-everything.patch
  0094-Query-Quiet-gcc-since-it-cannot-know-errno-0-in-this.patch
  0095-Makefile-Default-to-O2-optimization.patch
  0096-maps-Simplify-implementation-of-map_name.patch
  0097-Don-t-use-UnSet-with-consistency_policy.patch
  0098-Detail-determine-array-state-from-sysfs.patch
  0099-Detail-Respect-code-lines-are-80-character-wide.patch
  0100-Detail-Reinstate-support-for-not-having-sysfs.patch
  0101-Incremental-Use-md_array_active-where-applicable.patch
  0102-Incremental-Cleanup-some-if-statement-spaghetti.patch
  0103-Create-tell-udev-md-device-is-not-ready-when-first-c.patch
  0104-Incremental-Use-md_array_active-to-determine-state-o.patch
  0105-Manage-Manage_ro-Use-md_array_active.patch
  0106-IMSM-Initialize-my_vol_raid_dev_num-during-vol-creat.patch
  0107-Grow-Grow_continue_command-Avoid-aliasing-array-vari.patch
  0108-change-back-0644-permission-for-Grow.c.patch
  0109-util-md_array_valid-Introduce-md_array_valid-helper.patch
  0110-kernel-patch-Remove-obsolete-kernel-patches-against-.patch
  0111-mdassemble-Kill-off-the-last-remains.patch
  0112-mdadm-util-unify-fstat-checking-blkdev-into-function.patch
  0113-mdadm-util-unify-stat-checking-blkdev-into-function.patch
  0114-Fix-typo-in-new-udev-rule.patch
  0115-Incremental-return-is-not-a-function.patch
  0116-sysfs-sysfs_read-Count-active_disks-and-failed_disks.patch
  0117-container_members_max_degradation-Switch-to-using-sy.patch
  0118-IncrementalScan-Use-md_array_active-instead-of-md_ge.patch
  0119-Mention-endian-in-documentation-for-update-byte-orde.patch
  0120-Monitor-Use-md_array_active-instead-of-manually-fidd.patch
  0121-Monitor-Code-is-80-characters-per-line.patch
  0122-mdadm-md.4-set-page-length-as-1000-to-avoid-warnings.patch
  0123-Allow-more-spare-selection-criteria.patch
  0124-Add-sector-size-as-spare-selection-criterion.patch
  0125-Monitor-check_array-Centralize-exit-path.patch
  0126-Monitor-check_array-Reduce-duplicated-error-handling.patch
  0127-Monitor-check_array-Declate-mdinfo-instance-globally.patch
  0128-Monitor-check_array-Read-sysfs-entry-earlier.patch
  0129-Monitor-check_array-Obtain-RAID-level-from-syfs.patch
  0130-Monitor-check_array-Get-failed_disks-from-sysfs.patch
  0131-Monitor-check_array-Get-array_disks-from-sysfs.patch
  0132-Monitor-check_array-Get-nr_disks-active_disks-and-sp.patch
  0133-sysfs-sysfs_read-Count-working_disks.patch
  0134-Monitor-check_array-Use-working_disks-from-sysfs.patch
  0135-retire-the-APIs-that-driver-no-longer-supports.patch
  0136-Monitor-Not-much-point-declaring-mdlist-in-both-fork.patch
  0137-Monitor-mailfrom-is-initialized-correctly.patch
  0138-Monitor-Fixup-a-pile-of-whitespace-issues.patch
  0139-mdadm-Uninitialized-variable-rdev.patch
  0140-super-ddf-sysfs_read-takes-a-pointer-as-device-name-.patch
  0141-mdadm-Fixup-a-large-number-of-bad-formatting-of-logi.patch
  0142-mdadm-Fixup-more-broken-logical-operator-formatting.patch
  0143-mdadm-Fix-broken-formatting.patch
  0144-mdadm-Fixup-broken-formatting.patch
  0145-Detail-don-t-exit-if-ioctl-has-been-successful.patch
  0146-super1-fix-sb-max_dev-when-adding-a-new-disk-in-line.patch
  0147-md_u-Remove-unused-ioctl-declaration-of-START_ARRAY.patch
  0148-Get-failed-disk-count-from-array-state.patch
  0149-Monitor-don-t-assume-mdadm-parameter-is-a-block-devi.patch
  0150-super1-Always-round-data-offset-to-1M.patch
  0151-mdadm-r5cache-allow-adding-journal-to-array-without-.patch 
  0152-udev-rules-introduce-rules-for-cluster-md-to-confirm.patch
  0153-Detail-correct-output-for-active-arrays.patch
  0154-imsm-rebuild-from-2-disk-RAID10.patch (bsc#1069165)
  0155-Error-messages-should-end-with-a-newline-character.patch
  0156-Use-correct-syntax-for-passing-DEVLINKS-to-mdadm-fro.patch
  0157-super1-only-set-clustered-flag-when-bitmap-is-presen.patch
  0158-Don-t-use-exit-ERANGE.patch
  0159-Monitor-containers-don-t-have-the-same-sysfs-propert.patch
  0160-Monitor-Include-containers-in-spare-migration.patch
  0161-Detail-differentiate-between-container-and-inactive-.patch
  0162-mdadm-install-two-more-udev-rules-in-mdadm.spec.patch
  0163-mdadm-set-journal_clean-after-scanning-all-disks.patch
  0164-mdadm-bitmap-examine-bitmap-failed-when-bitmap-is-ex.patch
  0165-mdopen-call-modprobe-md_mod-if-it-might-be-needed.patch
  0166-lib-devid2kname-should-take-a-dev_t.patch
  0167-sysfs_init_dev-take-a-dev_t-argument.patch
  0168-Manage_subdevs-Use-a-dev_t.patch
  0169-util-Code-is-80-characters-wide.patch
  0170-Close-mdfd-before-returning-main-function.patch
  0171-Grow-stop-previous-reshape-process-first.patch
  0172-imsm-New-disk-controller-domains.patch
  0173-Monitor-Check-redundancy-for-arrays.patch
  0174-mdadm-grow-Component-size-must-be-larger-than-chunk-.patch
  0175-mdadm-manpage-disable-bitmap_resize-for-external-fil.patch
  0176-mdadm-fixes-some-trivial-typos-in-comments.patch
  (The following 12 patches are specifically for bsc#1068030)
  0177-Don-t-abort-starting-the-array-if-kernel-does-not-su.patch
  0178-super1-Add-support-for-multiple-ppls.patch
  0179-imsm-Add-support-for-multiple-ppls.patch
  0180-imsm-validate-multiple-ppls-during-assemble.patch
  0181-Zeroout-whole-ppl-space-during-creation-force-assemb.patch
  0182-imsm-switch-to-multiple-ppls-automatically-during-as.patch
  0183-Grow-fix-switching-on-PPL-during-recovery.patch
  0184-imsm-don-t-skip-resync-when-an-invalid-ppl-header-is.patch
  0185-imsm-Write-empty-PPL-header-if-assembling-regular-cl.patch
  0186-imsm-always-do-ppl-recovery-when-starting-a-rebuildi.patch
  0187-imsm-use-correct-map-when-validating-ppl.patch
  0188-imsm-write-initial-ppl-on-a-disk-added-for-rebuild.patch
  0189-Grow-Use-all-80-characters.patch
  0190-imsm-Set-disk-slot-number.patch
  (The following 1 patch is specifically for bsc#1069167)
  0191-mdmon-get-safe-mode-delay-file-descriptor-early.patch
  0192-mdadm-mdstat-fixup-a-number-of-broken-formatting.patch
  0193-mdadm-mdstat-correct-the-strncmp-number-4-as-6.patch
  0194-mdcheck-add-some-logging.patch
  0195-mdcheck-improve-cleanup.patch
  0196-Move-mdadm_env.sh-out-of-usr-lib-systemd.patch
  0197-mdadm-grow-adding-a-test-to-ensure-resize-was-requir.patch
  0198-mdadm-mdopen-create-new-function-create_named_array-.patch
  0199-systemd-add-I-to-description-of-mdadm-last-resort-se.patch
  0200-Incremental-Use-validate_geometry-instead-of-avail_s.patch
  0201-imsm-fix-reading-scsi-serial.patch
  0202-To-support-clustered-raid10.patch
  0203-imsm-More-precise-message-when-spanned-raid-is-creat.patch
  0204-sysfs-include-faulty-drive-in-disk-count.patch
  0205-Monitor-msg-Don-t-print-error-message-if-mdmon-doesn.patch
  0206-imsm-continue-resync-on-3-disk-RAID10.patch

OBS-URL: https://build.opensuse.org/request/show/548207
OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=156
2017-12-04 21:26:22 +00:00

422 lines
14 KiB
Diff

From 9cd39f015558dba82c293a4433b481b921ceec87 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@gmail.com>
Date: Wed, 29 Mar 2017 14:35:41 -0400
Subject: [PATCH] util: Introduce md_get_array_info()
Git-commit: 9cd39f015558dba82c293a4433b481b921ceec87
Patch-mainline: mdadm-4.0+
References: bsc#1069165, bsc#1069167, bsc#1068030
Remove most direct ioctl calls for GET_ARRAY_INFO, except for one,
which will be addressed in the next patch.
This is the start of the effort to clean up the use of ioctl calls and
introduce a more structured API, which will use sysfs and fall back to
ioctl for backup.
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
Create.c | 5 ++---
Detail.c | 2 +-
Grow.c | 31 ++++++++++++++++---------------
Incremental.c | 11 +++++------
Manage.c | 13 ++++++-------
Monitor.c | 7 ++++---
Query.c | 7 ++++---
mdadm.h | 1 +
mdassemble.c | 2 +-
util.c | 14 +++++++++++---
10 files changed, 51 insertions(+), 42 deletions(-)
diff --git a/Create.c b/Create.c
index 10e7d10..0e0778f 100644
--- a/Create.c
+++ b/Create.c
@@ -156,8 +156,7 @@ int Create(struct supertype *st, char *mddev,
memset(&inf, 0, sizeof(inf));
fd = open(devlist->devname, O_RDONLY);
if (fd >= 0 &&
- ioctl(fd, GET_ARRAY_INFO, &inf) == 0 &&
- inf.raid_disks == 0) {
+ md_get_array_info(fd, &inf) == 0 && inf.raid_disks == 0) {
/* yep, looks like a container */
if (st) {
rv = st->ss->load_container(st, fd,
@@ -634,7 +633,7 @@ int Create(struct supertype *st, char *mddev,
} else {
mdu_array_info_t inf;
memset(&inf, 0, sizeof(inf));
- ioctl(mdfd, GET_ARRAY_INFO, &inf);
+ md_get_array_info(mdfd, &inf);
if (inf.working_disks != 0) {
pr_err("another array by this name is already running.\n");
goto abort_locked;
diff --git a/Detail.c b/Detail.c
index 136875b..d7e886a 100644
--- a/Detail.c
+++ b/Detail.c
@@ -107,7 +107,7 @@ int Detail(char *dev, struct context *c)
external = (sra != NULL && sra->array.major_version == -1
&& sra->array.minor_version == -2);
st = super_by_fd(fd, &subarray);
- if (ioctl(fd, GET_ARRAY_INFO, &array) == 0) {
+ if (md_get_array_info(fd, &array) == 0) {
inactive = 0;
} else if (errno == ENODEV && sra) {
if (sra->array.major_version == -1 &&
diff --git a/Grow.c b/Grow.c
index 6405f0e..4eab5cc 100755
--- a/Grow.c
+++ b/Grow.c
@@ -115,7 +115,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
struct supertype *st = NULL;
char *subarray = NULL;
- if (ioctl(fd, GET_ARRAY_INFO, &info.array) < 0) {
+ if (md_get_array_info(fd, &info.array) < 0) {
pr_err("cannot get array info for %s\n", devname);
return 1;
}
@@ -221,7 +221,7 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
* Now go through and update all superblocks
*/
- if (ioctl(fd, GET_ARRAY_INFO, &info.array) < 0) {
+ if (md_get_array_info(fd, &info.array) < 0) {
pr_err("cannot get array info for %s\n", devname);
return 1;
}
@@ -328,7 +328,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
devname, bmf.pathname);
return 1;
}
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0) {
+ if (md_get_array_info(fd, &array) != 0) {
pr_err("cannot get array status for %s\n", devname);
return 1;
}
@@ -1784,7 +1784,7 @@ int Grow_reshape(char *devname, int fd,
struct mdinfo info;
struct mdinfo *sra;
- if (ioctl(fd, GET_ARRAY_INFO, &array) < 0) {
+ if (md_get_array_info(fd, &array) < 0) {
pr_err("%s is not an active md array - aborting\n",
devname);
return 1;
@@ -2030,7 +2030,7 @@ int Grow_reshape(char *devname, int fd,
/* get array parameters after takeover
* to change one parameter at time only
*/
- rv = ioctl(fd, GET_ARRAY_INFO, &array);
+ rv = md_get_array_info(fd, &array);
}
}
/* make sure mdmon is
@@ -2072,7 +2072,7 @@ int Grow_reshape(char *devname, int fd,
/* go back to raid0, drop parity disk
*/
sysfs_set_str(sra, NULL, "level", "raid0");
- ioctl(fd, GET_ARRAY_INFO, &array);
+ md_get_array_info(fd, &array);
}
size_change_error:
@@ -2101,7 +2101,7 @@ size_change_error:
sysfs_set_str(sra, NULL, "resync_start", "none") < 0)
pr_err("--assume-clean not supported with --grow on this kernel\n");
}
- ioctl(fd, GET_ARRAY_INFO, &array);
+ md_get_array_info(fd, &array);
s->size = get_component_size(fd)/2;
if (s->size == 0)
s->size = array.size;
@@ -2267,7 +2267,7 @@ size_change_error:
rv =1 ;
}
if (s->layout_str) {
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0) {
+ if (md_get_array_info(fd, &array) != 0) {
dprintf("Cannot get array information.\n");
goto release;
}
@@ -2830,7 +2830,7 @@ static int impose_reshape(struct mdinfo *sra,
* reshape->after.data_disks);
}
- ioctl(fd, GET_ARRAY_INFO, &array);
+ md_get_array_info(fd, &array);
if (info->array.chunk_size == info->new_chunk &&
reshape->before.layout == reshape->after.layout &&
st->ss->external == 0) {
@@ -2885,7 +2885,7 @@ static int impose_level(int fd, int level, char *devname, int verbose)
struct mdinfo info;
sysfs_init(&info, fd, NULL);
- ioctl(fd, GET_ARRAY_INFO, &array);
+ md_get_array_info(fd, &array);
if (level == 0 &&
(array.level >= 4 && array.level <= 6)) {
/* To convert to RAID0 we need to fail and
@@ -2921,7 +2921,7 @@ static int impose_level(int fd, int level, char *devname, int verbose)
makedev(disk.major, disk.minor));
}
/* Now fail anything left */
- ioctl(fd, GET_ARRAY_INFO, &array);
+ md_get_array_info(fd, &array);
for (d = 0, found = 0;
d < MAX_DISKS && found < array.nr_disks;
d++) {
@@ -3042,7 +3042,7 @@ static int reshape_array(char *container, int fd, char *devname,
/* when reshaping a RAID0, the component_size might be zero.
* So try to fix that up.
*/
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0) {
+ if (md_get_array_info(fd, &array) != 0) {
dprintf("Cannot get array information.\n");
goto release;
}
@@ -3230,7 +3230,7 @@ static int reshape_array(char *container, int fd, char *devname,
* some more changes: layout, raid_disks, chunk_size
*/
/* read current array info */
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0) {
+ if (md_get_array_info(fd, &array) != 0) {
dprintf("Cannot get array information.\n");
goto release;
}
@@ -4994,8 +4994,9 @@ int Grow_continue_command(char *devname, int fd,
int d;
int cnt = 5;
dprintf_cont("native array (%s)\n", devname);
- if (ioctl(fd, GET_ARRAY_INFO, &array.array) < 0) {
- pr_err("%s is not an active md array - aborting\n", devname);
+ if (md_get_array_info(fd, &array.array) < 0) {
+ pr_err("%s is not an active md array - aborting\n",
+ devname);
ret_val = 1;
goto Grow_continue_command_exit;
}
diff --git a/Incremental.c b/Incremental.c
index 81afc7e..1f12c77 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -398,7 +398,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
&& ! policy_action_allows(policy, st->ss->name,
act_re_add)
&& c->runstop < 1) {
- if (ioctl(mdfd, GET_ARRAY_INFO, &ainf) == 0) {
+ if (md_get_array_info(mdfd, &ainf) == 0) {
pr_err("not adding %s to active array (without --run) %s\n",
devname, chosen_name);
rv = 2;
@@ -549,7 +549,7 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
/* + add any bitmap file */
/* + start the array (auto-readonly). */
- if (ioctl(mdfd, GET_ARRAY_INFO, &ainf) == 0) {
+ if (md_get_array_info(mdfd, &ainf) == 0) {
if (c->export) {
printf("MD_STARTED=already\n");
} else if (c->verbose >= 0)
@@ -664,7 +664,7 @@ static void find_reject(int mdfd, struct supertype *st, struct mdinfo *sra,
struct mdinfo *d;
mdu_array_info_t ra;
- if (ioctl(mdfd, GET_ARRAY_INFO, &ra) == 0)
+ if (md_get_array_info(mdfd, &ra) == 0)
return; /* not safe to remove from active arrays
* without thinking more */
@@ -837,7 +837,7 @@ static int container_members_max_degradation(struct map_ent *map, struct map_ent
if (afd < 0)
continue;
/* most accurate information regarding array degradation */
- if (ioctl(afd, GET_ARRAY_INFO, &array) >= 0) {
+ if (md_get_array_info(afd, &array) >= 0) {
int degraded = array.raid_disks - array.active_disks -
array.spare_disks;
if (degraded > max_degraded)
@@ -1390,8 +1390,7 @@ restart:
rv = 1;
continue;
}
- if (ioctl(mdfd, GET_ARRAY_INFO, &array) == 0 ||
- errno != ENODEV) {
+ if (md_get_array_info(mdfd, &array) == 0 || errno != ENODEV) {
close(mdfd);
continue;
}
diff --git a/Manage.c b/Manage.c
index 55218d9..24ed370 100644
--- a/Manage.c
+++ b/Manage.c
@@ -95,7 +95,7 @@ int Manage_ro(char *devname, int fd, int readonly)
goto out;
}
#endif
- if (ioctl(fd, GET_ARRAY_INFO, &array)) {
+ if (md_get_array_info(fd, &array)) {
pr_err("%s does not appear to be active.\n",
devname);
rv = 1;
@@ -539,7 +539,7 @@ static void add_faulty(struct mddev_dev *dv, int fd, char disp)
int remaining_disks;
int i;
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0)
+ if (md_get_array_info(fd, &array) != 0)
return;
remaining_disks = array.nr_disks;
@@ -565,7 +565,7 @@ static void add_detached(struct mddev_dev *dv, int fd, char disp)
int remaining_disks;
int i;
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0)
+ if (md_get_array_info(fd, &array) != 0)
return;
remaining_disks = array.nr_disks;
@@ -602,7 +602,7 @@ static void add_set(struct mddev_dev *dv, int fd, char set_char)
int copies, set;
int i;
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0)
+ if (md_get_array_info(fd, &array) != 0)
return;
if (array.level != 10)
return;
@@ -1383,9 +1383,8 @@ int Manage_subdevs(char *devname, int fd,
int busy = 0;
int raid_slot = -1;
- if (ioctl(fd, GET_ARRAY_INFO, &array)) {
- pr_err("Cannot get array info for %s\n",
- devname);
+ if (md_get_array_info(fd, &array)) {
+ pr_err("Cannot get array info for %s\n", devname);
goto abort;
}
sysfs_init(&info, fd, NULL);
diff --git a/Monitor.c b/Monitor.c
index bdd3e63..0a0a1e2 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -497,7 +497,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
return 0;
}
fcntl(fd, F_SETFD, FD_CLOEXEC);
- if (ioctl(fd, GET_ARRAY_INFO, &array)<0) {
+ if (md_get_array_info(fd, &array) < 0) {
if (!st->err)
alert("DeviceDisappeared", dev, NULL, ainfo);
st->err++;
@@ -709,9 +709,10 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
st->devname = xstrdup(name);
if ((fd = open(st->devname, O_RDONLY)) < 0 ||
- ioctl(fd, GET_ARRAY_INFO, &array)< 0) {
+ md_get_array_info(fd, &array) < 0) {
/* no such array */
- if (fd >=0) close(fd);
+ if (fd >= 0)
+ close(fd);
put_md_name(st->devname);
free(st->devname);
if (st->metadata) {
diff --git a/Query.c b/Query.c
index fbc1d10..cae75d1 100644
--- a/Query.c
+++ b/Query.c
@@ -53,9 +53,10 @@ int Query(char *dev)
}
vers = md_get_version(fd);
- if (ioctl(fd, GET_ARRAY_INFO, &array)<0)
+ if (md_get_array_info(fd, &array) < 0)
ioctlerr = errno;
- else ioctlerr = 0;
+ else
+ ioctlerr = 0;
fstat(fd, &stb);
@@ -100,7 +101,7 @@ int Query(char *dev)
activity = "undetected";
if (mddev && (fd = open(mddev, O_RDONLY))>=0) {
if (md_get_version(fd) >= 9000 &&
- ioctl(fd, GET_ARRAY_INFO, &array)>= 0) {
+ md_get_array_info(fd, &array) >= 0) {
if (ioctl(fd, GET_DISK_INFO, &disc) >= 0 &&
makedev((unsigned)disc.major,(unsigned)disc.minor) == stb.st_rdev)
activity = "active";
diff --git a/mdadm.h b/mdadm.h
index dbf1f92..7770585 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1405,6 +1405,7 @@ extern int Restore_metadata(char *dev, char *dir, struct context *c,
struct supertype *st, int only);
extern int md_get_version(int fd);
+int md_get_array_info(int fd, struct mdu_array_info_s *array);
extern int get_linux_version(void);
extern int mdadm_version(char *version);
extern unsigned long long parse_size(char *size);
diff --git a/mdassemble.c b/mdassemble.c
index 471ffeb..a24b324 100644
--- a/mdassemble.c
+++ b/mdassemble.c
@@ -67,7 +67,7 @@ int main(int argc, char *argv[])
if (strcasecmp(array_list->devname, "<ignore>") == 0)
continue;
mdfd = open_mddev(array_list->devname, 0);
- if (mdfd >= 0 && ioctl(mdfd, GET_ARRAY_INFO, &array) == 0) {
+ if (mdfd >= 0 && md_get_array_info(mdfd, &array) == 0) {
rv |= Manage_ro(array_list->devname, mdfd, -1); /* make it readwrite */
continue;
}
diff --git a/util.c b/util.c
index 374015e..725877d 100644
--- a/util.c
+++ b/util.c
@@ -212,6 +212,15 @@ int cluster_release_dlmlock(int lockid)
#endif
/*
+ * Get array info from the kernel. Longer term we want to deprecate the
+ * ioctl and get it from sysfs.
+ */
+int md_get_array_info(int fd, struct mdu_array_info_s *array)
+{
+ return ioctl(fd, GET_ARRAY_INFO, array);
+}
+
+/*
* Parse a 128 bit uuid in 4 integers
* format is 32 hexx nibbles with options :.<space> separator
* If not exactly 32 hex digits are found, return 0
@@ -539,8 +548,7 @@ int enough_fd(int fd)
int i, rv;
char *avail;
- if (ioctl(fd, GET_ARRAY_INFO, &array) != 0 ||
- array.raid_disks <= 0)
+ if (md_get_array_info(fd, &array) != 0 || array.raid_disks <= 0)
return 0;
avail = xcalloc(array.raid_disks, 1);
for (i = 0; i < MAX_DISKS && array.nr_disks > 0; i++) {
@@ -1175,7 +1183,7 @@ struct supertype *super_by_fd(int fd, char **subarrayp)
minor = sra->array.minor_version;
verstr = sra->text_version;
} else {
- if (ioctl(fd, GET_ARRAY_INFO, &array))
+ if (md_get_array_info(fd, &array))
array.major_version = array.minor_version = 0;
vers = array.major_version;
minor = array.minor_version;
--
2.13.6