|
|
2c1b57 |
From 6ebf34e6bdd9e952d00ad3c2f12a130bfb68965e Mon Sep 17 00:00:00 2001
|
|
|
2c1b57 |
From: Jes Sorensen <Jes.Sorensen@gmail.com>
|
|
|
2c1b57 |
Date: Wed, 29 Mar 2017 12:15:20 -0400
|
|
|
2c1b57 |
Subject: [RHEL7.5 PATCH 036/169] Grow: Fixup a pile of cosmetic issues
|
|
|
2c1b57 |
|
|
|
2c1b57 |
No code change, simply cleanup ugliness.
|
|
|
2c1b57 |
|
|
|
2c1b57 |
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
|
|
|
2c1b57 |
---
|
|
|
2c1b57 |
Grow.c | 60 ++++++++++++++++++++++++++++++++----------------------------
|
|
|
2c1b57 |
1 file changed, 32 insertions(+), 28 deletions(-)
|
|
|
2c1b57 |
|
|
|
2c1b57 |
diff --git a/Grow.c b/Grow.c
|
|
|
2c1b57 |
index b86b53e..6405f0e 100755
|
|
|
2c1b57 |
--- a/Grow.c
|
|
|
2c1b57 |
+++ b/Grow.c
|
|
|
2c1b57 |
@@ -1269,8 +1269,7 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
|
|
|
2c1b57 |
* raid5 with 2 disks, or
|
|
|
2c1b57 |
* raid0 with 1 disk
|
|
|
2c1b57 |
*/
|
|
|
2c1b57 |
- if (info->new_level > 1 &&
|
|
|
2c1b57 |
- (info->component_size & 7))
|
|
|
2c1b57 |
+ if (info->new_level > 1 && (info->component_size & 7))
|
|
|
2c1b57 |
return "Cannot convert RAID1 of this size - reduce size to multiple of 4K first.";
|
|
|
2c1b57 |
if (info->new_level == 0) {
|
|
|
2c1b57 |
if (info->delta_disks != UnSet &&
|
|
|
2c1b57 |
@@ -1288,12 +1287,9 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
|
|
|
2c1b57 |
re->level = 1;
|
|
|
2c1b57 |
return NULL;
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
- if (info->array.raid_disks != 2 &&
|
|
|
2c1b57 |
- info->new_level == 5)
|
|
|
2c1b57 |
+ if (info->array.raid_disks != 2 && info->new_level == 5)
|
|
|
2c1b57 |
return "Can only convert a 2-device array to RAID5";
|
|
|
2c1b57 |
- if (info->array.raid_disks == 2 &&
|
|
|
2c1b57 |
- info->new_level == 5) {
|
|
|
2c1b57 |
-
|
|
|
2c1b57 |
+ if (info->array.raid_disks == 2 && info->new_level == 5) {
|
|
|
2c1b57 |
re->level = 5;
|
|
|
2c1b57 |
re->before.data_disks = 1;
|
|
|
2c1b57 |
if (info->delta_disks != UnSet &&
|
|
|
2c1b57 |
@@ -1404,7 +1400,8 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
|
|
|
2c1b57 |
case 0:
|
|
|
2c1b57 |
/* RAID0 can be converted to RAID10, or to RAID456 */
|
|
|
2c1b57 |
if (info->new_level == 10) {
|
|
|
2c1b57 |
- if (info->new_layout == UnSet && info->delta_disks == UnSet) {
|
|
|
2c1b57 |
+ if (info->new_layout == UnSet &&
|
|
|
2c1b57 |
+ info->delta_disks == UnSet) {
|
|
|
2c1b57 |
/* Assume near=2 layout */
|
|
|
2c1b57 |
info->new_layout = 0x102;
|
|
|
2c1b57 |
info->delta_disks = info->array.raid_disks;
|
|
|
2c1b57 |
@@ -1643,16 +1640,19 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
|
|
|
2c1b57 |
if (info->delta_disks == UnSet)
|
|
|
2c1b57 |
info->delta_disks = delta_parity;
|
|
|
2c1b57 |
|
|
|
2c1b57 |
- re->after.data_disks = (re->before.data_disks
|
|
|
2c1b57 |
- + info->delta_disks
|
|
|
2c1b57 |
- - delta_parity);
|
|
|
2c1b57 |
+ re->after.data_disks =
|
|
|
2c1b57 |
+ (re->before.data_disks + info->delta_disks - delta_parity);
|
|
|
2c1b57 |
+
|
|
|
2c1b57 |
switch (re->level) {
|
|
|
2c1b57 |
- case 6: re->parity = 2;
|
|
|
2c1b57 |
+ case 6:
|
|
|
2c1b57 |
+ re->parity = 2;
|
|
|
2c1b57 |
break;
|
|
|
2c1b57 |
case 4:
|
|
|
2c1b57 |
- case 5: re->parity = 1;
|
|
|
2c1b57 |
+ case 5:
|
|
|
2c1b57 |
+ re->parity = 1;
|
|
|
2c1b57 |
break;
|
|
|
2c1b57 |
- default: re->parity = 0;
|
|
|
2c1b57 |
+ default:
|
|
|
2c1b57 |
+ re->parity = 0;
|
|
|
2c1b57 |
break;
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
/* So we have a restripe operation, we need to calculate the number
|
|
|
2c1b57 |
@@ -1706,7 +1706,7 @@ static int set_array_size(struct supertype *st, struct mdinfo *sra,
|
|
|
2c1b57 |
|
|
|
2c1b57 |
if (text_version == NULL)
|
|
|
2c1b57 |
text_version = sra->text_version;
|
|
|
2c1b57 |
- subarray = strchr(text_version+1, '/')+1;
|
|
|
2c1b57 |
+ subarray = strchr(text_version + 1, '/')+1;
|
|
|
2c1b57 |
info = st->ss->container_content(st, subarray);
|
|
|
2c1b57 |
if (info) {
|
|
|
2c1b57 |
unsigned long long current_size = 0;
|
|
|
2c1b57 |
@@ -1789,8 +1789,8 @@ int Grow_reshape(char *devname, int fd,
|
|
|
2c1b57 |
devname);
|
|
|
2c1b57 |
return 1;
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
- if (data_offset != INVALID_SECTORS && array.level != 10
|
|
|
2c1b57 |
- && (array.level < 4 || array.level > 6)) {
|
|
|
2c1b57 |
+ if (data_offset != INVALID_SECTORS && array.level != 10 &&
|
|
|
2c1b57 |
+ (array.level < 4 || array.level > 6)) {
|
|
|
2c1b57 |
pr_err("--grow --data-offset not yet supported\n");
|
|
|
2c1b57 |
return 1;
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
@@ -1802,8 +1802,8 @@ int Grow_reshape(char *devname, int fd,
|
|
|
2c1b57 |
return 1;
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
|
|
|
2c1b57 |
- if (s->raiddisks && s->raiddisks < array.raid_disks && array.level > 1 &&
|
|
|
2c1b57 |
- get_linux_version() < 2006032 &&
|
|
|
2c1b57 |
+ if (s->raiddisks && s->raiddisks < array.raid_disks &&
|
|
|
2c1b57 |
+ array.level > 1 && get_linux_version() < 2006032 &&
|
|
|
2c1b57 |
!check_env("MDADM_FORCE_FEWER")) {
|
|
|
2c1b57 |
pr_err("reducing the number of devices is not safe before Linux 2.6.32\n"
|
|
|
2c1b57 |
" Please use a newer kernel\n");
|
|
|
2c1b57 |
@@ -1873,10 +1873,11 @@ int Grow_reshape(char *devname, int fd,
|
|
|
2c1b57 |
/* check if reshape is allowed based on metadata
|
|
|
2c1b57 |
* indications stored in content.array.status
|
|
|
2c1b57 |
*/
|
|
|
2c1b57 |
- if (content->array.state & (1<
|
|
|
2c1b57 |
+ if (content->array.state &
|
|
|
2c1b57 |
+ (1 << MD_SB_BLOCK_VOLUME))
|
|
|
2c1b57 |
allow_reshape = 0;
|
|
|
2c1b57 |
- if (content->array.state
|
|
|
2c1b57 |
- & (1<
|
|
|
2c1b57 |
+ if (content->array.state &
|
|
|
2c1b57 |
+ (1 << MD_SB_BLOCK_CONTAINER_RESHAPE))
|
|
|
2c1b57 |
allow_reshape = 0;
|
|
|
2c1b57 |
if (!allow_reshape) {
|
|
|
2c1b57 |
pr_err("cannot reshape arrays in container with unsupported metadata: %s(%s)\n",
|
|
|
2c1b57 |
@@ -1896,7 +1897,7 @@ int Grow_reshape(char *devname, int fd,
|
|
|
2c1b57 |
for (dv = devlist; dv; dv = dv->next)
|
|
|
2c1b57 |
added_disks++;
|
|
|
2c1b57 |
if (s->raiddisks > array.raid_disks &&
|
|
|
2c1b57 |
- array.spare_disks +added_disks < (s->raiddisks - array.raid_disks) &&
|
|
|
2c1b57 |
+ array.spare_disks + added_disks < (s->raiddisks - array.raid_disks) &&
|
|
|
2c1b57 |
!c->force) {
|
|
|
2c1b57 |
pr_err("Need %d spare%s to avoid degraded array, and only have %d.\n"
|
|
|
2c1b57 |
" Use --force to over-ride this check.\n",
|
|
|
2c1b57 |
@@ -1906,8 +1907,8 @@ int Grow_reshape(char *devname, int fd,
|
|
|
2c1b57 |
return 1;
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
|
|
|
2c1b57 |
- sra = sysfs_read(fd, NULL, GET_LEVEL | GET_DISKS | GET_DEVS
|
|
|
2c1b57 |
- | GET_STATE | GET_VERSION);
|
|
|
2c1b57 |
+ sra = sysfs_read(fd, NULL, GET_LEVEL | GET_DISKS | GET_DEVS |
|
|
|
2c1b57 |
+ GET_STATE | GET_VERSION);
|
|
|
2c1b57 |
if (sra) {
|
|
|
2c1b57 |
if (st->ss->external && subarray == NULL) {
|
|
|
2c1b57 |
array.level = LEVEL_CONTAINER;
|
|
|
2c1b57 |
@@ -1930,7 +1931,8 @@ int Grow_reshape(char *devname, int fd,
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
|
|
|
2c1b57 |
/* ========= set size =============== */
|
|
|
2c1b57 |
- if (s->size > 0 && (s->size == MAX_SIZE || s->size != (unsigned)array.size)) {
|
|
|
2c1b57 |
+ if (s->size > 0 &&
|
|
|
2c1b57 |
+ (s->size == MAX_SIZE || s->size != (unsigned)array.size)) {
|
|
|
2c1b57 |
unsigned long long orig_size = get_component_size(fd)/2;
|
|
|
2c1b57 |
unsigned long long min_csize;
|
|
|
2c1b57 |
struct mdinfo *mdi;
|
|
|
2c1b57 |
@@ -1946,7 +1948,8 @@ int Grow_reshape(char *devname, int fd,
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
|
|
|
2c1b57 |
if (reshape_super(st, s->size, UnSet, UnSet, 0, 0, UnSet, NULL,
|
|
|
2c1b57 |
- devname, APPLY_METADATA_CHANGES, c->verbose > 0)) {
|
|
|
2c1b57 |
+ devname, APPLY_METADATA_CHANGES,
|
|
|
2c1b57 |
+ c->verbose > 0)) {
|
|
|
2c1b57 |
rv = 1;
|
|
|
2c1b57 |
goto release;
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
@@ -1965,7 +1968,8 @@ int Grow_reshape(char *devname, int fd,
|
|
|
2c1b57 |
sizeinfo->array.layout,
|
|
|
2c1b57 |
sizeinfo->array.raid_disks);
|
|
|
2c1b57 |
new_size /= data_disks;
|
|
|
2c1b57 |
- dprintf("Metadata size correction from %llu to %llu (%llu)\n", orig_size, new_size,
|
|
|
2c1b57 |
+ dprintf("Metadata size correction from %llu to %llu (%llu)\n",
|
|
|
2c1b57 |
+ orig_size, new_size,
|
|
|
2c1b57 |
new_size * data_disks);
|
|
|
2c1b57 |
s->size = new_size;
|
|
|
2c1b57 |
sysfs_free(sizeinfo);
|
|
|
2c1b57 |
--
|
|
|
2c1b57 |
2.7.4
|
|
|
2c1b57 |
|