<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">Alasdair,

this patch cleans the dirty log external interface up from members
with only internal scope, such as list, name, module, ctr, dtr.

Please apply,
Heinz


Signed-off-by: Heinz Mauelshagen &lt;hjm@redhat.com&gt;
---
 drivers/md/dm-log.c |  120 ++++++++++++++++++++++++++++++++--------------------
 drivers/md/dm-log.h |   22 +--------
 2 files changed, 79 insertions(+), 63 deletions(-)

Index: linux-2.6.25-rc4/drivers/md/dm-log.c
===================================================================
--- linux-2.6.25-rc4.orig/drivers/md/dm-log.c	2008-03-14 17:24:35.000000000 +0000
+++ linux-2.6.25-rc4/drivers/md/dm-log.c	2008-03-14 17:32:25.000000000 +0000
@@ -19,7 +19,21 @@
 static LIST_HEAD(_log_types);
 static DEFINE_SPINLOCK(_lock);
 
-int dm_dirty_log_type_register(struct dm_dirty_log_type *type)
+struct dm_dirty_log_type {
+	struct list_head list;
+	const char *name;
+	struct module *module;
+	unsigned use_count;
+
+	int (*ctr)(struct dm_dirty_log *log, struct dm_target *ti,
+		   unsigned argc, char **argv);
+	void (*dtr)(struct dm_dirty_log *log);
+
+	struct dm_dirty_log_ops log_ops;
+};
+
+
+static int dm_dirty_log_type_register(struct dm_dirty_log_ops *log_ops)
 {
 	spin_lock(&amp;_lock);
 	type-&gt;use_count = 0;
@@ -28,9 +42,8 @@ int dm_dirty_log_type_register(struct dm
 
 	return 0;
 }
-EXPORT_SYMBOL(dm_dirty_log_type_register);
 
-int dm_dirty_log_type_unregister(struct dm_dirty_log_type *type)
+static int dm_dirty_log_type_unregister(const char *type_name)
 {
 	spin_lock(&amp;_lock);
 
@@ -43,11 +56,10 @@ int dm_dirty_log_type_unregister(struct 
 
 	return 0;
 }
-EXPORT_SYMBOL(dm_dirty_log_type_unregister);
 
-static struct dm_dirty_log_type *_get_type(const char *type_name)
+static struct dirty_log_type *_get_type(const char *type_name)
 {
-	struct dm_dirty_log_type *type;
+	struct dirty_log_type *type;
 
 	spin_lock(&amp;_lock);
 	list_for_each_entry (type, &amp;_log_types, list)
@@ -56,6 +68,7 @@ static struct dm_dirty_log_type *_get_ty
 				spin_unlock(&amp;_lock);
 				return NULL;
 			}
+
 			type-&gt;use_count++;
 			spin_unlock(&amp;_lock);
 			return type;
@@ -82,10 +95,10 @@ static struct dm_dirty_log_type *_get_ty
  *
  * Returns: dirty_log_type* on success, NULL on failure
  */
-static struct dm_dirty_log_type *get_type(const char *type_name)
+static struct dirty_log_type *get_type(const char *type_name)
 {
 	char *p, *type_name_dup;
-	struct dm_dirty_log_type *type;
+	struct dirty_log_type *type;
 
 	type = _get_type(type_name);
 	if (type)
@@ -114,7 +127,7 @@ static struct dm_dirty_log_type *get_typ
 	return type;
 }
 
-static void put_type(struct dm_dirty_log_type *type)
+static void put_type(struct dirty_log_type *type)
 {
 	spin_lock(&amp;_lock);
 	if (!--type-&gt;use_count)
@@ -122,10 +135,12 @@ static void put_type(struct dm_dirty_log
 	spin_unlock(&amp;_lock);
 }
 
-struct dm_dirty_log *dm_dirty_log_create(const char *type_name, struct dm_target *ti,
-				      unsigned int argc, char **argv)
+/* Create a dirty log. */
+struct dm_dirty_log *
+dm_dirty_log_create(const char *type_name, struct dm_target *ti,
+		    unsigned int argc, char **argv)
 {
-	struct dm_dirty_log_type *type;
+	struct dirty_log_type *type;
 	struct dm_dirty_log *log;
 
 	log = kmalloc(sizeof(*log), GFP_KERNEL);
@@ -138,7 +153,7 @@ struct dm_dirty_log *dm_dirty_log_create
 		return NULL;
 	}
 
-	log-&gt;type = type;
+	log-&gt;type = &amp;type-&gt;log_ops;
 	if (type-&gt;ctr(log, ti, argc, argv)) {
 		kfree(log);
 		put_type(type);
@@ -151,8 +166,11 @@ EXPORT_SYMBOL(dm_dirty_log_create);
 
 void dm_dirty_log_destroy(struct dm_dirty_log *log)
 {
-	log-&gt;type-&gt;dtr(log);
-	put_type(log-&gt;type);
+	struct dirty_log_type *type =
+		container_of(log-&gt;type, struct dirty_log_type, log_ops);
+
+	type-&gt;dtr(log);
+	put_type(type);
 	kfree(log);
 }
 EXPORT_SYMBOL(dm_dirty_log_destroy);
@@ -690,15 +708,17 @@ static int core_status(struct dm_dirty_l
 		       char *result, unsigned int maxlen)
 {
 	int sz = 0;
+	struct dirty_log_type *type =
+		container_of(log-&gt;type, struct dirty_log_type, log_ops);
 	struct log_c *lc = log-&gt;context;
 
 	switch(status) {
 	case STATUSTYPE_INFO:
-		DMEMIT("1 %s", log-&gt;type-&gt;name);
+		DMEMIT("1 %s", type-&gt;name);
 		break;
 
 	case STATUSTYPE_TABLE:
-		DMEMIT("%s %u %u ", log-&gt;type-&gt;name,
+		DMEMIT("%s %u %u ", type-&gt;name,
 		       lc-&gt;sync == DEFAULTSYNC ? 1 : 2, lc-&gt;region_size);
 		DMEMIT_SYNC;
 	}
@@ -710,16 +730,18 @@ static int disk_status(struct dm_dirty_l
 		       char *result, unsigned int maxlen)
 {
 	int sz = 0;
+	struct dirty_log_type *type =
+		container_of(log-&gt;type, struct dirty_log_type, log_ops);
 	struct log_c *lc = log-&gt;context;
 
 	switch(status) {
 	case STATUSTYPE_INFO:
-		DMEMIT("3 %s %s %c", log-&gt;type-&gt;name, lc-&gt;log_dev-&gt;name,
+		DMEMIT("3 %s %s %c", type-&gt;name, lc-&gt;log_dev-&gt;name,
 		       lc-&gt;log_dev_failed ? 'D' : 'A');
 		break;
 
 	case STATUSTYPE_TABLE:
-		DMEMIT("%s %u %s %u ", log-&gt;type-&gt;name,
+		DMEMIT("%s %u %s %u ", type-&gt;name,
 		       lc-&gt;sync == DEFAULTSYNC ? 2 : 3, lc-&gt;log_dev-&gt;name,
 		       lc-&gt;region_size);
 		DMEMIT_SYNC;
@@ -728,41 +750,51 @@ static int disk_status(struct dm_dirty_l
 	return sz;
 }
 
-static struct dm_dirty_log_type _core_type = {
+static struct dirty_log_type _core_type = {
+	/* Internal members. */
 	.name = "core",
 	.module = THIS_MODULE,
 	.ctr = core_ctr,
 	.dtr = core_dtr,
-	.resume = core_resume,
-	.get_region_size = core_get_region_size,
-	.is_clean = core_is_clean,
-	.in_sync = core_in_sync,
-	.flush = core_flush,
-	.mark_region = core_mark_region,
-	.clear_region = core_clear_region,
-	.get_resync_work = core_get_resync_work,
-	.set_region_sync = core_set_region_sync,
-	.get_sync_count = core_get_sync_count,
-	.status = core_status,
+
+	/* External interface. */
+	.log_ops = {
+		.resume = core_resume,
+		.get_region_size = core_get_region_size,
+		.is_clean = core_is_clean,
+		.in_sync = core_in_sync,
+		.flush = core_flush,
+		.mark_region = core_mark_region,
+		.clear_region = core_clear_region,
+		.get_resync_work = core_get_resync_work,
+		.set_region_sync = core_set_region_sync,
+		.get_sync_count = core_get_sync_count,
+		.status = core_status,
+	}
 };
 
-static struct dm_dirty_log_type _disk_type = {
+static struct dirty_log_type _disk_type = {
+	/* Internal members. */
 	.name = "disk",
 	.module = THIS_MODULE,
 	.ctr = disk_ctr,
 	.dtr = disk_dtr,
-	.postsuspend = disk_flush,
-	.resume = disk_resume,
-	.get_region_size = core_get_region_size,
-	.is_clean = core_is_clean,
-	.in_sync = core_in_sync,
-	.flush = disk_flush,
-	.mark_region = core_mark_region,
-	.clear_region = core_clear_region,
-	.get_resync_work = core_get_resync_work,
-	.set_region_sync = core_set_region_sync,
-	.get_sync_count = core_get_sync_count,
-	.status = disk_status,
+
+	/* External interface. */
+	.log_ops = {
+		.postsuspend = disk_flush,
+		.resume = disk_resume,
+		.get_region_size = core_get_region_size,
+		.is_clean = core_is_clean,
+		.in_sync = core_in_sync,
+		.flush = disk_flush,
+		.mark_region = core_mark_region,
+		.clear_region = core_clear_region,
+		.get_resync_work = core_get_resync_work,
+		.set_region_sync = core_set_region_sync,
+		.get_sync_count = core_get_sync_count,
+		.status = disk_status,
+	}
 };
 
 int __init dm_dirty_log_init(void)
Index: linux-2.6.25-rc4/drivers/md/dm-log.h
===================================================================
--- linux-2.6.25-rc4.orig/drivers/md/dm-log.h	2008-03-14 17:24:35.000000000 +0000
+++ linux-2.6.25-rc4/drivers/md/dm-log.h	2008-03-14 17:28:56.000000000 +0000
@@ -17,23 +17,14 @@
 
 typedef sector_t region_t;
 
-struct dm_dirty_log_type;
+struct dm_dirty_log_ops;
 
 struct dm_dirty_log {
-	struct dm_dirty_log_type *type;
+	struct dm_dirty_log_ops *log_ops;
 	void *context;
 };
 
-struct dm_dirty_log_type {
-	struct list_head list;
-	const char *name;
-	struct module *module;
-	unsigned use_count;
-
-	int (*ctr)(struct dm_dirty_log *log, struct dm_target *ti,
-		   unsigned argc, char **argv);
-	void (*dtr)(struct dm_dirty_log *log);
-
+struct dm_dirty_log_ops {
 	/*
 	 * There are times when we don't want the log to touch
 	 * the disk.
@@ -117,13 +108,6 @@ struct dm_dirty_log_type {
 		      char *result, unsigned maxlen);
 };
 
-int dm_dirty_log_type_register(struct dm_dirty_log_type *type);
-int dm_dirty_log_type_unregister(struct dm_dirty_log_type *type);
-
-/*
- * Make sure you use these two functions, rather than calling
- * type-&gt;constructor/destructor() directly.
- */
 struct dm_dirty_log *dm_dirty_log_create(const char *type_name,
 					 struct dm_target *ti,
 					 unsigned argc, char **argv);
</pre></body></html>