You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
310 lines
10 KiB
310 lines
10 KiB
2 months ago
|
From bdc2c56998abf76141294b04facf20217cfd1911 Mon Sep 17 00:00:00 2001
|
||
|
From: Mateusz Kusiak <mateusz.kusiak@intel.com>
|
||
|
Date: Mon, 29 Apr 2024 15:07:13 +0200
|
||
|
Subject: [PATCH 52/66] mdadm: pass struct context for external reshapes
|
||
|
|
||
|
This patch alters mutiple functions calls so the context is passed to
|
||
|
external reshape functions.
|
||
|
|
||
|
There are two main reasons behind it:
|
||
|
- reduces number of arguments passed and unifies them,
|
||
|
- imsm code will make use of context in incoming patches.
|
||
|
|
||
|
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
|
||
|
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
|
||
|
---
|
||
|
Assemble.c | 7 ++----
|
||
|
Grow.c | 68 +++++++++++++++++++++------------------------------
|
||
|
mdadm.c | 2 +-
|
||
|
mdadm.h | 11 +++------
|
||
|
super-intel.c | 6 ++---
|
||
|
5 files changed, 37 insertions(+), 57 deletions(-)
|
||
|
|
||
|
diff --git a/Assemble.c b/Assemble.c
|
||
|
index f6c5b99e..f5e9ab1f 100644
|
||
|
--- a/Assemble.c
|
||
|
+++ b/Assemble.c
|
||
|
@@ -1197,9 +1197,7 @@ static int start_array(int mdfd,
|
||
|
rv = sysfs_set_str(content, NULL,
|
||
|
"array_state", "readonly");
|
||
|
if (rv == 0)
|
||
|
- rv = Grow_continue(mdfd, st, content,
|
||
|
- c->backup_file, 0,
|
||
|
- c->freeze_reshape);
|
||
|
+ rv = Grow_continue(mdfd, st, content, 0, c);
|
||
|
} else if (c->readonly &&
|
||
|
sysfs_attribute_available(content, NULL,
|
||
|
"array_state")) {
|
||
|
@@ -2180,8 +2178,7 @@ int assemble_container_content(struct supertype *st, int mdfd,
|
||
|
st->update_tail = &st->updates;
|
||
|
}
|
||
|
|
||
|
- err = Grow_continue(mdfd, st, content, c->backup_file,
|
||
|
- 0, c->freeze_reshape);
|
||
|
+ err = Grow_continue(mdfd, st, content, 0, c);
|
||
|
} else switch(content->array.level) {
|
||
|
case LEVEL_LINEAR:
|
||
|
case LEVEL_MULTIPATH:
|
||
|
diff --git a/Grow.c b/Grow.c
|
||
|
index 074f1995..f477b438 100644
|
||
|
--- a/Grow.c
|
||
|
+++ b/Grow.c
|
||
|
@@ -864,8 +864,7 @@ static void wait_reshape(struct mdinfo *sra)
|
||
|
|
||
|
static int reshape_super(struct supertype *st, unsigned long long size,
|
||
|
int level, int layout, int chunksize, int raid_disks,
|
||
|
- int delta_disks, char *backup_file, char *dev,
|
||
|
- int direction, int verbose)
|
||
|
+ int delta_disks, char *dev, int direction, struct context *c)
|
||
|
{
|
||
|
/* nothing extra to check in the native case */
|
||
|
if (!st->ss->external)
|
||
|
@@ -876,9 +875,8 @@ static int reshape_super(struct supertype *st, unsigned long long size,
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
- return st->ss->reshape_super(st, size, level, layout, chunksize,
|
||
|
- raid_disks, delta_disks, backup_file, dev,
|
||
|
- direction, verbose);
|
||
|
+ return st->ss->reshape_super(st, size, level, layout, chunksize, raid_disks,
|
||
|
+ delta_disks, dev, direction, c);
|
||
|
}
|
||
|
|
||
|
static void sync_metadata(struct supertype *st)
|
||
|
@@ -1764,9 +1762,8 @@ static int reshape_container(char *container, char *devname,
|
||
|
int mdfd,
|
||
|
struct supertype *st,
|
||
|
struct mdinfo *info,
|
||
|
- int force,
|
||
|
- char *backup_file, int verbose,
|
||
|
- int forked, int restart, int freeze_reshape);
|
||
|
+ struct context *c,
|
||
|
+ int forked, int restart);
|
||
|
|
||
|
/**
|
||
|
* prepare_external_reshape() - prepares update on external metadata if supported.
|
||
|
@@ -2004,9 +2001,8 @@ int Grow_reshape(char *devname, int fd,
|
||
|
goto release;
|
||
|
}
|
||
|
|
||
|
- if (reshape_super(st, s->size, UnSet, UnSet, 0, 0, UnSet, NULL,
|
||
|
- devname, APPLY_METADATA_CHANGES,
|
||
|
- c->verbose > 0)) {
|
||
|
+ if (reshape_super(st, s->size, UnSet, UnSet, 0, 0, UnSet,
|
||
|
+ devname, APPLY_METADATA_CHANGES, c)) {
|
||
|
rv = 1;
|
||
|
goto release;
|
||
|
}
|
||
|
@@ -2124,10 +2120,8 @@ size_change_error:
|
||
|
int err = errno;
|
||
|
|
||
|
/* restore metadata */
|
||
|
- if (reshape_super(st, orig_size, UnSet, UnSet, 0, 0,
|
||
|
- UnSet, NULL, devname,
|
||
|
- ROLLBACK_METADATA_CHANGES,
|
||
|
- c->verbose) == 0)
|
||
|
+ if (reshape_super(st, orig_size, UnSet, UnSet, 0, 0, UnSet,
|
||
|
+ devname, ROLLBACK_METADATA_CHANGES, c) == 0)
|
||
|
sync_metadata(st);
|
||
|
pr_err("Cannot set device size for %s: %s\n",
|
||
|
devname, strerror(err));
|
||
|
@@ -2338,8 +2332,7 @@ size_change_error:
|
||
|
*/
|
||
|
close_fd(&fd);
|
||
|
rv = reshape_container(container, devname, -1, st, &info,
|
||
|
- c->force, c->backup_file, c->verbose,
|
||
|
- 0, 0, 0);
|
||
|
+ c, 0, 0);
|
||
|
frozen = 0;
|
||
|
} else {
|
||
|
/* get spare devices from external metadata
|
||
|
@@ -2356,13 +2349,13 @@ size_change_error:
|
||
|
}
|
||
|
|
||
|
/* Impose these changes on a single array. First
|
||
|
- * check that the metadata is OK with the change. */
|
||
|
+ * check that the metadata is OK with the change.
|
||
|
+ */
|
||
|
|
||
|
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)) {
|
||
|
+ devname, APPLY_METADATA_CHANGES, c)) {
|
||
|
rv = 1;
|
||
|
goto release;
|
||
|
}
|
||
|
@@ -3668,9 +3661,8 @@ int reshape_container(char *container, char *devname,
|
||
|
int mdfd,
|
||
|
struct supertype *st,
|
||
|
struct mdinfo *info,
|
||
|
- int force,
|
||
|
- char *backup_file, int verbose,
|
||
|
- int forked, int restart, int freeze_reshape)
|
||
|
+ struct context *c,
|
||
|
+ int forked, int restart)
|
||
|
{
|
||
|
struct mdinfo *cc = NULL;
|
||
|
int rv = restart;
|
||
|
@@ -3683,8 +3675,7 @@ int reshape_container(char *container, char *devname,
|
||
|
reshape_super(st, 0, info->new_level,
|
||
|
info->new_layout, info->new_chunk,
|
||
|
info->array.raid_disks, info->delta_disks,
|
||
|
- backup_file, devname, APPLY_METADATA_CHANGES,
|
||
|
- verbose)) {
|
||
|
+ devname, APPLY_METADATA_CHANGES, c)) {
|
||
|
unfreeze(st);
|
||
|
return 1;
|
||
|
}
|
||
|
@@ -3695,7 +3686,7 @@ int reshape_container(char *container, char *devname,
|
||
|
*/
|
||
|
ping_monitor(container);
|
||
|
|
||
|
- if (!forked && !freeze_reshape)
|
||
|
+ if (!forked && !c->freeze_reshape)
|
||
|
if (continue_via_systemd(container, GROW_SERVICE, NULL))
|
||
|
return 0;
|
||
|
|
||
|
@@ -3705,7 +3696,7 @@ int reshape_container(char *container, char *devname,
|
||
|
unfreeze(st);
|
||
|
return 1;
|
||
|
default: /* parent */
|
||
|
- if (!freeze_reshape)
|
||
|
+ if (!c->freeze_reshape)
|
||
|
printf("%s: multi-array reshape continues in background\n", Name);
|
||
|
return 0;
|
||
|
case 0: /* child */
|
||
|
@@ -3802,12 +3793,12 @@ int reshape_container(char *container, char *devname,
|
||
|
flush_mdmon(container);
|
||
|
|
||
|
rv = reshape_array(container, fd, adev, st,
|
||
|
- content, force, NULL, INVALID_SECTORS,
|
||
|
- backup_file, verbose, 1, restart,
|
||
|
- freeze_reshape);
|
||
|
+ content, c->force, NULL, INVALID_SECTORS,
|
||
|
+ c->backup_file, c->verbose, 1, restart,
|
||
|
+ c->freeze_reshape);
|
||
|
close(fd);
|
||
|
|
||
|
- if (freeze_reshape) {
|
||
|
+ if (c->freeze_reshape) {
|
||
|
sysfs_free(cc);
|
||
|
exit(0);
|
||
|
}
|
||
|
@@ -4970,8 +4961,7 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist,
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
-int Grow_continue_command(char *devname, int fd,
|
||
|
- char *backup_file, int verbose)
|
||
|
+int Grow_continue_command(char *devname, int fd, struct context *c)
|
||
|
{
|
||
|
int ret_val = 0;
|
||
|
struct supertype *st = NULL;
|
||
|
@@ -5157,7 +5147,7 @@ int Grow_continue_command(char *devname, int fd,
|
||
|
|
||
|
/* continue reshape
|
||
|
*/
|
||
|
- ret_val = Grow_continue(fd, st, content, backup_file, 1, 0);
|
||
|
+ ret_val = Grow_continue(fd, st, content, 1, c);
|
||
|
|
||
|
Grow_continue_command_exit:
|
||
|
if (cfd > -1)
|
||
|
@@ -5171,7 +5161,7 @@ Grow_continue_command_exit:
|
||
|
}
|
||
|
|
||
|
int Grow_continue(int mdfd, struct supertype *st, struct mdinfo *info,
|
||
|
- char *backup_file, int forked, int freeze_reshape)
|
||
|
+ int forked, struct context *c)
|
||
|
{
|
||
|
int ret_val = 2;
|
||
|
|
||
|
@@ -5187,14 +5177,12 @@ 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,
|
||
|
- freeze_reshape);
|
||
|
+ st, info, c, forked, 1 | info->reshape_active);
|
||
|
} else
|
||
|
ret_val = reshape_array(NULL, mdfd, "array", st, info, 1,
|
||
|
- NULL, INVALID_SECTORS, backup_file,
|
||
|
+ NULL, INVALID_SECTORS, c->backup_file,
|
||
|
0, forked, 1 | info->reshape_active,
|
||
|
- freeze_reshape);
|
||
|
+ c->freeze_reshape);
|
||
|
|
||
|
return ret_val;
|
||
|
}
|
||
|
diff --git a/mdadm.c b/mdadm.c
|
||
|
index 3f191288..d18619db 100644
|
||
|
--- a/mdadm.c
|
||
|
+++ b/mdadm.c
|
||
|
@@ -1636,7 +1636,7 @@ int main(int argc, char *argv[])
|
||
|
c.delay = DEFAULT_BITMAP_DELAY;
|
||
|
rv = Grow_addbitmap(ident.devname, mdfd, &c, &s);
|
||
|
} else if (grow_continue)
|
||
|
- rv = Grow_continue_command(ident.devname, mdfd, c.backup_file, c.verbose);
|
||
|
+ rv = Grow_continue_command(ident.devname, mdfd, &c);
|
||
|
else if (s.size > 0 || s.raiddisks || s.layout_str ||
|
||
|
s.chunk != 0 || s.level != UnSet ||
|
||
|
s.data_offset != INVALID_SECTORS) {
|
||
|
diff --git a/mdadm.h b/mdadm.h
|
||
|
index 2640b396..0ade4beb 100644
|
||
|
--- a/mdadm.h
|
||
|
+++ b/mdadm.h
|
||
|
@@ -1235,9 +1235,8 @@ extern struct superswitch {
|
||
|
int (*reshape_super)(struct supertype *st,
|
||
|
unsigned long long size, int level,
|
||
|
int layout, int chunksize, int raid_disks,
|
||
|
- int delta_disks, char *backup, char *dev,
|
||
|
- int direction,
|
||
|
- int verbose); /* optional */
|
||
|
+ int delta_disks, char *dev, int direction,
|
||
|
+ struct context *c);
|
||
|
int (*manage_reshape)( /* optional */
|
||
|
int afd, struct mdinfo *sra, struct reshape *reshape,
|
||
|
struct supertype *st, unsigned long blocks,
|
||
|
@@ -1541,8 +1540,7 @@ extern int Grow_reshape(char *devname, int fd,
|
||
|
extern int Grow_restart(struct supertype *st, struct mdinfo *info,
|
||
|
int *fdlist, int cnt, char *backup_file, int verbose);
|
||
|
extern int Grow_continue(int mdfd, struct supertype *st,
|
||
|
- struct mdinfo *info, char *backup_file,
|
||
|
- int forked, int freeze_reshape);
|
||
|
+ struct mdinfo *info, int forked, struct context *c);
|
||
|
extern int Grow_consistency_policy(char *devname, int fd,
|
||
|
struct context *c, struct shape *s);
|
||
|
|
||
|
@@ -1552,8 +1550,7 @@ extern int restore_backup(struct supertype *st,
|
||
|
int spares,
|
||
|
char **backup_filep,
|
||
|
int verbose);
|
||
|
-extern int Grow_continue_command(char *devname, int fd,
|
||
|
- char *backup_file, int verbose);
|
||
|
+extern int Grow_continue_command(char *devname, int fd, struct context *c);
|
||
|
|
||
|
extern int Assemble(struct supertype *st, char *mddev,
|
||
|
struct mddev_ident *ident,
|
||
|
diff --git a/super-intel.c b/super-intel.c
|
||
|
index 1faab607..417da267 100644
|
||
|
--- a/super-intel.c
|
||
|
+++ b/super-intel.c
|
||
|
@@ -12153,10 +12153,8 @@ exit:
|
||
|
}
|
||
|
|
||
|
static int imsm_reshape_super(struct supertype *st, unsigned long long size,
|
||
|
- int level,
|
||
|
- int layout, int chunksize, int raid_disks,
|
||
|
- int delta_disks, char *backup, char *dev,
|
||
|
- int direction, int verbose)
|
||
|
+ int level, int layout, int chunksize, int raid_disks,
|
||
|
+ int delta_disks, char *dev, int direction, struct context *c)
|
||
|
{
|
||
|
int ret_val = 1;
|
||
|
struct geo_params geo;
|
||
|
--
|
||
|
2.41.0
|
||
|
|