Skip to contentSkip to conversation

dm thin: rename dm_thin_id to more generic dm_dev_id

PATCH In review Mike Snitzer 3 participants 6 messages Mar 2, 2012 – Mar 5, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dm thin: rename dm_thin_id to more generic dm_dev_id

dm_thin_id is too specific to thin devices. Rename to allow for reuse by other targets.

---
 drivers/md/dm-thin-metadata.c |   24 ++++++++++++------------
 drivers/md/dm-thin-metadata.h |   14 +++++++-------
 drivers/md/dm-thin.c          |   16 ++++++++--------
 3 files changed, 27 insertions(+), 27 deletions(-)
drivers/md/dm-thin-metadata.c +12 -12
index 1783741..62e7024 100644
@@ -184,7 +184,7 @@ struct dm_pool_metadata {
 struct dm_thin_device {
 	struct list_head list;
 	struct dm_pool_metadata *pmd;
-	dm_thin_id id;
+	dm_dev_id id;
 
 	int open_count;
 	int changed;
@@ -799,7 +799,7 @@ int dm_pool_metadata_close(struct dm_pool_metadata *pmd)
  * on failure, @td is not initialized.
  */
 static int __open_device(struct dm_pool_metadata *pmd,
-			 dm_thin_id dev, int create,
+			 dm_dev_id dev, int create,
 			 struct dm_thin_device **td)
 {
 	int r, changed = 0;
@@ -867,7 +867,7 @@ static void __close_device(struct dm_thin_device *td)
 }
 
 static int __create_thin(struct dm_pool_metadata *pmd,
-			 dm_thin_id dev)
+			 dm_dev_id dev)
 {
 	int r;
 	dm_block_t dev_root;
@@ -910,7 +910,7 @@ static int __create_thin(struct dm_pool_metadata *pmd,
 	return r;
 }
 
-int dm_pool_create_thin(struct dm_pool_metadata *pmd, dm_thin_id dev)
+int dm_pool_create_thin(struct dm_pool_metadata *pmd, dm_dev_id dev)
 {
 	int r;
 
@@ -923,7 +923,7 @@ int dm_pool_create_thin(struct dm_pool_metadata *pmd, dm_thin_id dev)
 
 static int __set_snapshot_details(struct dm_pool_metadata *pmd,
 				  struct dm_thin_device *snap,
-				  dm_thin_id origin, uint32_t time)
+				  dm_dev_id origin, uint32_t time)
 {
 	int r;
 	struct dm_thin_device *td;
@@ -943,7 +943,7 @@ static int __set_snapshot_details(struct dm_pool_metadata *pmd,
 }
 
 static int __create_snap(struct dm_pool_metadata *pmd,
-			 dm_thin_id dev, dm_thin_id origin)
+			 dm_dev_id dev, dm_dev_id origin)
 {
 	int r;
 	dm_block_t origin_root;
@@ -1000,8 +1000,8 @@ bad:
 }
 
 int dm_pool_create_snap(struct dm_pool_metadata *pmd,
-				 dm_thin_id dev,
-				 dm_thin_id origin)
+				 dm_dev_id dev,
+				 dm_dev_id origin)
 {
 	int r;
 
@@ -1012,7 +1012,7 @@ int dm_pool_create_snap(struct dm_pool_metadata *pmd,
 	return r;
 }
 
-static int __delete_device(struct dm_pool_metadata *pmd, dm_thin_id dev)
+static int __delete_device(struct dm_pool_metadata *pmd, dm_dev_id dev)
 {
 	int r;
 	uint64_t key = dev;
@@ -1045,7 +1045,7 @@ static int __delete_device(struct dm_pool_metadata *pmd, dm_thin_id dev)
 }
 
 int dm_pool_delete_thin_device(struct dm_pool_metadata *pmd,
-			       dm_thin_id dev)
+			       dm_dev_id dev)
 {
 	int r;
 
@@ -1188,7 +1188,7 @@ int dm_pool_get_held_metadata_root(struct dm_pool_metadata *pmd,
 	return r;
 }
 
-int dm_pool_open_thin_device(struct dm_pool_metadata *pmd, dm_thin_id dev,
+int dm_pool_open_thin_device(struct dm_pool_metadata *pmd, dm_dev_id dev,
 			     struct dm_thin_device **td)
 {
 	int r;
@@ -1209,7 +1209,7 @@ int dm_pool_close_thin_device(struct dm_thin_device *td)
 	return 0;
 }
 
-dm_thin_id dm_thin_dev_id(struct dm_thin_device *td)
+dm_dev_id dm_thin_dev_id(struct dm_thin_device *td)
 {
 	return td->id;
 }
drivers/md/dm-thin-metadata.h +7 -7
index 4460857..511a223 100644
@@ -34,7 +34,7 @@ struct dm_thin_device;
 /*
  * Device identifier
  */
-typedef uint64_t dm_thin_id;
+typedef uint64_t dm_dev_id;
 
 /*
  * Reopens or creates a new, empty metadata volume.
@@ -55,7 +55,7 @@ int dm_pool_metadata_close(struct dm_pool_metadata *pmd);
 /*
  * Device creation/deletion.
  */
-int dm_pool_create_thin(struct dm_pool_metadata *pmd, dm_thin_id dev);
+int dm_pool_create_thin(struct dm_pool_metadata *pmd, dm_dev_id dev);
 
 /*
  * An internal snapshot.
@@ -63,8 +63,8 @@ int dm_pool_create_thin(struct dm_pool_metadata *pmd, dm_thin_id dev);
  * You can only snapshot a quiesced origin i.e. one that is either
  * suspended or not instanced at all.
  */
-int dm_pool_create_snap(struct dm_pool_metadata *pmd, dm_thin_id dev,
-			dm_thin_id origin);
+int dm_pool_create_snap(struct dm_pool_metadata *pmd, dm_dev_id dev,
+			dm_dev_id origin);
 
 /*
  * Deletes a virtual device from the metadata.  It _is_ safe to call this
@@ -72,7 +72,7 @@ int dm_pool_create_snap(struct dm_pool_metadata *pmd, dm_thin_id dev,
  * failing.  You still need to call close() on the device.
  */
 int dm_pool_delete_thin_device(struct dm_pool_metadata *pmd,
-			       dm_thin_id dev);
+			       dm_dev_id dev);
 
 /*
  * Commits _all_ metadata changes: device creation, deletion, mapping
@@ -106,12 +106,12 @@ int dm_pool_get_held_metadata_root(struct dm_pool_metadata *pmd,
 /*
  * Opening the same device more than once will fail with -EBUSY.
  */
-int dm_pool_open_thin_device(struct dm_pool_metadata *pmd, dm_thin_id dev,
+int dm_pool_open_thin_device(struct dm_pool_metadata *pmd, dm_dev_id dev,
 			     struct dm_thin_device **td);
 
 int dm_pool_close_thin_device(struct dm_thin_device *td);
 
-dm_thin_id dm_thin_dev_id(struct dm_thin_device *td);
+dm_dev_id dm_thin_dev_id(struct dm_thin_device *td);
 
 struct dm_thin_lookup_result {
 	dm_block_t block;
drivers/md/dm-thin.c +8 -8
index d9ea643..536835f 100644
@@ -107,7 +107,7 @@ struct bio_prison;
 
 struct cell_key {
 	int virtual;
-	dm_thin_id dev;
+	dm_dev_id dev;
 	dm_block_t block;
 };
 
@@ -560,7 +560,7 @@ struct pool_c {
 struct thin_c {
 	struct dm_dev *pool_dev;
 	struct dm_dev *origin_dev;
-	dm_thin_id dev_id;
+	dm_dev_id dev_id;
 
 	struct pool *pool;
 	struct dm_thin_device *td;
@@ -2116,7 +2116,7 @@ static int check_arg_count(unsigned argc, unsigned args_required)
 	return 0;
 }
 
-static int read_dev_id(char *arg, dm_thin_id *dev_id, int warning)
+static int read_dev_id(char *arg, dm_dev_id *dev_id, int warning)
 {
 	if (!kstrtoull(arg, 10, (unsigned long long *)dev_id) &&
 	    *dev_id <= MAX_DEV_ID)
@@ -2130,7 +2130,7 @@ static int read_dev_id(char *arg, dm_thin_id *dev_id, int warning)
 
 static int process_create_thin_mesg(unsigned argc, char **argv, struct pool *pool)
 {
-	dm_thin_id dev_id;
+	dm_dev_id dev_id;
 	int r;
 
 	r = check_arg_count(argc, 2);
@@ -2153,8 +2153,8 @@ static int process_create_thin_mesg(unsigned argc, char **argv, struct pool *poo
 
 static int process_create_snap_mesg(unsigned argc, char **argv, struct pool *pool)
 {
-	dm_thin_id dev_id;
-	dm_thin_id origin_dev_id;
+	dm_dev_id dev_id;
+	dm_dev_id origin_dev_id;
 	int r;
 
 	r = check_arg_count(argc, 3);
@@ -2181,7 +2181,7 @@ static int process_create_snap_mesg(unsigned argc, char **argv, struct pool *poo
 
 static int process_delete_mesg(unsigned argc, char **argv, struct pool *pool)
 {
-	dm_thin_id dev_id;
+	dm_dev_id dev_id;
 	int r;
 
 	r = check_arg_count(argc, 2);
@@ -2201,7 +2201,7 @@ static int process_delete_mesg(unsigned argc, char **argv, struct pool *pool)
 
 static int process_set_transaction_id_mesg(unsigned argc, char **argv, struct pool *pool)
 {
-	dm_thin_id old_id, new_id;
+	dm_dev_id old_id, new_id;
 	int r;
 
 	r = check_arg_count(argc, 3);
Signature · 1 line
1.7.1
#1 lore raw

PATCH 2/2 dm thin: elevate the bio_prison and deferred_set code to allow for re-use

Allow other DM targets to make use of the bio_prison and deferred_set infrastructure. Code elevated to drivers/md/dm-bio-prison.[hc]

---
 drivers/md/Makefile           |    2 +-
 drivers/md/dm-bio-prison.c    |  336 +++++++++++++++++++++++++++++++++++++
 drivers/md/dm-bio-prison.h    |  110 ++++++++++++
 drivers/md/dm-thin-metadata.h |    6 +-
 drivers/md/dm-thin.c          |  368 +----------------------------------------
 5 files changed, 449 insertions(+), 373 deletions(-)
 create mode 100644 drivers/md/dm-bio-prison.c
 create mode 100644 drivers/md/dm-bio-prison.h
drivers/md/Makefile +1 -1
index 046860c..c1706ed 100644
@@ -3,7 +3,7 @@
 #
 
 dm-mod-y	+= dm.o dm-table.o dm-target.o dm-linear.o dm-stripe.o \
-		   dm-ioctl.o dm-io.o dm-kcopyd.o dm-sysfs.o
+		   dm-ioctl.o dm-io.o dm-kcopyd.o dm-sysfs.o dm-bio-prison.o
 dm-multipath-y	+= dm-path-selector.o dm-mpath.o
 dm-snapshot-y	+= dm-snap.o dm-exception-store.o dm-snap-transient.o \
 		    dm-snap-persistent.o
drivers/md/dm-bio-prison.c new file +336 -0

336 lines not on this page · raw message

drivers/md/dm-bio-prison.h new file +110 -0

110 lines not on this page · raw message

drivers/md/dm-thin-metadata.h +1 -5
index 511a223..d718189 100644
@@ -7,6 +7,7 @@
 #ifndef DM_THIN_METADATA_H
 #define DM_THIN_METADATA_H
 
+#include "dm-bio-prison.h"
 #include "persistent-data/dm-block-manager.h"
 
 #define THIN_METADATA_BLOCK_SIZE 4096
@@ -32,11 +33,6 @@ struct dm_pool_metadata;
 struct dm_thin_device;
 
 /*
- * Device identifier
- */
-typedef uint64_t dm_dev_id;
-
-/*
  * Reopens or creates a new, empty metadata volume.
  */
 struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev,
drivers/md/dm-thin.c +1 -367

386 lines not on this page · raw message

Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH 2/2] dm thin: elevate the bio_prison and deferred_set code to allow for re-use

Quoted 1 line · Mike Snitzer

+EXPORT_SYMBOL(prison_create);

_GPL please and place a dm_something prefix on everything exported.

Thanks,
Alasdair

#3 lore raw

PATCH v2 2/2 dm thin: elevate the bio_prison and deferred_set code to allow for re-use

In reply to Mike Snitzer

Allow other DM targets to make use of the bio_prison and deferred_set infrastructure. Code elevated to drivers/md/dm-bio-prison.[hc]

---
 drivers/md/Makefile           |    2 
 drivers/md/dm-bio-prison.c    |  336 ++++++++++++++++++++++++++++++++
 drivers/md/dm-bio-prison.h    |  109 ++++++++++
 drivers/md/dm-thin-metadata.h |    6 
 drivers/md/dm-thin.c          |  438 +++---------------------------------------
 5 files changed, 483 insertions(+), 408 deletions(-)
 create mode 100644 drivers/md/dm-bio-prison.c
 create mode 100644 drivers/md/dm-bio-prison.h
drivers/md/Makefile +1 -1
Index: linux-2.6/drivers/md/Makefile
===================================================================
@@ -3,7 +3,7 @@
 #
 
 dm-mod-y	+= dm.o dm-table.o dm-target.o dm-linear.o dm-stripe.o \
-		   dm-ioctl.o dm-io.o dm-kcopyd.o dm-sysfs.o
+		   dm-ioctl.o dm-io.o dm-kcopyd.o dm-sysfs.o dm-bio-prison.o
 dm-multipath-y	+= dm-path-selector.o dm-mpath.o
 dm-snapshot-y	+= dm-snap.o dm-exception-store.o dm-snap-transient.o \
 		    dm-snap-persistent.o
drivers/md/dm-bio-prison.c new file +336 -0

336 lines not on this page · raw message

drivers/md/dm-bio-prison.h new file +109 -0

109 lines not on this page · raw message

drivers/md/dm-thin-metadata.h +1 -5
Index: linux-2.6/drivers/md/dm-thin-metadata.h
===================================================================
@@ -7,6 +7,7 @@
 #ifndef DM_THIN_METADATA_H
 #define DM_THIN_METADATA_H
 
+#include "dm-bio-prison.h"
 #include "persistent-data/dm-block-manager.h"
 
 #define THIN_METADATA_BLOCK_SIZE 4096
@@ -32,11 +33,6 @@ struct dm_pool_metadata;
 struct dm_thin_device;
 
 /*
- * Device identifier
- */
-typedef uint64_t dm_dev_id;
-
-/*
  * Reopens or creates a new, empty metadata volume.
  */
 struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev,
drivers/md/dm-thin.c +36 -402

642 lines not on this page · raw message

#4 lore raw
In reply to Mike Snitzer

This is part of the hsm target development work. Let's keep this in git for now; there's no point spamming dm-devel with work in progress. I'm happy to give you write access to my github repo if you like. Otherwise I can merge from any git repo you wish.

Quoted 2 lines · Mike Snitzer

dm_thin_id is too specific to thin devices. Rename to allow for reuse by other targets.

#5 lore raw
Quoted 4 lines · Joe Thornber

This is part of the hsm target development work. Let's keep this in git for now; there's no point spamming dm-devel with work in progress. I'm happy to give you write access to my github repo if you like. Otherwise I can merge from any git repo you wish.

Sure, dm-devel is just a public list (doubt people who care about DM see these patches as spam). I didn't see the need for a back channel exchange, but noted.