mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] dm: Repair persistent minors
@ 2003-06-11 10:05 Joe Thornber
  2003-06-11 10:19 ` Bernd Eckenfels
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Thornber @ 2003-06-11 10:05 UTC (permalink / raw)
  To: Linus Torvalds, Linux Mailing List

Split the dm_create() function into two variants, depending on whether
you want the device to have a specific minor number.  This avoids
the broken overloading of the minor argument to the old dm_create().

--- diff/drivers/md/dm-ioctl.c	2003-06-11 10:31:17.000000000 +0100
+++ source/drivers/md/dm-ioctl.c	2003-06-11 10:32:11.000000000 +0100
@@ -560,7 +560,6 @@
 	int r;
 	struct dm_table *t;
 	struct mapped_device *md;
-	unsigned int minor = 0;
 
 	r = check_name(param->name);
 	if (r)
@@ -577,9 +576,10 @@
 	}
 
 	if (param->flags & DM_PERSISTENT_DEV_FLAG)
-		minor = minor(to_kdev_t(param->dev));
+		r = dm_create_with_minor(minor(to_kdev_t(param->dev)), t, &md);
+	else
+		r = dm_create(t, &md);
 
-	r = dm_create(minor, t, &md);
 	if (r) {
 		dm_table_put(t);
 		return r;
--- diff/drivers/md/dm.c	2003-06-11 10:31:41.000000000 +0100
+++ source/drivers/md/dm.c	2003-06-11 10:32:54.000000000 +0100
@@ -569,7 +569,7 @@
 /*
  * Allocate and initialise a blank device with a given minor.
  */
-static struct mapped_device *alloc_dev(unsigned int minor)
+static struct mapped_device *alloc_dev(unsigned int minor, int persistent)
 {
 	int r;
 	struct mapped_device *md = kmalloc(sizeof(*md), GFP_KERNEL);
@@ -580,7 +580,7 @@
 	}
 
 	/* get a minor number for the dev */
-	r = (minor < 0) ? next_free_minor(&minor) : specific_minor(minor);
+	r = persistent ? specific_minor(minor) : next_free_minor(&minor);
 	if (r < 0) {
 		kfree(md);
 		return NULL;
@@ -660,13 +660,13 @@
 /*
  * Constructor for a new device.
  */
-int dm_create(unsigned int minor, struct dm_table *table,
-	      struct mapped_device **result)
+static int create_aux(unsigned int minor, int persistent,
+		      struct dm_table *table, struct mapped_device **result)
 {
 	int r;
 	struct mapped_device *md;
 
-	md = alloc_dev(minor);
+	md = alloc_dev(minor, persistent);
 	if (!md)
 		return -ENXIO;
 
@@ -681,6 +681,17 @@
 	return 0;
 }
 
+int dm_create(struct dm_table *table, struct mapped_device **result)
+{
+	return create_aux(0, 0, table, result);
+}
+
+int dm_create_with_minor(unsigned int minor,
+			 struct dm_table *table, struct mapped_device **result)
+{
+	return create_aux(minor, 1, table, result);
+}
+
 void dm_get(struct mapped_device *md)
 {
 	atomic_inc(&md->holders);
--- diff/drivers/md/dm.h	2003-06-11 10:31:27.000000000 +0100
+++ source/drivers/md/dm.h	2003-06-11 10:32:11.000000000 +0100
@@ -51,8 +51,9 @@
  * Functions for manipulating a struct mapped_device.
  * Drop the reference with dm_put when you finish with the object.
  *---------------------------------------------------------------*/
-int dm_create(unsigned int minor, struct dm_table *table,
-	      struct mapped_device **md);
+int dm_create(struct dm_table *table, struct mapped_device **md);
+int dm_create_with_minor(unsigned int minor, struct dm_table *table,
+			 struct mapped_device **md);
 
 /*
  * Reference counting for md.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] dm: Repair persistent minors
  2003-06-11 10:05 [PATCH 1/1] dm: Repair persistent minors Joe Thornber
@ 2003-06-11 10:19 ` Bernd Eckenfels
  2003-06-11 11:59   ` Joe Thornber
  0 siblings, 1 reply; 3+ messages in thread
From: Bernd Eckenfels @ 2003-06-11 10:19 UTC (permalink / raw)
  To: linux-kernel

In article <20030611100542.GD2499@fib011235813.fsnet.co.uk> you wrote:
> Split the dm_create() function into two variants, depending on whether
> you want the device to have a specific minor number.  This avoids
> the broken overloading of the minor argument to the old dm_create().

why dont you just call dm_create_with_minor() from dm_create and skip the
create_aux function? the create_aux function is pretty badly named, me
thinks. you sould at least call it dm_create_aux.

Greetings
Bernd
-- 
eckes privat - http://www.eckes.org/
Project Freefire - http://www.freefire.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] dm: Repair persistent minors
  2003-06-11 10:19 ` Bernd Eckenfels
@ 2003-06-11 11:59   ` Joe Thornber
  0 siblings, 0 replies; 3+ messages in thread
From: Joe Thornber @ 2003-06-11 11:59 UTC (permalink / raw)
  To: Bernd Eckenfels; +Cc: linux-kernel

On Wed, Jun 11, 2003 at 12:19:48PM +0200, Bernd Eckenfels wrote:
> In article <20030611100542.GD2499@fib011235813.fsnet.co.uk> you wrote:
> > Split the dm_create() function into two variants, depending on whether
> > you want the device to have a specific minor number.  This avoids
> > the broken overloading of the minor argument to the old dm_create().
> 
> why dont you just call dm_create_with_minor() from dm_create and skip the
> create_aux function?

Because I'm trying to avoid having a special value to the 'minor' arg
to indicate that we can use any minor.

> the create_aux function is pretty badly named, me
> thinks. you sould at least call it dm_create_aux.

I use the dm_ prefix for external functions.

- Joe

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-06-11 11:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-11 10:05 [PATCH 1/1] dm: Repair persistent minors Joe Thornber
2003-06-11 10:19 ` Bernd Eckenfels
2003-06-11 11:59   ` Joe Thornber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®