summaryrefslogtreecommitdiff
path: root/Grow.c
diff options
context:
space:
mode:
authorJes Sorensen <Jes.Sorensen@gmail.com>2017-03-29 14:35:41 -0400
committerJes Sorensen <Jes.Sorensen@gmail.com>2017-03-29 14:35:41 -0400
commit9cd39f015558dba82c293a4433b481b921ceec87 (patch)
tree324f4d170f41b88d9941b06c832638a0ba232950 /Grow.c
parent6ebf34e6bdd9e952d00ad3c2f12a130bfb68965e (diff)
downloadmdadm-9cd39f015558dba82c293a4433b481b921ceec87.tar.gz
util: Introduce md_get_array_info()
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>
Diffstat (limited to 'Grow.c')
-rwxr-xr-xGrow.c31
1 files changed, 16 insertions, 15 deletions
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;
}