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

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