Blame SOURCES/0032-DDF-Cleanup-validate_geometry_ddf_container.patch

c0f891
From 679bd9508a30b2a0a1baecc9a21dd6c7d8d8d7dc Mon Sep 17 00:00:00 2001
c0f891
From: Logan Gunthorpe <logang@deltatee.com>
c0f891
Date: Wed, 22 Jun 2022 14:25:07 -0600
37f2b0
Subject: [PATCH 32/83] DDF: Cleanup validate_geometry_ddf_container()
c0f891
c0f891
Move the function up so that the function declaration is not necessary
c0f891
and remove the unused arguments to the function.
c0f891
c0f891
No functional changes are intended but will help with a bug fix in the
c0f891
next patch.
c0f891
c0f891
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
c0f891
Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
c0f891
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
c0f891
---
c0f891
 super-ddf.c | 88 ++++++++++++++++++++++++-----------------------------
c0f891
 1 file changed, 39 insertions(+), 49 deletions(-)
c0f891
c0f891
diff --git a/super-ddf.c b/super-ddf.c
c0f891
index abbc8b09..9d867f69 100644
c0f891
--- a/super-ddf.c
c0f891
+++ b/super-ddf.c
c0f891
@@ -503,13 +503,6 @@ struct ddf_super {
c0f891
 static int load_super_ddf_all(struct supertype *st, int fd,
c0f891
 			      void **sbp, char *devname);
c0f891
 static int get_svd_state(const struct ddf_super *, const struct vcl *);
c0f891
-static int
c0f891
-validate_geometry_ddf_container(struct supertype *st,
c0f891
-				int level, int layout, int raiddisks,
c0f891
-				int chunk, unsigned long long size,
c0f891
-				unsigned long long data_offset,
c0f891
-				char *dev, unsigned long long *freesize,
c0f891
-				int verbose);
c0f891
 
c0f891
 static int validate_geometry_ddf_bvd(struct supertype *st,
c0f891
 				     int level, int layout, int raiddisks,
c0f891
@@ -3322,6 +3315,42 @@ static int reserve_space(struct supertype *st, int raiddisks,
c0f891
 	return 1;
c0f891
 }
c0f891
 
c0f891
+static int
c0f891
+validate_geometry_ddf_container(struct supertype *st,
c0f891
+				int level, int raiddisks,
c0f891
+				unsigned long long data_offset,
c0f891
+				char *dev, unsigned long long *freesize,
c0f891
+				int verbose)
c0f891
+{
c0f891
+	int fd;
c0f891
+	unsigned long long ldsize;
c0f891
+
c0f891
+	if (level != LEVEL_CONTAINER)
c0f891
+		return 0;
c0f891
+	if (!dev)
c0f891
+		return 1;
c0f891
+
c0f891
+	fd = dev_open(dev, O_RDONLY|O_EXCL);
c0f891
+	if (fd < 0) {
c0f891
+		if (verbose)
c0f891
+			pr_err("ddf: Cannot open %s: %s\n",
c0f891
+			       dev, strerror(errno));
c0f891
+		return 0;
c0f891
+	}
c0f891
+	if (!get_dev_size(fd, dev, &ldsize)) {
c0f891
+		close(fd);
c0f891
+		return 0;
c0f891
+	}
c0f891
+	close(fd);
c0f891
+	if (freesize) {
c0f891
+		*freesize = avail_size_ddf(st, ldsize >> 9, INVALID_SECTORS);
c0f891
+		if (*freesize == 0)
c0f891
+			return 0;
c0f891
+	}
c0f891
+
c0f891
+	return 1;
c0f891
+}
c0f891
+
c0f891
 static int validate_geometry_ddf(struct supertype *st,
c0f891
 				 int level, int layout, int raiddisks,
c0f891
 				 int *chunk, unsigned long long size,
c0f891
@@ -3347,11 +3376,9 @@ static int validate_geometry_ddf(struct supertype *st,
c0f891
 		level = LEVEL_CONTAINER;
c0f891
 	if (level == LEVEL_CONTAINER) {
c0f891
 		/* Must be a fresh device to add to a container */
c0f891
-		return validate_geometry_ddf_container(st, level, layout,
c0f891
-						       raiddisks, *chunk,
c0f891
-						       size, data_offset, dev,
c0f891
-						       freesize,
c0f891
-						       verbose);
c0f891
+		return validate_geometry_ddf_container(st, level, raiddisks,
c0f891
+						       data_offset, dev,
c0f891
+						       freesize, verbose);
c0f891
 	}
c0f891
 
c0f891
 	if (!dev) {
c0f891
@@ -3449,43 +3476,6 @@ static int validate_geometry_ddf(struct supertype *st,
c0f891
 	return 1;
c0f891
 }
c0f891
 
c0f891
-static int
c0f891
-validate_geometry_ddf_container(struct supertype *st,
c0f891
-				int level, int layout, int raiddisks,
c0f891
-				int chunk, unsigned long long size,
c0f891
-				unsigned long long data_offset,
c0f891
-				char *dev, unsigned long long *freesize,
c0f891
-				int verbose)
c0f891
-{
c0f891
-	int fd;
c0f891
-	unsigned long long ldsize;
c0f891
-
c0f891
-	if (level != LEVEL_CONTAINER)
c0f891
-		return 0;
c0f891
-	if (!dev)
c0f891
-		return 1;
c0f891
-
c0f891
-	fd = dev_open(dev, O_RDONLY|O_EXCL);
c0f891
-	if (fd < 0) {
c0f891
-		if (verbose)
c0f891
-			pr_err("ddf: Cannot open %s: %s\n",
c0f891
-			       dev, strerror(errno));
c0f891
-		return 0;
c0f891
-	}
c0f891
-	if (!get_dev_size(fd, dev, &ldsize)) {
c0f891
-		close(fd);
c0f891
-		return 0;
c0f891
-	}
c0f891
-	close(fd);
c0f891
-	if (freesize) {
c0f891
-		*freesize = avail_size_ddf(st, ldsize >> 9, INVALID_SECTORS);
c0f891
-		if (*freesize == 0)
c0f891
-			return 0;
c0f891
-	}
c0f891
-
c0f891
-	return 1;
c0f891
-}
c0f891
-
c0f891
 static int validate_geometry_ddf_bvd(struct supertype *st,
c0f891
 				     int level, int layout, int raiddisks,
c0f891
 				     int *chunk, unsigned long long size,
c0f891
-- 
37f2b0
2.38.1
c0f891