forked from pool/mdadm
849a39cd07
- 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
1105 lines
40 KiB
Diff
1105 lines
40 KiB
Diff
From 358ef9bfdd368cbcb5ac1b588e9cc6d439d99f0f Mon Sep 17 00:00:00 2001
|
|
From: Jes Sorensen <jsorensen@fb.com>
|
|
Date: Mon, 2 Oct 2017 17:21:40 -0400
|
|
Subject: [PATCH] Grow: Use all 80 characters
|
|
Git-commit: 358ef9bfdd368cbcb5ac1b588e9cc6d439d99f0f
|
|
Patch-mainline: mdadm-4.0+
|
|
References: bsc#1069165, bsc#1069167, bsc#1068030
|
|
|
|
Try to use the full line length and avoid breaking up lines excessively.
|
|
Equally break up lines that are too long for no reason.
|
|
|
|
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
|
|
Signed-off-by: Coly Li <colyli@suse.de>
|
|
|
|
---
|
|
Grow.c | 417 +++++++++++++++++++++++++++++++----------------------------------
|
|
1 file changed, 197 insertions(+), 220 deletions(-)
|
|
|
|
diff --git a/Grow.c b/Grow.c
|
|
index 1149753..4d79d83 100644
|
|
--- a/Grow.c
|
|
+++ b/Grow.c
|
|
@@ -58,9 +58,8 @@ int restore_backup(struct supertype *st,
|
|
for (dev = content->devs; dev; dev = dev->next) {
|
|
char buf[22];
|
|
int fd;
|
|
- sprintf(buf, "%d:%d",
|
|
- dev->disk.major,
|
|
- dev->disk.minor);
|
|
+
|
|
+ sprintf(buf, "%d:%d", dev->disk.major, dev->disk.minor);
|
|
fd = dev_open(buf, O_RDWR);
|
|
|
|
if (dev->disk.raid_disk >= 0)
|
|
@@ -160,16 +159,14 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
|
|
|
|
disk.number = d;
|
|
if (md_get_disk_info(fd, &disk) < 0) {
|
|
- pr_err("cannot get device detail for device %d\n",
|
|
- d);
|
|
+ pr_err("cannot get device detail for device %d\n", d);
|
|
close(nfd);
|
|
free(st);
|
|
return 1;
|
|
}
|
|
dv = map_dev(disk.major, disk.minor, 1);
|
|
if (!dv) {
|
|
- pr_err("cannot find device file for device %d\n",
|
|
- d);
|
|
+ pr_err("cannot find device file for device %d\n", d);
|
|
close(nfd);
|
|
free(st);
|
|
return 1;
|
|
@@ -200,12 +197,10 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
|
|
info.disk.minor = minor(rdev);
|
|
info.disk.raid_disk = d;
|
|
info.disk.state = (1 << MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE);
|
|
- st->ss->update_super(st, &info, "linear-grow-new", newdev,
|
|
- 0, 0, NULL);
|
|
+ st->ss->update_super(st, &info, "linear-grow-new", newdev, 0, 0, NULL);
|
|
|
|
if (st->ss->store_super(st, nfd)) {
|
|
- pr_err("Cannot store new superblock on %s\n",
|
|
- newdev);
|
|
+ pr_err("Cannot store new superblock on %s\n", newdev);
|
|
close(nfd);
|
|
return 1;
|
|
}
|
|
@@ -231,14 +226,12 @@ int Grow_Add_device(char *devname, int fd, char *newdev)
|
|
|
|
disk.number = d;
|
|
if (md_get_disk_info(fd, &disk) < 0) {
|
|
- pr_err("cannot get device detail for device %d\n",
|
|
- d);
|
|
+ pr_err("cannot get device detail for device %d\n", d);
|
|
return 1;
|
|
}
|
|
dv = map_dev(disk.major, disk.minor, 1);
|
|
if (!dv) {
|
|
- pr_err("cannot find device file for device %d\n",
|
|
- d);
|
|
+ pr_err("cannot find device file for device %d\n", d);
|
|
return 1;
|
|
}
|
|
fd2 = dev_open(dv, O_RDWR);
|
|
@@ -315,8 +308,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
|
|
}
|
|
return 0;
|
|
}
|
|
- pr_err("%s already has a bitmap (%s)\n",
|
|
- devname, bmf.pathname);
|
|
+ pr_err("%s already has a bitmap (%s)\n", devname, bmf.pathname);
|
|
return 1;
|
|
}
|
|
if (md_get_array_info(fd, &array) != 0) {
|
|
@@ -653,7 +645,8 @@ int Grow_consistency_policy(char *devname, int fd, struct context *c, struct sha
|
|
goto free_info;
|
|
}
|
|
|
|
- ret = st->ss->update_super(st, sra, "ppl", devname,
|
|
+ ret = st->ss->update_super(st, sra, "ppl",
|
|
+ devname,
|
|
c->verbose, 0, NULL);
|
|
if (ret) {
|
|
close(dfd);
|
|
@@ -663,8 +656,10 @@ int Grow_consistency_policy(char *devname, int fd, struct context *c, struct sha
|
|
st->ss->getinfo_super(st, &info, NULL);
|
|
}
|
|
|
|
- ret |= sysfs_set_num(sra, sd, "ppl_sector", info.ppl_sector);
|
|
- ret |= sysfs_set_num(sra, sd, "ppl_size", info.ppl_size);
|
|
+ ret |= sysfs_set_num(sra, sd, "ppl_sector",
|
|
+ info.ppl_sector);
|
|
+ ret |= sysfs_set_num(sra, sd, "ppl_size",
|
|
+ info.ppl_size);
|
|
|
|
if (ret) {
|
|
pr_err("Failed to set PPL attributes for %s\n",
|
|
@@ -851,8 +846,7 @@ static int reshape_super(struct supertype *st, unsigned long long size,
|
|
/* nothing extra to check in the native case */
|
|
if (!st->ss->external)
|
|
return 0;
|
|
- if (!st->ss->reshape_super ||
|
|
- !st->ss->manage_reshape) {
|
|
+ if (!st->ss->reshape_super || !st->ss->manage_reshape) {
|
|
pr_err("%s metadata does not support reshape\n",
|
|
st->ss->name);
|
|
return 1;
|
|
@@ -930,7 +924,8 @@ int start_reshape(struct mdinfo *sra, int already_running,
|
|
if (!already_running && err == 0) {
|
|
int cnt = 5;
|
|
do {
|
|
- err = sysfs_set_str(sra, NULL, "sync_action", "reshape");
|
|
+ err = sysfs_set_str(sra, NULL, "sync_action",
|
|
+ "reshape");
|
|
if (err)
|
|
sleep(1);
|
|
} while (err && errno == EBUSY && cnt-- > 0);
|
|
@@ -1089,10 +1084,8 @@ int reshape_prepare_fdlist(char *devname,
|
|
continue;
|
|
if (sd->disk.state & (1<<MD_DISK_SYNC) &&
|
|
sd->disk.raid_disk < raid_disks) {
|
|
- char *dn = map_dev(sd->disk.major,
|
|
- sd->disk.minor, 1);
|
|
- fdlist[sd->disk.raid_disk]
|
|
- = dev_open(dn, O_RDONLY);
|
|
+ char *dn = map_dev(sd->disk.major, sd->disk.minor, 1);
|
|
+ fdlist[sd->disk.raid_disk] = dev_open(dn, O_RDONLY);
|
|
offsets[sd->disk.raid_disk] = sd->data_offset*512;
|
|
if (fdlist[sd->disk.raid_disk] < 0) {
|
|
pr_err("%s: cannot open component %s\n",
|
|
@@ -1102,8 +1095,7 @@ int reshape_prepare_fdlist(char *devname,
|
|
}
|
|
} else if (backup_file == NULL) {
|
|
/* spare */
|
|
- char *dn = map_dev(sd->disk.major,
|
|
- sd->disk.minor, 1);
|
|
+ char *dn = map_dev(sd->disk.major, sd->disk.minor, 1);
|
|
fdlist[d] = dev_open(dn, O_RDWR);
|
|
offsets[d] = (sd->data_offset + sra->component_size - blocks - 8)*512;
|
|
if (fdlist[d] < 0) {
|
|
@@ -1322,17 +1314,22 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
|
|
case 0:
|
|
if ((info->array.layout & ~0xff) != 0x100)
|
|
return "Cannot Grow RAID10 with far/offset layout";
|
|
- /* number of devices must be multiple of number of copies */
|
|
- if (info->array.raid_disks % (info->array.layout & 0xff))
|
|
+ /*
|
|
+ * number of devices must be multiple of
|
|
+ * number of copies
|
|
+ */
|
|
+ if (info->array.raid_disks %
|
|
+ (info->array.layout & 0xff))
|
|
return "RAID10 layout too complex for Grow operation";
|
|
|
|
- new_disks = (info->array.raid_disks
|
|
- / (info->array.layout & 0xff));
|
|
+ new_disks = (info->array.raid_disks /
|
|
+ (info->array.layout & 0xff));
|
|
if (info->delta_disks == UnSet)
|
|
info->delta_disks = (new_disks
|
|
- info->array.raid_disks);
|
|
|
|
- if (info->delta_disks != new_disks - info->array.raid_disks)
|
|
+ if (info->delta_disks !=
|
|
+ new_disks - info->array.raid_disks)
|
|
return "New number of raid-devices impossible for RAID10";
|
|
if (info->new_chunk &&
|
|
info->new_chunk != info->array.chunk_size)
|
|
@@ -1617,7 +1614,8 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
|
|
* can leave it unchanged, else we must
|
|
* fail
|
|
*/
|
|
- ls = map_num(r6layout, info->new_layout);
|
|
+ ls = map_num(r6layout,
|
|
+ info->new_layout);
|
|
if (!ls ||
|
|
strcmp(ls+strlen(ls)-2, "-6") != 0)
|
|
return "Please specify new layout";
|
|
@@ -1689,8 +1687,7 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
|
|
|
|
re->backup_blocks = compute_backup_blocks(
|
|
info->new_chunk, info->array.chunk_size,
|
|
- re->after.data_disks,
|
|
- re->before.data_disks);
|
|
+ re->after.data_disks, re->before.data_disks);
|
|
re->min_offset_change = re->backup_blocks / re->before.data_disks;
|
|
|
|
re->new_size = info->component_size * re->after.data_disks;
|
|
@@ -1713,8 +1710,7 @@ static int set_array_size(struct supertype *st, struct mdinfo *sra,
|
|
info = st->ss->container_content(st, subarray);
|
|
if (info) {
|
|
unsigned long long current_size = 0;
|
|
- unsigned long long new_size =
|
|
- info->custom_array_size/2;
|
|
+ unsigned long long new_size = info->custom_array_size/2;
|
|
|
|
if (sysfs_get_ll(sra, NULL, "array_size", ¤t_size) == 0 &&
|
|
new_size > current_size) {
|
|
@@ -1855,8 +1851,7 @@ int Grow_reshape(char *devname, int fd,
|
|
fd = cfd;
|
|
}
|
|
if (cfd < 0) {
|
|
- pr_err("Unable to open container for %s\n",
|
|
- devname);
|
|
+ pr_err("Unable to open container for %s\n", devname);
|
|
free(subarray);
|
|
return 1;
|
|
}
|
|
@@ -1864,8 +1859,7 @@ int Grow_reshape(char *devname, int fd,
|
|
retval = st->ss->load_container(st, cfd, NULL);
|
|
|
|
if (retval) {
|
|
- pr_err("Cannot read superblock for %s\n",
|
|
- devname);
|
|
+ pr_err("Cannot read superblock for %s\n", devname);
|
|
free(subarray);
|
|
return 1;
|
|
}
|
|
@@ -1913,7 +1907,8 @@ int Grow_reshape(char *devname, int fd,
|
|
for (dv = devlist; dv; dv = dv->next)
|
|
added_disks++;
|
|
if (s->raiddisks > array.raid_disks &&
|
|
- array.spare_disks + added_disks < (s->raiddisks - array.raid_disks) &&
|
|
+ array.spare_disks + added_disks <
|
|
+ (s->raiddisks - array.raid_disks) &&
|
|
!c->force) {
|
|
pr_err("Need %d spare%s to avoid degraded array, and only have %d.\n"
|
|
" Use --force to over-ride this check.\n",
|
|
@@ -1999,18 +1994,19 @@ int Grow_reshape(char *devname, int fd,
|
|
*/
|
|
min_csize = 0;
|
|
for (mdi = sra->devs; mdi; mdi = mdi->next) {
|
|
- sysfs_set_num(sra, mdi, "size", s->size == MAX_SIZE ? 0
|
|
- : s->size);
|
|
+ sysfs_set_num(sra, mdi, "size",
|
|
+ s->size == MAX_SIZE ? 0 : s->size);
|
|
if (array.not_persistent == 0 &&
|
|
array.major_version == 0 &&
|
|
get_linux_version() < 3001000) {
|
|
/* Dangerous to allow size to exceed 2TB */
|
|
unsigned long long csize;
|
|
- if (sysfs_get_ll(sra, mdi, "size", &csize) == 0) {
|
|
+ if (sysfs_get_ll(sra, mdi, "size",
|
|
+ &csize) == 0) {
|
|
if (csize >= 2ULL*1024*1024*1024)
|
|
csize = 2ULL*1024*1024*1024;
|
|
- if ((min_csize == 0 || (min_csize
|
|
- > csize)))
|
|
+ if ((min_csize == 0 ||
|
|
+ (min_csize > csize)))
|
|
min_csize = csize;
|
|
}
|
|
}
|
|
@@ -2029,8 +2025,7 @@ int Grow_reshape(char *devname, int fd,
|
|
}
|
|
if (st->ss->external) {
|
|
if (sra->array.level == 0) {
|
|
- rv = sysfs_set_str(sra, NULL, "level",
|
|
- "raid5");
|
|
+ rv = sysfs_set_str(sra, NULL, "level", "raid5");
|
|
if (!rv) {
|
|
raid0_takeover = 1;
|
|
/* get array parameters after takeover
|
|
@@ -2104,7 +2099,8 @@ size_change_error:
|
|
* a backport has been arranged.
|
|
*/
|
|
if (sra == NULL ||
|
|
- sysfs_set_str(sra, NULL, "resync_start", "none") < 0)
|
|
+ sysfs_set_str(sra, NULL, "resync_start",
|
|
+ "none") < 0)
|
|
pr_err("--assume-clean not supported with --grow on this kernel\n");
|
|
}
|
|
md_get_array_info(fd, &array);
|
|
@@ -2134,8 +2130,7 @@ size_change_error:
|
|
(s->raiddisks == 0 || s->raiddisks == array.raid_disks)) {
|
|
/* Nothing more to do */
|
|
if (!changed && c->verbose >= 0)
|
|
- pr_err("%s: no change requested\n",
|
|
- devname);
|
|
+ pr_err("%s: no change requested\n", devname);
|
|
goto release;
|
|
}
|
|
|
|
@@ -2149,6 +2144,7 @@ size_change_error:
|
|
array.layout == ((1 << 8) + 2) && !(array.raid_disks & 1)) ||
|
|
(s->level == 0 && array.level == 1 && sra)) {
|
|
int err;
|
|
+
|
|
err = remove_disks_for_takeover(st, sra, array.layout);
|
|
if (err) {
|
|
dprintf("Array cannot be reshaped\n");
|
|
@@ -2303,7 +2299,8 @@ size_change_error:
|
|
fd = -1;
|
|
}
|
|
rv = reshape_container(container, devname, -1, st, &info,
|
|
- c->force, c->backup_file, c->verbose, 0, 0, 0);
|
|
+ c->force, c->backup_file, c->verbose,
|
|
+ 0, 0, 0);
|
|
frozen = 0;
|
|
} else {
|
|
/* get spare devices from external metadata
|
|
@@ -2325,15 +2322,15 @@ size_change_error:
|
|
if (reshape_super(st, 0, info.new_level,
|
|
info.new_layout, info.new_chunk,
|
|
info.array.raid_disks, info.delta_disks,
|
|
- c->backup_file, devname, APPLY_METADATA_CHANGES,
|
|
- c->verbose)) {
|
|
+ c->backup_file, devname,
|
|
+ APPLY_METADATA_CHANGES, c->verbose)) {
|
|
rv = 1;
|
|
goto release;
|
|
}
|
|
sync_metadata(st);
|
|
rv = reshape_array(container, fd, devname, st, &info, c->force,
|
|
- devlist, data_offset, c->backup_file, c->verbose,
|
|
- 0, 0, 0);
|
|
+ devlist, data_offset, c->backup_file,
|
|
+ c->verbose, 0, 0, 0);
|
|
frozen = 0;
|
|
}
|
|
release:
|
|
@@ -2504,8 +2501,10 @@ static int set_new_data_offset(struct mdinfo *sra, struct supertype *st,
|
|
dir = -1;
|
|
else
|
|
dir = 1;
|
|
- } else if ((data_offset <= info2.data_offset && dir == 1) ||
|
|
- (data_offset >= info2.data_offset && dir == -1)) {
|
|
+ } else if ((data_offset <= info2.data_offset &&
|
|
+ dir == 1) ||
|
|
+ (data_offset >= info2.data_offset &&
|
|
+ dir == -1)) {
|
|
pr_err("%s: differing data offsets on devices make this --data-offset setting impossible\n",
|
|
dn);
|
|
goto release;
|
|
@@ -2630,8 +2629,7 @@ static int set_new_data_offset(struct mdinfo *sra, struct supertype *st,
|
|
}
|
|
if (err < 0) {
|
|
if (errno == E2BIG && data_offset != INVALID_SECTORS) {
|
|
- pr_err("data-offset is too big for %s\n",
|
|
- dn);
|
|
+ pr_err("data-offset is too big for %s\n", dn);
|
|
goto release;
|
|
}
|
|
if (sd == sra->devs &&
|
|
@@ -2641,8 +2639,7 @@ static int set_new_data_offset(struct mdinfo *sra, struct supertype *st,
|
|
* For RAID5/6 this is not fatal
|
|
*/
|
|
return 1;
|
|
- pr_err("Cannot set new_offset for %s\n",
|
|
- dn);
|
|
+ pr_err("Cannot set new_offset for %s\n", dn);
|
|
break;
|
|
}
|
|
}
|
|
@@ -2688,8 +2685,7 @@ static int raid10_reshape(char *container, int fd, char *devname,
|
|
GET_COMPONENT|GET_DEVS|GET_OFFSET|GET_STATE|GET_CHUNK
|
|
);
|
|
if (!sra) {
|
|
- pr_err("%s: Cannot get array details from sysfs\n",
|
|
- devname);
|
|
+ pr_err("%s: Cannot get array details from sysfs\n", devname);
|
|
goto release;
|
|
}
|
|
min = reshape->min_offset_change;
|
|
@@ -2697,18 +2693,16 @@ static int raid10_reshape(char *container, int fd, char *devname,
|
|
if (info->delta_disks)
|
|
sysfs_set_str(sra, NULL, "reshape_direction",
|
|
info->delta_disks < 0 ? "backwards" : "forwards");
|
|
- if (info->delta_disks < 0 &&
|
|
- info->space_after < min) {
|
|
+ if (info->delta_disks < 0 && info->space_after < min) {
|
|
int rv = sysfs_set_num(sra, NULL, "component_size",
|
|
- (sra->component_size -
|
|
- min)/2);
|
|
+ (sra->component_size - min)/2);
|
|
if (rv) {
|
|
pr_err("cannot reduce component size\n");
|
|
goto release;
|
|
}
|
|
}
|
|
- err = set_new_data_offset(sra, st, devname, info->delta_disks, data_offset,
|
|
- min, 0);
|
|
+ err = set_new_data_offset(sra, st, devname, info->delta_disks,
|
|
+ data_offset, min, 0);
|
|
if (err == 1) {
|
|
pr_err("Cannot set new_data_offset: RAID10 reshape not\n");
|
|
cont_err("supported on this kernel\n");
|
|
@@ -2719,10 +2713,12 @@ static int raid10_reshape(char *container, int fd, char *devname,
|
|
|
|
if (!err && sysfs_set_num(sra, NULL, "chunk_size", info->new_chunk) < 0)
|
|
err = errno;
|
|
- if (!err && sysfs_set_num(sra, NULL, "layout", reshape->after.layout) < 0)
|
|
+ if (!err && sysfs_set_num(sra, NULL, "layout",
|
|
+ reshape->after.layout) < 0)
|
|
err = errno;
|
|
- if (!err && sysfs_set_num(sra, NULL, "raid_disks",
|
|
- info->array.raid_disks + info->delta_disks) < 0)
|
|
+ if (!err &&
|
|
+ sysfs_set_num(sra, NULL, "raid_disks",
|
|
+ info->array.raid_disks + info->delta_disks) < 0)
|
|
err = errno;
|
|
if (!err && sysfs_set_str(sra, NULL, "sync_action", "reshape") < 0)
|
|
err = errno;
|
|
@@ -2873,8 +2869,7 @@ static int impose_reshape(struct mdinfo *sra,
|
|
reshape->parity) < 0)
|
|
err = errno;
|
|
if (err) {
|
|
- pr_err("Cannot set device shape for %s\n",
|
|
- devname);
|
|
+ pr_err("Cannot set device shape for %s\n", devname);
|
|
|
|
if (err == EBUSY &&
|
|
(array.state & (1<<MD_SB_BITMAP_PRESENT)))
|
|
@@ -2899,8 +2894,7 @@ static int impose_level(int fd, int level, char *devname, int verbose)
|
|
}
|
|
|
|
md_get_array_info(fd, &array);
|
|
- if (level == 0 &&
|
|
- (array.level >= 4 && array.level <= 6)) {
|
|
+ if (level == 0 && (array.level >= 4 && array.level <= 6)) {
|
|
/* To convert to RAID0 we need to fail and
|
|
* remove any non-data devices. */
|
|
int found = 0;
|
|
@@ -2908,17 +2902,14 @@ static int impose_level(int fd, int level, char *devname, int verbose)
|
|
int data_disks = array.raid_disks - 1;
|
|
if (array.level == 6)
|
|
data_disks -= 1;
|
|
- if (array.level == 5 &&
|
|
- array.layout != ALGORITHM_PARITY_N)
|
|
+ if (array.level == 5 && array.layout != ALGORITHM_PARITY_N)
|
|
return -1;
|
|
- if (array.level == 6 &&
|
|
- array.layout != ALGORITHM_PARITY_N_6)
|
|
+ if (array.level == 6 && array.layout != ALGORITHM_PARITY_N_6)
|
|
return -1;
|
|
sysfs_set_str(&info, NULL,"sync_action", "idle");
|
|
/* First remove any spares so no recovery starts */
|
|
for (d = 0, found = 0;
|
|
- d < MAX_DISKS && found < array.nr_disks;
|
|
- d++) {
|
|
+ d < MAX_DISKS && found < array.nr_disks; d++) {
|
|
mdu_disk_info_t disk;
|
|
disk.number = d;
|
|
if (md_get_disk_info(fd, &disk) < 0)
|
|
@@ -2936,8 +2927,7 @@ static int impose_level(int fd, int level, char *devname, int verbose)
|
|
/* Now fail anything left */
|
|
md_get_array_info(fd, &array);
|
|
for (d = 0, found = 0;
|
|
- d < MAX_DISKS && found < array.nr_disks;
|
|
- d++) {
|
|
+ d < MAX_DISKS && found < array.nr_disks; d++) {
|
|
mdu_disk_info_t disk;
|
|
disk.number = d;
|
|
if (md_get_disk_info(fd, &disk) < 0)
|
|
@@ -2967,8 +2957,7 @@ static int impose_level(int fd, int level, char *devname, int verbose)
|
|
return err;
|
|
}
|
|
if (verbose >= 0)
|
|
- pr_err("level of %s changed to %s\n",
|
|
- devname, c);
|
|
+ pr_err("level of %s changed to %s\n", devname, c);
|
|
}
|
|
return 0;
|
|
}
|
|
@@ -3003,10 +2992,9 @@ static int continue_via_systemd(char *devnm)
|
|
*/
|
|
close(2);
|
|
open("/dev/null", O_WRONLY);
|
|
- snprintf(pathbuf, sizeof(pathbuf), "mdadm-grow-continue@%s.service",
|
|
- devnm);
|
|
- status = execl("/usr/bin/systemctl", "systemctl",
|
|
- "restart",
|
|
+ snprintf(pathbuf, sizeof(pathbuf),
|
|
+ "mdadm-grow-continue@%s.service", devnm);
|
|
+ status = execl("/usr/bin/systemctl", "systemctl", "restart",
|
|
pathbuf, NULL);
|
|
status = execl("/bin/systemctl", "systemctl", "restart",
|
|
pathbuf, NULL);
|
|
@@ -3088,17 +3076,17 @@ static int reshape_array(char *container, int fd, char *devname,
|
|
pr_err("%s\n", msg);
|
|
goto release;
|
|
}
|
|
- if (restart &&
|
|
- (reshape.level != info->array.level ||
|
|
- reshape.before.layout != info->array.layout ||
|
|
- reshape.before.data_disks + reshape.parity !=
|
|
- info->array.raid_disks - max(0, info->delta_disks))) {
|
|
+ if (restart && (reshape.level != info->array.level ||
|
|
+ reshape.before.layout != info->array.layout ||
|
|
+ reshape.before.data_disks + reshape.parity !=
|
|
+ info->array.raid_disks - max(0, info->delta_disks))) {
|
|
pr_err("reshape info is not in native format - cannot continue.\n");
|
|
goto release;
|
|
}
|
|
|
|
if (st->ss->external && restart && (info->reshape_progress == 0) &&
|
|
- !((sysfs_get_str(info, NULL, "sync_action", buf, sizeof(buf)) > 0) &&
|
|
+ !((sysfs_get_str(info, NULL, "sync_action",
|
|
+ buf, sizeof(buf)) > 0) &&
|
|
(strncmp(buf, "reshape", 7) == 0))) {
|
|
/* When reshape is restarted from '0', very begin of array
|
|
* it is possible that for external metadata reshape and array
|
|
@@ -3112,7 +3100,10 @@ static int reshape_array(char *container, int fd, char *devname,
|
|
restart = 0;
|
|
}
|
|
if (restart) {
|
|
- /* reshape already started. just skip to monitoring the reshape */
|
|
+ /*
|
|
+ * reshape already started. just skip to monitoring
|
|
+ * the reshape
|
|
+ */
|
|
if (reshape.backup_blocks == 0)
|
|
return 0;
|
|
if (restart & RESHAPE_NO_BACKUP)
|
|
@@ -3120,8 +3111,8 @@ static int reshape_array(char *container, int fd, char *devname,
|
|
|
|
/* Need 'sra' down at 'started:' */
|
|
sra = sysfs_read(fd, NULL,
|
|
- GET_COMPONENT|GET_DEVS|GET_OFFSET|GET_STATE|GET_CHUNK|
|
|
- GET_CACHE);
|
|
+ GET_COMPONENT|GET_DEVS|GET_OFFSET|GET_STATE|
|
|
+ GET_CHUNK|GET_CACHE);
|
|
if (!sra) {
|
|
pr_err("%s: Cannot get array details from sysfs\n",
|
|
devname);
|
|
@@ -3144,11 +3135,10 @@ static int reshape_array(char *container, int fd, char *devname,
|
|
for (dv = devlist; dv ; dv=dv->next)
|
|
added_disks++;
|
|
spares_needed = max(reshape.before.data_disks,
|
|
- reshape.after.data_disks)
|
|
- + reshape.parity - array.raid_disks;
|
|
+ reshape.after.data_disks) +
|
|
+ reshape.parity - array.raid_disks;
|
|
|
|
- if (!force &&
|
|
- info->new_level > 1 && info->array.level > 1 &&
|
|
+ if (!force && info->new_level > 1 && info->array.level > 1 &&
|
|
spares_needed > info->array.spare_disks + added_disks) {
|
|
pr_err("Need %d spare%s to avoid degraded array, and only have %d.\n"
|
|
" Use --force to over-ride this check.\n",
|
|
@@ -3164,8 +3154,7 @@ static int reshape_array(char *container, int fd, char *devname,
|
|
if ((info->new_level > 1 || info->new_level == 0) &&
|
|
spares_needed > info->array.spare_disks +added_disks) {
|
|
pr_err("Need %d spare%s to create working array, and only have %d.\n",
|
|
- spares_needed,
|
|
- spares_needed == 1 ? "" : "s",
|
|
+ spares_needed, spares_needed == 1 ? "" : "s",
|
|
info->array.spare_disks + added_disks);
|
|
goto release;
|
|
}
|
|
@@ -3187,8 +3176,7 @@ static int reshape_array(char *container, int fd, char *devname,
|
|
if (!mdmon_running(container))
|
|
start_mdmon(container);
|
|
ping_monitor(container);
|
|
- if (mdmon_running(container) &&
|
|
- st->update_tail == NULL)
|
|
+ if (mdmon_running(container) && st->update_tail == NULL)
|
|
st->update_tail = &st->updates;
|
|
}
|
|
}
|
|
@@ -3215,7 +3203,8 @@ static int reshape_array(char *container, int fd, char *devname,
|
|
* be rejected.
|
|
*/
|
|
if (reshape.backup_blocks &&
|
|
- reshape.after.data_disks > reshape.before.data_disks)
|
|
+ reshape.after.data_disks >
|
|
+ reshape.before.data_disks)
|
|
subarray_set_num(container, info2, "raid_disks",
|
|
reshape.after.data_disks +
|
|
reshape.parity);
|
|
@@ -3236,8 +3225,7 @@ static int reshape_array(char *container, int fd, char *devname,
|
|
* level and frozen, we can safely add them.
|
|
*/
|
|
if (devlist) {
|
|
- if (Manage_subdevs(devname, fd, devlist, verbose,
|
|
- 0, NULL, 0))
|
|
+ if (Manage_subdevs(devname, fd, devlist, verbose, 0, NULL, 0))
|
|
goto release;
|
|
}
|
|
|
|
@@ -3264,9 +3252,9 @@ static int reshape_array(char *container, int fd, char *devname,
|
|
printf("layout for %s set to %d\n",
|
|
devname, array.layout);
|
|
}
|
|
- if (info->delta_disks != UnSet &&
|
|
- info->delta_disks != 0 &&
|
|
- array.raid_disks != (info->array.raid_disks + info->delta_disks)) {
|
|
+ if (info->delta_disks != UnSet && info->delta_disks != 0 &&
|
|
+ array.raid_disks !=
|
|
+ (info->array.raid_disks + info->delta_disks)) {
|
|
array.raid_disks += info->delta_disks;
|
|
if (md_set_array_info(fd, &array) != 0) {
|
|
pr_err("failed to set raid disks\n");
|
|
@@ -3343,8 +3331,7 @@ static int reshape_array(char *container, int fd, char *devname,
|
|
/* Nothing to do. */
|
|
return 0;
|
|
return raid10_reshape(container, fd, devname, st, info,
|
|
- &reshape, data_offset,
|
|
- force, verbose);
|
|
+ &reshape, data_offset, force, verbose);
|
|
}
|
|
sra = sysfs_read(fd, NULL,
|
|
GET_COMPONENT|GET_DEVS|GET_OFFSET|GET_STATE|GET_CHUNK|
|
|
@@ -3428,15 +3415,13 @@ started:
|
|
* not so big that we reject it below.
|
|
* Try for 16 megabytes
|
|
*/
|
|
- while (blocks * 32 < sra->component_size &&
|
|
- blocks < 16*1024*2)
|
|
+ while (blocks * 32 < sra->component_size && blocks < 16*1024*2)
|
|
blocks *= 2;
|
|
} else
|
|
pr_err("Need to backup %luK of critical section..\n", blocks/2);
|
|
|
|
if (blocks >= sra->component_size/2) {
|
|
- pr_err("%s: Something wrong - reshape aborted\n",
|
|
- devname);
|
|
+ pr_err("%s: Something wrong - reshape aborted\n", devname);
|
|
goto release;
|
|
}
|
|
|
|
@@ -3449,9 +3434,8 @@ started:
|
|
offsets = xcalloc((1+nrdisks), sizeof(offsets[0]));
|
|
|
|
odisks = reshape.before.data_disks + reshape.parity;
|
|
- d = reshape_prepare_fdlist(devname, sra, odisks,
|
|
- nrdisks, blocks, backup_file,
|
|
- fdlist, offsets);
|
|
+ d = reshape_prepare_fdlist(devname, sra, odisks, nrdisks, blocks,
|
|
+ backup_file, fdlist, offsets);
|
|
if (d < odisks) {
|
|
goto release;
|
|
}
|
|
@@ -3472,8 +3456,7 @@ started:
|
|
if (!reshape_open_backup_file(backup_file, fd, devname,
|
|
(signed)blocks,
|
|
fdlist+d, offsets+d,
|
|
- sra->sys_name,
|
|
- restart)) {
|
|
+ sra->sys_name, restart)) {
|
|
goto release;
|
|
}
|
|
d++;
|
|
@@ -3481,8 +3464,8 @@ started:
|
|
}
|
|
|
|
update_cache_size(container, sra, info,
|
|
- min(reshape.before.data_disks, reshape.after.data_disks),
|
|
- blocks);
|
|
+ min(reshape.before.data_disks,
|
|
+ reshape.after.data_disks), blocks);
|
|
|
|
/* Right, everything seems fine. Let's kick things off.
|
|
* If only changing raid_disks, use ioctl, else use
|
|
@@ -3498,8 +3481,7 @@ started:
|
|
reshape.after.data_disks);
|
|
if (err) {
|
|
pr_err("Cannot %s reshape for %s\n",
|
|
- restart ? "continue" : "start",
|
|
- devname);
|
|
+ restart ? "continue" : "start", devname);
|
|
goto release;
|
|
}
|
|
if (restart)
|
|
@@ -3554,8 +3536,7 @@ started:
|
|
mds = mdstat_read(1, 0);
|
|
for (m = mds; m; m = m->next)
|
|
if (strcmp(m->devnm, sra->sys_name) == 0) {
|
|
- if (m->resync &&
|
|
- m->percent == RESYNC_DELAYED)
|
|
+ if (m->resync && m->percent == RESYNC_DELAYED)
|
|
delayed = 1;
|
|
if (m->resync == 0)
|
|
/* Haven't started the reshape thread
|
|
@@ -3587,15 +3568,12 @@ started:
|
|
/* metadata handler takes it from here */
|
|
done = st->ss->manage_reshape(
|
|
fd, sra, &reshape, st, blocks,
|
|
- fdlist, offsets,
|
|
- d - odisks, fdlist+odisks,
|
|
- offsets+odisks);
|
|
+ fdlist, offsets, d - odisks, fdlist + odisks,
|
|
+ offsets + odisks);
|
|
} else
|
|
done = child_monitor(
|
|
- fd, sra, &reshape, st, blocks,
|
|
- fdlist, offsets,
|
|
- d - odisks, fdlist+odisks,
|
|
- offsets+odisks);
|
|
+ fd, sra, &reshape, st, blocks, fdlist, offsets,
|
|
+ d - odisks, fdlist + odisks, offsets + odisks);
|
|
|
|
free(fdlist);
|
|
free(offsets);
|
|
@@ -3646,8 +3624,7 @@ started:
|
|
/* set new array size if required customer_array_size is used
|
|
* by this metadata.
|
|
*/
|
|
- if (reshape.before.data_disks !=
|
|
- reshape.after.data_disks &&
|
|
+ if (reshape.before.data_disks != reshape.after.data_disks &&
|
|
info->custom_array_size)
|
|
set_array_size(st, info, info->text_version);
|
|
|
|
@@ -3786,7 +3763,8 @@ int reshape_container(char *container, char *devname,
|
|
|
|
fd = open_dev(mdstat->devnm);
|
|
if (fd < 0) {
|
|
- pr_err("Device %s cannot be opened for reshape.\n", adev);
|
|
+ pr_err("Device %s cannot be opened for reshape.\n",
|
|
+ adev);
|
|
break;
|
|
}
|
|
|
|
@@ -3973,8 +3951,7 @@ int progress_reshape(struct mdinfo *info, struct reshape *reshape,
|
|
max_progress = backup_point;
|
|
else
|
|
max_progress =
|
|
- read_offset *
|
|
- reshape->after.data_disks;
|
|
+ read_offset * reshape->after.data_disks;
|
|
} else {
|
|
if (read_offset > write_offset - write_range)
|
|
/* Can only progress as far as has been backed up,
|
|
@@ -3989,8 +3966,7 @@ int progress_reshape(struct mdinfo *info, struct reshape *reshape,
|
|
else {
|
|
/* Can progress until metadata update is required */
|
|
max_progress =
|
|
- read_offset *
|
|
- reshape->after.data_disks;
|
|
+ read_offset * reshape->after.data_disks;
|
|
/* but data must be suspended */
|
|
if (max_progress < *suspend_point)
|
|
max_progress = *suspend_point;
|
|
@@ -4039,7 +4015,8 @@ int progress_reshape(struct mdinfo *info, struct reshape *reshape,
|
|
*suspend_point > 0) {
|
|
*suspend_point = 0;
|
|
sysfs_set_num(info, NULL, "suspend_lo", 0);
|
|
- sysfs_set_num(info, NULL, "suspend_hi", need_backup);
|
|
+ sysfs_set_num(info, NULL, "suspend_hi",
|
|
+ need_backup);
|
|
}
|
|
} else {
|
|
/* Need to suspend continually */
|
|
@@ -4070,7 +4047,10 @@ int progress_reshape(struct mdinfo *info, struct reshape *reshape,
|
|
*/
|
|
/* scale down max_progress to per_disk */
|
|
max_progress /= reshape->after.data_disks;
|
|
- /* Round to chunk size as some kernels give an erroneously high number */
|
|
+ /*
|
|
+ * Round to chunk size as some kernels give an erroneously
|
|
+ * high number
|
|
+ */
|
|
max_progress /= info->new_chunk/512;
|
|
max_progress *= info->new_chunk/512;
|
|
/* And round to old chunk size as the kernel wants that */
|
|
@@ -4107,8 +4087,7 @@ int progress_reshape(struct mdinfo *info, struct reshape *reshape,
|
|
* waiting forever on a dead array
|
|
*/
|
|
char action[20];
|
|
- if (sysfs_get_str(info, NULL, "sync_action",
|
|
- action, 20) <= 0 ||
|
|
+ if (sysfs_get_str(info, NULL, "sync_action", action, 20) <= 0 ||
|
|
strncmp(action, "reshape", 7) != 0)
|
|
break;
|
|
/* Some kernels reset 'sync_completed' to zero
|
|
@@ -4121,8 +4100,8 @@ int progress_reshape(struct mdinfo *info, struct reshape *reshape,
|
|
break;
|
|
if (completed == 0 && !advancing &&
|
|
strncmp(action, "idle", 4) == 0 &&
|
|
- info->reshape_progress < (info->component_size
|
|
- * reshape->after.data_disks))
|
|
+ info->reshape_progress <
|
|
+ (info->component_size * reshape->after.data_disks))
|
|
break;
|
|
sysfs_wait(fd, NULL);
|
|
if (sysfs_fd_get_ll(fd, &completed) < 0)
|
|
@@ -4135,8 +4114,7 @@ int progress_reshape(struct mdinfo *info, struct reshape *reshape,
|
|
if (completed == 0) {
|
|
unsigned long long reshapep;
|
|
char action[20];
|
|
- if (sysfs_get_str(info, NULL, "sync_action",
|
|
- action, 20) > 0 &&
|
|
+ if (sysfs_get_str(info, NULL, "sync_action", action, 20) > 0 &&
|
|
strncmp(action, "idle", 4) == 0 &&
|
|
sysfs_get_ll(info, NULL,
|
|
"reshape_position", &reshapep) == 0)
|
|
@@ -4174,8 +4152,7 @@ check_progress:
|
|
* functioning.
|
|
*/
|
|
if (sysfs_get_str(info, NULL, "reshape_position", buf,
|
|
- sizeof(buf)) < 0 ||
|
|
- strncmp(buf, "none", 4) != 0) {
|
|
+ sizeof(buf)) < 0 || strncmp(buf, "none", 4) != 0) {
|
|
/* The abort might only be temporary. Wait up to 10
|
|
* seconds for fd to contain a valid number again.
|
|
*/
|
|
@@ -4192,7 +4169,8 @@ check_progress:
|
|
/* If "sync_max" is no longer max_progress
|
|
* we need to freeze things
|
|
*/
|
|
- sysfs_get_ll(info, NULL, "sync_max", &new_sync_max);
|
|
+ sysfs_get_ll(info, NULL, "sync_max",
|
|
+ &new_sync_max);
|
|
*frozen = (new_sync_max != max_progress);
|
|
break;
|
|
case -2: /* read error - abort */
|
|
@@ -4283,15 +4261,14 @@ static int grow_backup(struct mdinfo *sra,
|
|
bsb.magic[15] = '2';
|
|
for (i = 0; i < dests; i++)
|
|
if (part)
|
|
- lseek64(destfd[i], destoffsets[i] + __le64_to_cpu(bsb.devstart2)*512, 0);
|
|
+ lseek64(destfd[i], destoffsets[i] +
|
|
+ __le64_to_cpu(bsb.devstart2)*512, 0);
|
|
else
|
|
lseek64(destfd[i], destoffsets[i], 0);
|
|
|
|
- rv = save_stripes(sources, offsets,
|
|
- disks, chunk, level, layout,
|
|
- dests, destfd,
|
|
- offset*512*odata, stripes * chunk * odata,
|
|
- buf);
|
|
+ rv = save_stripes(sources, offsets, disks, chunk, level, layout,
|
|
+ dests, destfd, offset * 512 * odata,
|
|
+ stripes * chunk * odata, buf);
|
|
|
|
if (rv)
|
|
return rv;
|
|
@@ -4299,7 +4276,8 @@ static int grow_backup(struct mdinfo *sra,
|
|
for (i = 0; i < dests; i++) {
|
|
bsb.devstart = __cpu_to_le64(destoffsets[i]/512);
|
|
|
|
- bsb.sb_csum = bsb_csum((char*)&bsb, ((char*)&bsb.sb_csum)-((char*)&bsb));
|
|
+ bsb.sb_csum = bsb_csum((char*)&bsb,
|
|
+ ((char*)&bsb.sb_csum)-((char*)&bsb));
|
|
if (memcmp(bsb.magic, "md_backup_data-2", 16) == 0)
|
|
bsb.sb_csum2 = bsb_csum((char*)&bsb,
|
|
((char*)&bsb.sb_csum2)-((char*)&bsb));
|
|
@@ -4357,15 +4335,15 @@ static int forget_backup(int dests, int *destfd,
|
|
rv = 0;
|
|
for (i = 0; i < dests; i++) {
|
|
bsb.devstart = __cpu_to_le64(destoffsets[i]/512);
|
|
- bsb.sb_csum = bsb_csum((char*)&bsb, ((char*)&bsb.sb_csum)-((char*)&bsb));
|
|
+ bsb.sb_csum = bsb_csum((char*)&bsb,
|
|
+ ((char*)&bsb.sb_csum)-((char*)&bsb));
|
|
if (memcmp(bsb.magic, "md_backup_data-2", 16) == 0)
|
|
bsb.sb_csum2 = bsb_csum((char*)&bsb,
|
|
((char*)&bsb.sb_csum2)-((char*)&bsb));
|
|
if ((unsigned long long)lseek64(destfd[i], destoffsets[i]-4096, 0) !=
|
|
destoffsets[i]-4096)
|
|
rv = -1;
|
|
- if (rv == 0 &&
|
|
- write(destfd[i], &bsb, 512) != 512)
|
|
+ if (rv == 0 && write(destfd[i], &bsb, 512) != 512)
|
|
rv = -1;
|
|
fsync(destfd[i]);
|
|
}
|
|
@@ -4481,9 +4459,10 @@ int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape,
|
|
unsigned long long backup_point, wait_point;
|
|
unsigned long long reshape_completed;
|
|
int done = 0;
|
|
- int increasing = reshape->after.data_disks >= reshape->before.data_disks;
|
|
- int part = 0; /* The next part of the backup area to fill. It may already
|
|
- * be full, so we need to check */
|
|
+ int increasing = reshape->after.data_disks >=
|
|
+ reshape->before.data_disks;
|
|
+ int part = 0; /* The next part of the backup area to fill. It
|
|
+ * may already be full, so we need to check */
|
|
int level = reshape->level;
|
|
int layout = reshape->before.layout;
|
|
int data = reshape->before.data_disks;
|
|
@@ -4647,11 +4626,9 @@ int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape,
|
|
}
|
|
if (actual_stripes == 0)
|
|
break;
|
|
- grow_backup(sra, offset, actual_stripes,
|
|
- fds, offsets,
|
|
- disks, chunk, level, layout,
|
|
- dests, destfd, destoffsets,
|
|
- part, °raded, buf);
|
|
+ grow_backup(sra, offset, actual_stripes, fds, offsets,
|
|
+ disks, chunk, level, layout, dests, destfd,
|
|
+ destoffsets, part, °raded, buf);
|
|
validate(afd, destfd[0], destoffsets[0]);
|
|
/* record where 'part' is up to */
|
|
part = !part;
|
|
@@ -4680,8 +4657,8 @@ int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape,
|
|
* write that data into the array and update the super blocks with
|
|
* the new reshape_progress
|
|
*/
|
|
-int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, int cnt,
|
|
- char *backup_file, int verbose)
|
|
+int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist,
|
|
+ int cnt, char *backup_file, int verbose)
|
|
{
|
|
int i, j;
|
|
int old_disks;
|
|
@@ -4690,9 +4667,11 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, int cnt
|
|
int ndata, odata;
|
|
|
|
odata = info->array.raid_disks - info->delta_disks - 1;
|
|
- if (info->array.level == 6) odata--; /* number of data disks */
|
|
+ if (info->array.level == 6)
|
|
+ odata--; /* number of data disks */
|
|
ndata = info->array.raid_disks - 1;
|
|
- if (info->new_level == 6) ndata--;
|
|
+ if (info->new_level == 6)
|
|
+ ndata--;
|
|
|
|
old_disks = info->array.raid_disks - info->delta_disks;
|
|
|
|
@@ -4755,24 +4734,30 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, int cnt
|
|
}
|
|
if (bsb.sb_csum != bsb_csum((char*)&bsb, ((char*)&bsb.sb_csum)-((char*)&bsb))) {
|
|
if (verbose)
|
|
- pr_err("Bad backup-metadata checksum on %s\n", devname);
|
|
+ pr_err("Bad backup-metadata checksum on %s\n",
|
|
+ devname);
|
|
continue; /* bad checksum */
|
|
}
|
|
if (memcmp(bsb.magic, "md_backup_data-2", 16) == 0 &&
|
|
bsb.sb_csum2 != bsb_csum((char*)&bsb, ((char*)&bsb.sb_csum2)-((char*)&bsb))) {
|
|
if (verbose)
|
|
- pr_err("Bad backup-metadata checksum2 on %s\n", devname);
|
|
+ pr_err("Bad backup-metadata checksum2 on %s\n",
|
|
+ devname);
|
|
continue; /* Bad second checksum */
|
|
}
|
|
if (memcmp(bsb.set_uuid,info->uuid, 16) != 0) {
|
|
if (verbose)
|
|
- pr_err("Wrong uuid on backup-metadata on %s\n", devname);
|
|
+ pr_err("Wrong uuid on backup-metadata on %s\n",
|
|
+ devname);
|
|
continue; /* Wrong uuid */
|
|
}
|
|
|
|
- /* array utime and backup-mtime should be updated at much the same time, but it seems that
|
|
- * sometimes they aren't... So allow considerable flexability in matching, and allow
|
|
- * this test to be overridden by an environment variable.
|
|
+ /*
|
|
+ * array utime and backup-mtime should be updated at
|
|
+ * much the same time, but it seems that sometimes
|
|
+ * they aren't... So allow considerable flexability in
|
|
+ * matching, and allow this test to be overridden by
|
|
+ * an environment variable.
|
|
*/
|
|
if(time_after(info->array.utime, (unsigned int)__le64_to_cpu(bsb.mtime) + 2*60*60) ||
|
|
time_before(info->array.utime, (unsigned int)__le64_to_cpu(bsb.mtime) - 10*60)) {
|
|
@@ -4859,12 +4844,10 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, int cnt
|
|
}
|
|
printf("%s: restoring critical section\n", Name);
|
|
|
|
- if (restore_stripes(fdlist, offsets,
|
|
- info->array.raid_disks,
|
|
- info->new_chunk,
|
|
- info->new_level,
|
|
- info->new_layout,
|
|
- fd, __le64_to_cpu(bsb.devstart)*512,
|
|
+ if (restore_stripes(fdlist, offsets, info->array.raid_disks,
|
|
+ info->new_chunk, info->new_level,
|
|
+ info->new_layout, fd,
|
|
+ __le64_to_cpu(bsb.devstart)*512,
|
|
__le64_to_cpu(bsb.arraystart)*512,
|
|
__le64_to_cpu(bsb.length)*512, NULL)) {
|
|
/* didn't succeed, so giveup */
|
|
@@ -4876,12 +4859,10 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, int cnt
|
|
}
|
|
|
|
if (bsb.magic[15] == '2' &&
|
|
- restore_stripes(fdlist, offsets,
|
|
- info->array.raid_disks,
|
|
- info->new_chunk,
|
|
- info->new_level,
|
|
- info->new_layout,
|
|
- fd, __le64_to_cpu(bsb.devstart)*512 +
|
|
+ restore_stripes(fdlist, offsets, info->array.raid_disks,
|
|
+ info->new_chunk, info->new_level,
|
|
+ info->new_layout, fd,
|
|
+ __le64_to_cpu(bsb.devstart)*512 +
|
|
__le64_to_cpu(bsb.devstart2)*512,
|
|
__le64_to_cpu(bsb.arraystart2)*512,
|
|
__le64_to_cpu(bsb.length2)*512, NULL)) {
|
|
@@ -4914,15 +4895,16 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, int cnt
|
|
else
|
|
lo = lo1;
|
|
}
|
|
- if (lo < hi &&
|
|
- (info->reshape_progress < lo ||
|
|
- info->reshape_progress > hi))
|
|
+ if (lo < hi && (info->reshape_progress < lo ||
|
|
+ info->reshape_progress > hi))
|
|
/* backup does not affect reshape_progress*/ ;
|
|
else if (info->delta_disks >= 0) {
|
|
info->reshape_progress = __le64_to_cpu(bsb.arraystart) +
|
|
__le64_to_cpu(bsb.length);
|
|
if (bsb.magic[15] == '2') {
|
|
- unsigned long long p2 = __le64_to_cpu(bsb.arraystart2) +
|
|
+ unsigned long long p2;
|
|
+
|
|
+ p2 = __le64_to_cpu(bsb.arraystart2) +
|
|
__le64_to_cpu(bsb.length2);
|
|
if (p2 > info->reshape_progress)
|
|
info->reshape_progress = p2;
|
|
@@ -4930,7 +4912,9 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, int cnt
|
|
} else {
|
|
info->reshape_progress = __le64_to_cpu(bsb.arraystart);
|
|
if (bsb.magic[15] == '2') {
|
|
- unsigned long long p2 = __le64_to_cpu(bsb.arraystart2);
|
|
+ unsigned long long p2;
|
|
+
|
|
+ p2 = __le64_to_cpu(bsb.arraystart2);
|
|
if (p2 < info->reshape_progress)
|
|
info->reshape_progress = p2;
|
|
}
|
|
@@ -4942,8 +4926,7 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, int cnt
|
|
continue;
|
|
st->ss->getinfo_super(st, &dinfo, NULL);
|
|
dinfo.reshape_progress = info->reshape_progress;
|
|
- st->ss->update_super(st, &dinfo,
|
|
- "_reshape_progress",
|
|
+ st->ss->update_super(st, &dinfo, "_reshape_progress",
|
|
NULL,0, 0, NULL);
|
|
st->ss->store_super(st, fdlist[j]);
|
|
st->ss->free_super(st);
|
|
@@ -5004,13 +4987,11 @@ int Grow_continue_command(char *devname, int fd,
|
|
int cfd = -1;
|
|
int fd2;
|
|
|
|
- dprintf("Grow continue from command line called for %s\n",
|
|
- devname);
|
|
+ dprintf("Grow continue from command line called for %s\n", devname);
|
|
|
|
st = super_by_fd(fd, &subarray);
|
|
if (!st || !st->ss) {
|
|
- pr_err("Unable to determine metadata format for %s\n",
|
|
- devname);
|
|
+ pr_err("Unable to determine metadata format for %s\n", devname);
|
|
return 1;
|
|
}
|
|
dprintf("Grow continue is run for ");
|
|
@@ -5090,8 +5071,7 @@ int Grow_continue_command(char *devname, int fd,
|
|
*/
|
|
ret_val = st->ss->load_container(st, cfd, NULL);
|
|
if (ret_val) {
|
|
- pr_err("Cannot read superblock for %s\n",
|
|
- devname);
|
|
+ pr_err("Cannot read superblock for %s\n", devname);
|
|
ret_val = 1;
|
|
goto Grow_continue_command_exit;
|
|
}
|
|
@@ -5213,15 +5193,13 @@ int Grow_continue(int mdfd, struct supertype *st, struct mdinfo *info,
|
|
st->ss->load_container(st, cfd, st->container_devnm);
|
|
close(cfd);
|
|
ret_val = reshape_container(st->container_devnm, NULL, mdfd,
|
|
- st, info, 0, backup_file,
|
|
- 0, forked,
|
|
- 1 | info->reshape_active,
|
|
+ st, info, 0, backup_file, 0,
|
|
+ forked, 1 | info->reshape_active,
|
|
freeze_reshape);
|
|
} else
|
|
ret_val = reshape_array(NULL, mdfd, "array", st, info, 1,
|
|
- NULL, INVALID_SECTORS,
|
|
- backup_file, 0, forked,
|
|
- 1 | info->reshape_active,
|
|
+ NULL, INVALID_SECTORS, backup_file,
|
|
+ 0, forked, 1 | info->reshape_active,
|
|
freeze_reshape);
|
|
|
|
return ret_val;
|
|
@@ -5244,8 +5222,7 @@ char *locate_backup(char *name)
|
|
char *fl = make_backup(name);
|
|
struct stat stb;
|
|
|
|
- if (stat(fl, &stb) == 0 &&
|
|
- S_ISREG(stb.st_mode))
|
|
+ if (stat(fl, &stb) == 0 && S_ISREG(stb.st_mode))
|
|
return fl;
|
|
|
|
free(fl);
|
|
--
|
|
2.13.6
|
|
|