dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/util-Introduce4-md_set_array_info.patch

2c1b57
From 018a488238e2ff55d7c2fd29333c1f7305354318 Mon Sep 17 00:00:00 2001
2c1b57
From: Jes Sorensen <Jes.Sorensen@gmail.com>
2c1b57
Date: Wed, 29 Mar 2017 15:43:53 -0400
2c1b57
Subject: [RHEL7.5 PATCH 040/169] util: Introduce md_set_array_info()
2c1b57
2c1b57
Switch from using ioctl(SET_ARRAY_INFO) to using md_set_array_info()
2c1b57
2c1b57
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2c1b57
---
2c1b57
 Build.c |  4 ++--
2c1b57
 Grow.c  | 17 ++++++++---------
2c1b57
 mdadm.h |  1 +
2c1b57
 util.c  | 12 ++++++++++--
2c1b57
 4 files changed, 21 insertions(+), 13 deletions(-)
2c1b57
2c1b57
diff --git a/Build.c b/Build.c
2c1b57
index a5fcc06..691dd6f 100644
2c1b57
--- a/Build.c
2c1b57
+++ b/Build.c
2c1b57
@@ -148,8 +148,8 @@ int Build(char *mddev, struct mddev_dev *devlist,
2c1b57
 			s->chunk = 64;
2c1b57
 		array.chunk_size = s->chunk*1024;
2c1b57
 		array.layout = s->layout;
2c1b57
-		if (ioctl(mdfd, SET_ARRAY_INFO, &array)) {
2c1b57
-			pr_err("SET_ARRAY_INFO failed for %s: %s\n",
2c1b57
+		if (md_set_array_info(mdfd, &array)) {
2c1b57
+			pr_err("md_set_array_info() failed for %s: %s\n",
2c1b57
 				mddev, strerror(errno));
2c1b57
 			goto abort;
2c1b57
 		}
2c1b57
diff --git a/Grow.c b/Grow.c
2c1b57
index 1c90902..af8d520 100755
2c1b57
--- a/Grow.c
2c1b57
+++ b/Grow.c
2c1b57
@@ -335,7 +335,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
2c1b57
 	if (array.state & (1 << MD_SB_BITMAP_PRESENT)) {
2c1b57
 		if (strcmp(s->bitmap_file, "none")==0) {
2c1b57
 			array.state &= ~(1 << MD_SB_BITMAP_PRESENT);
2c1b57
-			if (ioctl(fd, SET_ARRAY_INFO, &array) != 0) {
2c1b57
+			if (md_set_array_info(fd, &array) != 0) {
2c1b57
 				if (array.state & (1 << MD_SB_CLUSTERED))
2c1b57
 					pr_err("failed to remove clustered bitmap.\n");
2c1b57
 				else
2c1b57
@@ -463,7 +463,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
2c1b57
 			if (strcmp(s->bitmap_file, "clustered") == 0)
2c1b57
 				array.state |= (1 << MD_SB_CLUSTERED);
2c1b57
 			array.state |= (1 << MD_SB_BITMAP_PRESENT);
2c1b57
-			rv = ioctl(fd, SET_ARRAY_INFO, &array);
2c1b57
+			rv = md_set_array_info(fd, &array);
2c1b57
 		}
2c1b57
 		if (rv < 0) {
2c1b57
 			if (errno == EBUSY)
2c1b57
@@ -1823,7 +1823,7 @@ int Grow_reshape(char *devname, int fd,
2c1b57
 	    (array.state & (1<
2c1b57
 	    !(array.state & (1<
2c1b57
                 array.state &= ~(1<
2c1b57
-                if (ioctl(fd, SET_ARRAY_INFO, &array)!= 0) {
2c1b57
+                if (md_set_array_info(fd, &array)!= 0) {
2c1b57
                         pr_err("failed to remove internal bitmap.\n");
2c1b57
                         return 1;
2c1b57
                 }
2c1b57
@@ -2056,7 +2056,7 @@ int Grow_reshape(char *devname, int fd,
2c1b57
 			else
2c1b57
 				rv = -1;
2c1b57
 		} else {
2c1b57
-			rv = ioctl(fd, SET_ARRAY_INFO, &array);
2c1b57
+			rv = md_set_array_info(fd, &array);
2c1b57
 
2c1b57
 			/* manage array size when it is managed externally
2c1b57
 			 */
2c1b57
@@ -2272,7 +2272,7 @@ size_change_error:
2c1b57
 				goto release;
2c1b57
 			}
2c1b57
 			array.layout = info.new_layout;
2c1b57
-			if (ioctl(fd, SET_ARRAY_INFO, &array) != 0) {
2c1b57
+			if (md_set_array_info(fd, &array) != 0) {
2c1b57
 				pr_err("failed to set new layout\n");
2c1b57
 				rv = 1;
2c1b57
 			} else if (c->verbose >= 0)
2c1b57
@@ -2836,8 +2836,7 @@ static int impose_reshape(struct mdinfo *sra,
2c1b57
 	    st->ss->external == 0) {
2c1b57
 		/* use SET_ARRAY_INFO but only if reshape hasn't started */
2c1b57
 		array.raid_disks = reshape->after.data_disks + reshape->parity;
2c1b57
-		if (!restart &&
2c1b57
-		    ioctl(fd, SET_ARRAY_INFO, &array) != 0) {
2c1b57
+		if (!restart && md_set_array_info(fd, &array) != 0) {
2c1b57
 			int err = errno;
2c1b57
 
2c1b57
 			pr_err("Cannot set device shape for %s: %s\n",
2c1b57
@@ -3239,7 +3238,7 @@ static int reshape_array(char *container, int fd, char *devname,
2c1b57
 		if (info->new_layout != UnSet &&
2c1b57
 		    info->new_layout != array.layout) {
2c1b57
 			array.layout = info->new_layout;
2c1b57
-			if (ioctl(fd, SET_ARRAY_INFO, &array) != 0) {
2c1b57
+			if (md_set_array_info(fd, &array) != 0) {
2c1b57
 				pr_err("failed to set new layout\n");
2c1b57
 				goto release;
2c1b57
 			} else if (verbose >= 0)
2c1b57
@@ -3250,7 +3249,7 @@ static int reshape_array(char *container, int fd, char *devname,
2c1b57
 		    info->delta_disks != 0 &&
2c1b57
 		    array.raid_disks != (info->array.raid_disks + info->delta_disks)) {
2c1b57
 			array.raid_disks += info->delta_disks;
2c1b57
-			if (ioctl(fd, SET_ARRAY_INFO, &array) != 0) {
2c1b57
+			if (md_set_array_info(fd, &array) != 0) {
2c1b57
 				pr_err("failed to set raid disks\n");
2c1b57
 				goto release;
2c1b57
 			} else if (verbose >= 0) {
2c1b57
diff --git a/mdadm.h b/mdadm.h
2c1b57
index 3ab548f..084bc97 100644
2c1b57
--- a/mdadm.h
2c1b57
+++ b/mdadm.h
2c1b57
@@ -1406,6 +1406,7 @@ extern int Restore_metadata(char *dev, char *dir, struct context *c,
2c1b57
 
2c1b57
 extern int md_get_version(int fd);
2c1b57
 int md_get_array_info(int fd, struct mdu_array_info_s *array);
2c1b57
+int md_set_array_info(int fd, struct mdu_array_info_s *array);
2c1b57
 int md_get_disk_info(int fd, struct mdu_disk_info_s *disk);
2c1b57
 extern int get_linux_version(void);
2c1b57
 extern int mdadm_version(char *version);
2c1b57
diff --git a/util.c b/util.c
2c1b57
index aa27e59..9fc7ba0 100644
2c1b57
--- a/util.c
2c1b57
+++ b/util.c
2c1b57
@@ -221,6 +221,14 @@ int md_get_array_info(int fd, struct mdu_array_info_s *array)
2c1b57
 }
2c1b57
 
2c1b57
 /*
2c1b57
+ * Set array info
2c1b57
+ */
2c1b57
+int md_set_array_info(int fd, struct mdu_array_info_s *array)
2c1b57
+{
2c1b57
+	return ioctl(fd, SET_ARRAY_INFO, array);
2c1b57
+}
2c1b57
+
2c1b57
+/*
2c1b57
  * Get disk info from the kernel.
2c1b57
  */
2c1b57
 int md_get_disk_info(int fd, struct mdu_disk_info_s *disk)
2c1b57
@@ -1858,9 +1866,9 @@ int set_array_info(int mdfd, struct supertype *st, struct mdinfo *info)
2c1b57
 		memset(&inf, 0, sizeof(inf));
2c1b57
 		inf.major_version = info->array.major_version;
2c1b57
 		inf.minor_version = info->array.minor_version;
2c1b57
-		rv = ioctl(mdfd, SET_ARRAY_INFO, &inf);
2c1b57
+		rv = md_set_array_info(mdfd, &inf);
2c1b57
 	} else
2c1b57
-		rv = ioctl(mdfd, SET_ARRAY_INFO, NULL);
2c1b57
+		rv = md_set_array_info(mdfd, NULL);
2c1b57
 	return rv;
2c1b57
 }
2c1b57
 
2c1b57
-- 
2c1b57
2.7.4
2c1b57