[dm-devel] accumulation of patches adding static, __exit qualfiers, etc.

Dave Olien dmo at osdl.org
Fri Apr 30 01:03:42 UTC 2004


This is a resend of my patches since (and including) last Friday's.
I've removed the improper __exit qualifiers that were in my patches
from Tuesday and Wednesday.

So, this includes miscellaneous additions of "static", __init, and
__exit qualifiers.  In addition, in contains:

	in dm-log.c:
		in the function dm_register_dirty_log_type(),
		I moved the try_module_get() outside the lock, and
		added an error return case if it fails.

		I also added .module=THIS_MODULE intializers to the _core_type
		and _disk_type declarations in this file.

	in dm-snap.c
		I put #if 0 around the definition of check_free_space(),
		since it isn't used.  I also put #if 0 around the commented
		out use of check_free_space later in that file.


diff -ur linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm.c linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm.c
--- linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm.c	2004-04-27 15:04:13.000000000 -0700
+++ linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm.c	2004-04-28 13:25:43.000000000 -0700
@@ -93,7 +93,7 @@
 static kmem_cache_t *_io_cache;
 static kmem_cache_t *_tio_cache;
 
-static __init int local_init(void)
+static int __init local_init(void)
 {
 	int r;
 
@@ -663,6 +663,8 @@
 	return r;
 }
 
+static struct block_device_operations dm_blk_dops;
+
 /*
  * Allocate and initialise a blank device with a given minor.
  */
@@ -1100,7 +1102,7 @@
 	return test_bit(DMF_SUSPENDED, &md->flags);
 }
 
-struct block_device_operations dm_blk_dops = {
+static struct block_device_operations dm_blk_dops = {
 	.open = dm_blk_open,
 	.release = dm_blk_close,
 	.owner = THIS_MODULE
diff -ur linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm-exception-store.c linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm-exception-store.c
--- linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm-exception-store.c	2004-04-27 15:04:13.000000000 -0700
+++ linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm-exception-store.c	2004-04-23 15:15:40.000000000 -0700
@@ -588,17 +588,17 @@
 	sector_t next_free;
 };
 
-void transient_destroy(struct exception_store *store)
+static void transient_destroy(struct exception_store *store)
 {
 	kfree(store->context);
 }
 
-int transient_read_metadata(struct exception_store *store)
+static int transient_read_metadata(struct exception_store *store)
 {
 	return 0;
 }
 
-int transient_prepare(struct exception_store *store, struct exception *e)
+static int transient_prepare(struct exception_store *store, struct exception *e)
 {
 	struct transient_c *tc = (struct transient_c *) store->context;
 	sector_t size = get_dev_size(store->snap->cow->bdev);
@@ -612,7 +612,7 @@
 	return 0;
 }
 
-void transient_commit(struct exception_store *store,
+static void transient_commit(struct exception_store *store,
 		      struct exception *e,
 		      void (*callback) (void *, int success),
 		      void *callback_context)
diff -ur linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm-flakey.c linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm-flakey.c
--- linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm-flakey.c	2004-04-27 15:04:15.000000000 -0700
+++ linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm-flakey.c	2004-04-27 19:21:17.000000000 -0700
@@ -141,7 +141,7 @@
 	return r;
 }
 
-void dm_flakey_exit(void)
+void __exit dm_flakey_exit(void)
 {
 	int r = dm_unregister_target(&flakey_target);
 
diff -ur linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm.h linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm.h
--- linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm.h	2004-04-27 15:04:13.000000000 -0700
+++ linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm.h	2004-04-27 19:02:05.000000000 -0700
@@ -31,8 +31,6 @@
 
 #define SECTOR_SHIFT 9
 
-extern struct block_device_operations dm_blk_dops;
-
 /*
  * List of devices that a metadevice uses and should open/close.
  */
diff -ur linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm-io.c linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm-io.c
--- linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm-io.c	2004-04-27 15:04:13.000000000 -0700
+++ linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm-io.c	2004-04-27 15:30:29.000000000 -0700
@@ -369,7 +369,7 @@
 /*
  * Functions for getting the pages from a list.
  */
-void list_get_page(struct dpages *dp,
+static void list_get_page(struct dpages *dp,
 		  struct page **p, unsigned long *len, unsigned *offset)
 {
 	unsigned o = dp->context_u;
@@ -380,14 +380,14 @@
 	*offset = o;
 }
 
-void list_next_page(struct dpages *dp)
+static void list_next_page(struct dpages *dp)
 {
 	struct page_list *pl = (struct page_list *) dp->context_ptr;
 	dp->context_ptr = pl->next;
 	dp->context_u = 0;
 }
 
-void list_dp_init(struct dpages *dp, struct page_list *pl, unsigned offset)
+static void list_dp_init(struct dpages *dp, struct page_list *pl, unsigned offset)
 {
 	dp->get_page = list_get_page;
 	dp->next_page = list_next_page;
@@ -398,7 +398,7 @@
 /*
  * Functions for getting the pages from a bvec.
  */
-void bvec_get_page(struct dpages *dp,
+static void bvec_get_page(struct dpages *dp,
 		  struct page **p, unsigned long *len, unsigned *offset)
 {
 	struct bio_vec *bvec = (struct bio_vec *) dp->context_ptr;
@@ -407,20 +407,20 @@
 	*offset = bvec->bv_offset;
 }
 
-void bvec_next_page(struct dpages *dp)
+static void bvec_next_page(struct dpages *dp)
 {
 	struct bio_vec *bvec = (struct bio_vec *) dp->context_ptr;
 	dp->context_ptr = bvec + 1;
 }
 
-void bvec_dp_init(struct dpages *dp, struct bio_vec *bvec)
+static void bvec_dp_init(struct dpages *dp, struct bio_vec *bvec)
 {
 	dp->get_page = bvec_get_page;
 	dp->next_page = bvec_next_page;
 	dp->context_ptr = bvec;
 }
 
-void vm_get_page(struct dpages *dp,
+static void vm_get_page(struct dpages *dp,
 		 struct page **p, unsigned long *len, unsigned *offset)
 {
 	*p = vmalloc_to_page(dp->context_ptr);
@@ -428,13 +428,13 @@
 	*len = PAGE_SIZE - dp->context_u;
 }
 
-void vm_next_page(struct dpages *dp)
+static void vm_next_page(struct dpages *dp)
 {
 	dp->context_ptr += PAGE_SIZE - dp->context_u;
 	dp->context_u = 0;
 }
 
-void vm_dp_init(struct dpages *dp, void *data)
+static void vm_dp_init(struct dpages *dp, void *data)
 {
 	dp->get_page = vm_get_page;
 	dp->next_page = vm_next_page;
@@ -516,7 +516,7 @@
 	dec_count(io, 0, 0);
 }
 
-int sync_io(unsigned int num_regions, struct io_region *where,
+static int sync_io(unsigned int num_regions, struct io_region *where,
 	    int rw, struct dpages *dp, unsigned long *error_bits)
 {
 	struct io io;
@@ -546,7 +546,7 @@
 	return io.error ? -EIO : 0;
 }
 
-int async_io(unsigned int num_regions, struct io_region *where, int rw,
+static int async_io(unsigned int num_regions, struct io_region *where, int rw,
 	     struct dpages *dp, io_notify_fn fn, void *context)
 {
 	struct io *io = mempool_alloc(_io_pool, GFP_NOIO);
@@ -615,6 +615,7 @@
 EXPORT_SYMBOL(dm_io_put);
 EXPORT_SYMBOL(dm_io_sync);
 EXPORT_SYMBOL(dm_io_async);
+EXPORT_SYMBOL(dm_io_sync_bvec);
 EXPORT_SYMBOL(dm_io_async_bvec);
 EXPORT_SYMBOL(dm_io_sync_vm);
 EXPORT_SYMBOL(dm_io_async_vm);
diff -ur linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm-ioctl.c linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm-ioctl.c
--- linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm-ioctl.c	2004-04-27 15:04:15.000000000 -0700
+++ linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm-ioctl.c	2004-04-28 13:21:09.000000000 -0700
@@ -46,7 +46,7 @@
 static struct list_head _name_buckets[NUM_BUCKETS];
 static struct list_head _uuid_buckets[NUM_BUCKETS];
 
-void dm_hash_remove_all(void);
+static void dm_hash_remove_all(void);
 
 /*
  * Guards access to both hash tables.
@@ -61,7 +61,7 @@
 		INIT_LIST_HEAD(buckets + i);
 }
 
-int dm_hash_init(void)
+static int dm_hash_init(void)
 {
 	init_buckets(_name_buckets);
 	init_buckets(_uuid_buckets);
@@ -69,7 +69,7 @@
 	return 0;
 }
 
-void dm_hash_exit(void)
+static void dm_hash_exit(void)
 {
 	dm_hash_remove_all();
 	devfs_remove(DM_DIR);
@@ -195,7 +195,7 @@
  * The kdev_t and uuid of a device can never change once it is
  * initially inserted.
  */
-int dm_hash_insert(const char *name, const char *uuid, struct mapped_device *md)
+static int dm_hash_insert(const char *name, const char *uuid, struct mapped_device *md)
 {
 	struct hash_cell *cell;
 
@@ -234,7 +234,7 @@
 	return -EBUSY;
 }
 
-void __hash_remove(struct hash_cell *hc)
+static void __hash_remove(struct hash_cell *hc)
 {
 	/* remove from the dev hash */
 	list_del(&hc->uuid_list);
@@ -246,7 +246,7 @@
 	free_cell(hc);
 }
 
-void dm_hash_remove_all(void)
+static void dm_hash_remove_all(void)
 {
 	int i;
 	struct hash_cell *hc;
@@ -262,7 +262,7 @@
 	up_write(&_hash_lock);
 }
 
-int dm_hash_rename(const char *old, const char *new)
+static int dm_hash_rename(const char *old, const char *new)
 {
 	char *new_name, *old_name;
 	struct hash_cell *hc;
diff -ur linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm-log.c linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm-log.c
--- linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm-log.c	2004-04-27 15:04:15.000000000 -0700
+++ linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm-log.c	2004-04-28 20:13:01.000000000 -0700
@@ -17,10 +17,11 @@
 
 int dm_register_dirty_log_type(struct dirty_log_type *type)
 {
+	if (!try_module_get(type->module))
+		return -EINVAL;
+
 	spin_lock(&_lock);
 	type->use_count = 0;
-	try_module_get(type->module);
-
 	list_add(&type->list, &_log_types);
 	spin_unlock(&_lock);
 
@@ -567,6 +568,7 @@
 
 static struct dirty_log_type _core_type = {
 	.name = "core",
+	.module = THIS_MODULE,
 	.ctr = core_ctr,
 	.dtr = core_dtr,
 	.get_region_size = core_get_region_size,
@@ -582,6 +584,7 @@
 
 static struct dirty_log_type _disk_type = {
 	.name = "disk",
+	.module = THIS_MODULE,
 	.ctr = disk_ctr,
 	.dtr = disk_dtr,
 	.suspend = disk_flush,
@@ -597,7 +600,7 @@
         .get_sync_count = core_get_sync_count
 };
 
-__init int dm_dirty_log_init(void)
+int __init dm_dirty_log_init(void)
 {
 	int r;
 
@@ -622,7 +625,5 @@
 
 EXPORT_SYMBOL(dm_register_dirty_log_type);
 EXPORT_SYMBOL(dm_unregister_dirty_log_type);
-EXPORT_SYMBOL(dm_dirty_log_init);
-EXPORT_SYMBOL(dm_dirty_log_exit);
 EXPORT_SYMBOL(dm_create_dirty_log);
 EXPORT_SYMBOL(dm_destroy_dirty_log);
diff -ur linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm-snap.c linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm-snap.c
--- linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm-snap.c	2004-04-27 15:04:15.000000000 -0700
+++ linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm-snap.c	2004-04-27 15:11:23.000000000 -0700
@@ -608,9 +608,9 @@
 	return NULL;
 }
 
+#if 0
 static void check_free_space(struct dm_snapshot *s)
 {
-#if 0
 	sector_t numerator, denominator;
 	double n, d;
 	unsigned pc;
@@ -628,8 +628,8 @@
 		dm_table_event(s->table);
 		s->last_percent = pc - pc % WAKE_UP_PERCENT;
 	}
-#endif
 }
+#endif
 
 static void pending_complete(struct pending_exception *pe, int success)
 {
@@ -667,8 +667,10 @@
 		flush_bios(bio_list_get(&pe->snapshot_bios));
 		DMDEBUG("Exception completed successfully.");
 
+#if 0
 		/* Notify any interested parties */
 		//check_free_space(s);
+#endif
 
 	} else {
 		/* Read/write error - snapshot is unusable */
@@ -889,7 +891,7 @@
 	return r;
 }
 
-void snapshot_resume(struct dm_target *ti)
+static void snapshot_resume(struct dm_target *ti)
 {
 	struct dm_snapshot *s = (struct dm_snapshot *) ti->private;
 
@@ -1040,7 +1042,7 @@
 /*
  * Called on a write from the origin driver.
  */
-int do_origin(struct dm_dev *origin, struct bio *bio)
+static int do_origin(struct dm_dev *origin, struct bio *bio)
 {
 	struct origin *o;
 	int r;
diff -ur linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm-table.c linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm-table.c
--- linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm-table.c	2004-04-27 15:03:56.000000000 -0700
+++ linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm-table.c	2004-04-23 15:15:40.000000000 -0700
@@ -181,8 +181,8 @@
 	/*
 	 * Allocate both the target array and offset array at once.
 	 */
-	n_highs = (sector_t *) dm_vcalloc(sizeof(struct dm_target) +
-					  sizeof(sector_t), num);
+	n_highs = (sector_t *) dm_vcalloc(num, sizeof(struct dm_target) +
+					  sizeof(sector_t));
 	if (!n_highs)
 		return -ENOMEM;
 
diff -ur linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm-target.c linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm-target.c
--- linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/dm-target.c	2004-04-03 19:38:22.000000000 -0800
+++ linux-2.6.6-rc2-mm1-UDM1/drivers/md/dm-target.c	2004-04-28 13:22:05.000000000 -0700
@@ -7,6 +7,7 @@
 #include "dm.h"
 
 #include <linux/module.h>
+#include <linux/init.h>
 #include <linux/kmod.h>
 #include <linux/bio.h>
 #include <linux/slab.h>
@@ -181,7 +182,7 @@
 	.map  = io_err_map,
 };
 
-int dm_target_init(void)
+int __init dm_target_init(void)
 {
 	return dm_register_target(&error_target);
 }
diff -ur linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/kcopyd.c linux-2.6.6-rc2-mm1-UDM1/drivers/md/kcopyd.c
--- linux-2.6.6-rc2-mm1-UDM1_original/drivers/md/kcopyd.c	2004-04-27 18:40:26.000000000 -0700
+++ linux-2.6.6-rc2-mm1-UDM1/drivers/md/kcopyd.c	2004-04-28 13:23:59.000000000 -0700
@@ -218,7 +218,7 @@
 static LIST_HEAD(_io_jobs);
 static LIST_HEAD(_pages_jobs);
 
-static int jobs_init(void)
+static int __init jobs_init(void)
 {
 	INIT_LIST_HEAD(&_complete_jobs);
 	INIT_LIST_HEAD(&_io_jobs);



More information about the dm-devel mailing list