Blame SOURCES/0049-mdadm-move-data_offset-to-struct-shape.patch

b33395
From ae5dfc56b7a96805d5a0b50eaf93b9fec8604298 Mon Sep 17 00:00:00 2001
b33395
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
b33395
Date: Tue, 19 Jul 2022 14:48:23 +0200
b33395
Subject: [PATCH 49/52] mdadm: move data_offset to struct shape
b33395
b33395
Data offset is a shape property so move it there to remove additional
b33395
parameter from some functions.
b33395
b33395
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
b33395
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
b33395
---
b33395
 Create.c | 16 ++++++++--------
b33395
 Grow.c   |  7 +++----
b33395
 mdadm.c  | 20 +++++++++-----------
b33395
 mdadm.h  |  5 ++---
b33395
 4 files changed, 22 insertions(+), 26 deletions(-)
b33395
b33395
diff --git a/Create.c b/Create.c
b33395
index c84c1ac8..e06ec2ae 100644
b33395
--- a/Create.c
b33395
+++ b/Create.c
b33395
@@ -95,7 +95,7 @@ int Create(struct supertype *st, char *mddev,
b33395
 	   char *name, int *uuid,
b33395
 	   int subdevs, struct mddev_dev *devlist,
b33395
 	   struct shape *s,
b33395
-	   struct context *c, unsigned long long data_offset)
b33395
+	   struct context *c)
b33395
 {
b33395
 	/*
b33395
 	 * Create a new raid array.
b33395
@@ -288,7 +288,7 @@ int Create(struct supertype *st, char *mddev,
b33395
 	newsize = s->size * 2;
b33395
 	if (st && ! st->ss->validate_geometry(st, s->level, s->layout, s->raiddisks,
b33395
 					      &s->chunk, s->size*2,
b33395
-					      data_offset, NULL,
b33395
+					      s->data_offset, NULL,
b33395
 					      &newsize, s->consistency_policy,
b33395
 					      c->verbose >= 0))
b33395
 		return 1;
b33395
@@ -323,10 +323,10 @@ int Create(struct supertype *st, char *mddev,
b33395
 	info.array.working_disks = 0;
b33395
 	dnum = 0;
b33395
 	for (dv = devlist; dv; dv = dv->next)
b33395
-		if (data_offset == VARIABLE_OFFSET)
b33395
+		if (s->data_offset == VARIABLE_OFFSET)
b33395
 			dv->data_offset = INVALID_SECTORS;
b33395
 		else
b33395
-			dv->data_offset = data_offset;
b33395
+			dv->data_offset = s->data_offset;
b33395
 
b33395
 	for (dv=devlist; dv && !have_container; dv=dv->next, dnum++) {
b33395
 		char *dname = dv->devname;
b33395
@@ -342,7 +342,7 @@ int Create(struct supertype *st, char *mddev,
b33395
 			missing_disks ++;
b33395
 			continue;
b33395
 		}
b33395
-		if (data_offset == VARIABLE_OFFSET) {
b33395
+		if (s->data_offset == VARIABLE_OFFSET) {
b33395
 			doff = strchr(dname, ':');
b33395
 			if (doff) {
b33395
 				*doff++ = 0;
b33395
@@ -350,7 +350,7 @@ int Create(struct supertype *st, char *mddev,
b33395
 			} else
b33395
 				dv->data_offset = INVALID_SECTORS;
b33395
 		} else
b33395
-			dv->data_offset = data_offset;
b33395
+			dv->data_offset = s->data_offset;
b33395
 
b33395
 		dfd = open(dname, O_RDONLY);
b33395
 		if (dfd < 0) {
b33395
@@ -535,7 +535,7 @@ int Create(struct supertype *st, char *mddev,
b33395
 			if (!st->ss->validate_geometry(st, s->level, s->layout,
b33395
 						       s->raiddisks,
b33395
 						       &s->chunk, minsize*2,
b33395
-						       data_offset,
b33395
+						       s->data_offset,
b33395
 						       NULL, NULL,
b33395
 						       s->consistency_policy, 0)) {
b33395
 				pr_err("devices too large for RAID level %d\n", s->level);
b33395
@@ -754,7 +754,7 @@ int Create(struct supertype *st, char *mddev,
b33395
 		}
b33395
 	}
b33395
 	if (!st->ss->init_super(st, &info.array, s, name, c->homehost, uuid,
b33395
-				data_offset))
b33395
+				s->data_offset))
b33395
 		goto abort_locked;
b33395
 
b33395
 	total_slots = info.array.nr_disks;
b33395
diff --git a/Grow.c b/Grow.c
b33395
index 5780635a..868bdc3a 100644
b33395
--- a/Grow.c
b33395
+++ b/Grow.c
b33395
@@ -1775,7 +1775,6 @@ static int reshape_container(char *container, char *devname,
b33395
 
b33395
 int Grow_reshape(char *devname, int fd,
b33395
 		 struct mddev_dev *devlist,
b33395
-		 unsigned long long data_offset,
b33395
 		 struct context *c, struct shape *s)
b33395
 {
b33395
 	/* Make some changes in the shape of an array.
b33395
@@ -1821,7 +1820,7 @@ int Grow_reshape(char *devname, int fd,
b33395
 		return 1;
b33395
 	}
b33395
 
b33395
-	if (data_offset != INVALID_SECTORS && array.level != 10 &&
b33395
+	if (s->data_offset != INVALID_SECTORS && array.level != 10 &&
b33395
 	    (array.level < 4 || array.level > 6)) {
b33395
 		pr_err("--grow --data-offset not yet supported\n");
b33395
 		return 1;
b33395
@@ -2179,7 +2178,7 @@ size_change_error:
b33395
 	if ((s->level == UnSet || s->level == array.level) &&
b33395
 	    (s->layout_str == NULL) &&
b33395
 	    (s->chunk == 0 || s->chunk == array.chunk_size) &&
b33395
-	    data_offset == INVALID_SECTORS &&
b33395
+	    s->data_offset == INVALID_SECTORS &&
b33395
 	    (s->raiddisks == 0 || s->raiddisks == array.raid_disks)) {
b33395
 		/* Nothing more to do */
b33395
 		if (!changed && c->verbose >= 0)
b33395
@@ -2379,7 +2378,7 @@ size_change_error:
b33395
 		}
b33395
 		sync_metadata(st);
b33395
 		rv = reshape_array(container, fd, devname, st, &info, c->force,
b33395
-				   devlist, data_offset, c->backup_file,
b33395
+				   devlist, s->data_offset, c->backup_file,
b33395
 				   c->verbose, 0, 0, 0);
b33395
 		frozen = 0;
b33395
 	}
b33395
diff --git a/mdadm.c b/mdadm.c
b33395
index 180f7a9c..845e4466 100644
b33395
--- a/mdadm.c
b33395
+++ b/mdadm.c
b33395
@@ -49,7 +49,6 @@ int main(int argc, char *argv[])
b33395
 	int i;
b33395
 
b33395
 	unsigned long long array_size = 0;
b33395
-	unsigned long long data_offset = INVALID_SECTORS;
b33395
 	struct mddev_ident ident;
b33395
 	char *configfile = NULL;
b33395
 	int devmode = 0;
b33395
@@ -79,6 +78,7 @@ int main(int argc, char *argv[])
b33395
 		.layout		= UnSet,
b33395
 		.bitmap_chunk	= UnSet,
b33395
 		.consistency_policy	= CONSISTENCY_POLICY_UNKNOWN,
b33395
+		.data_offset = INVALID_SECTORS,
b33395
 	};
b33395
 
b33395
 	char sys_hostname[256];
b33395
@@ -479,15 +479,15 @@ int main(int argc, char *argv[])
b33395
 
b33395
 		case O(CREATE,DataOffset):
b33395
 		case O(GROW,DataOffset):
b33395
-			if (data_offset != INVALID_SECTORS) {
b33395
+			if (s.data_offset != INVALID_SECTORS) {
b33395
 				pr_err("data-offset may only be specified one. Second value is %s.\n", optarg);
b33395
 				exit(2);
b33395
 			}
b33395
 			if (mode == CREATE && strcmp(optarg, "variable") == 0)
b33395
-				data_offset = VARIABLE_OFFSET;
b33395
+				s.data_offset = VARIABLE_OFFSET;
b33395
 			else
b33395
-				data_offset = parse_size(optarg);
b33395
-			if (data_offset == INVALID_SECTORS) {
b33395
+				s.data_offset = parse_size(optarg);
b33395
+			if (s.data_offset == INVALID_SECTORS) {
b33395
 				pr_err("invalid data-offset: %s\n",
b33395
 					optarg);
b33395
 				exit(2);
b33395
@@ -1416,7 +1416,7 @@ int main(int argc, char *argv[])
b33395
 		exit(1);
b33395
 	}
b33395
 
b33395
-	if (c.backup_file && data_offset != INVALID_SECTORS) {
b33395
+	if (c.backup_file && s.data_offset != INVALID_SECTORS) {
b33395
 		pr_err("--backup-file and --data-offset are incompatible\n");
b33395
 		exit(2);
b33395
 	}
b33395
@@ -1587,8 +1587,7 @@ int main(int argc, char *argv[])
b33395
 
b33395
 		rv = Create(ss, devlist->devname,
b33395
 			    ident.name, ident.uuid_set ? ident.uuid : NULL,
b33395
-			    devs_found-1, devlist->next,
b33395
-			    &s, &c, data_offset);
b33395
+			    devs_found - 1, devlist->next, &s, &c);
b33395
 		break;
b33395
 	case MISC:
b33395
 		if (devmode == 'E') {
b33395
@@ -1706,10 +1705,9 @@ int main(int argc, char *argv[])
b33395
 						   c.verbose);
b33395
 		else if (s.size > 0 || s.raiddisks || s.layout_str ||
b33395
 			 s.chunk != 0 || s.level != UnSet ||
b33395
-			 data_offset != INVALID_SECTORS) {
b33395
+			 s.data_offset != INVALID_SECTORS) {
b33395
 			rv = Grow_reshape(devlist->devname, mdfd,
b33395
-					  devlist->next,
b33395
-					  data_offset, &c, &s);
b33395
+					  devlist->next, &c, &s);
b33395
 		} else if (s.consistency_policy != CONSISTENCY_POLICY_UNKNOWN) {
b33395
 			rv = Grow_consistency_policy(devlist->devname, mdfd, &c, &s);
b33395
 		} else if (array_size == 0)
b33395
diff --git a/mdadm.h b/mdadm.h
b33395
index 93e72786..adb7cdaa 100644
b33395
--- a/mdadm.h
b33395
+++ b/mdadm.h
b33395
@@ -595,6 +595,7 @@ struct shape {
b33395
 	int	assume_clean;
b33395
 	int	write_behind;
b33395
 	unsigned long long size;
b33395
+	unsigned long long data_offset;
b33395
 	int	consistency_policy;
b33395
 };
b33395
 
b33395
@@ -1431,7 +1432,6 @@ extern int Grow_addbitmap(char *devname, int fd,
b33395
 			  struct context *c, struct shape *s);
b33395
 extern int Grow_reshape(char *devname, int fd,
b33395
 			struct mddev_dev *devlist,
b33395
-			unsigned long long data_offset,
b33395
 			struct context *c, struct shape *s);
b33395
 extern int Grow_restart(struct supertype *st, struct mdinfo *info,
b33395
 			int *fdlist, int cnt, char *backup_file, int verbose);
b33395
@@ -1462,8 +1462,7 @@ extern int Create(struct supertype *st, char *mddev,
b33395
 		  char *name, int *uuid,
b33395
 		  int subdevs, struct mddev_dev *devlist,
b33395
 		  struct shape *s,
b33395
-		  struct context *c,
b33395
-		  unsigned long long data_offset);
b33395
+		  struct context *c);
b33395
 
b33395
 extern int Detail(char *dev, struct context *c);
b33395
 extern int Detail_Platform(struct superswitch *ss, int scan, int verbose, int export, char *controller_path);
b33395
-- 
b33395
2.31.1
b33395