lkml.org 
[lkml]   [2006]   [Apr]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 07/08] dm: proper module reference counting

Module reference counting appropriately occurs when the block device is
opened, but dm devices exist outside of the device actually being opened.

Currently, in certain situations, unloading the dm-mod module will result
in an oops. This patch claims a reference to the module when a device
is created, and drops it when the device is freed.

This is one possible implementation. Another could be to do an internal
"dmsetup remove_all" when the module is unloaded. Comments welcome.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
--
drivers/md/dm.c | 6 ++++++
1 files changed, 6 insertions(+)

diff -ruNpX ../dontdiff linux-2.6.16-staging1/drivers/md/dm.c linux-2.6.16-staging2/drivers/md/dm.c
--- linux-2.6.16-staging1/drivers/md/dm.c 2006-04-13 16:18:23.000000000 -0400
+++ linux-2.6.16-staging2/drivers/md/dm.c 2006-04-13 16:18:23.000000000 -0400
@@ -796,6 +796,9 @@ static struct mapped_device *alloc_dev(u
return NULL;
}

+ if (!try_module_get(THIS_MODULE))
+ goto bad0;
+
/* get a minor number for the dev */
r = persistent ? specific_minor(md, minor) : next_free_minor(md, &minor);
if (r < 0)
@@ -862,6 +865,8 @@ static struct mapped_device *alloc_dev(u
blk_put_queue(md->queue);
free_minor(minor);
bad1:
+ module_put(THIS_MODULE);
+ bad0:
kfree(md);
return NULL;
}
@@ -885,6 +890,7 @@ static void free_dev(struct mapped_devic

put_disk(md->disk);
blk_put_queue(md->queue);
+ module_put(THIS_MODULE);
kfree(md);
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2006-04-13 22:41    [W:0.037 / U:0.944 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site