aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/Kconfig6
-rw-r--r--drivers/md/Makefile4
-rw-r--r--drivers/md/dm-uevent.c72
-rw-r--r--drivers/md/dm-uevent.h41
-rw-r--r--drivers/md/dm.c10
5 files changed, 133 insertions, 0 deletions
diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig
index a99af897820..9b6fbf044fd 100644
--- a/drivers/md/Kconfig
+++ b/drivers/md/Kconfig
@@ -282,4 +282,10 @@ config DM_DELAY
282 282
283 If unsure, say N. 283 If unsure, say N.
284 284
285config DM_UEVENT
286 bool "DM uevents (EXPERIMENTAL)"
287 depends on BLK_DEV_DM && EXPERIMENTAL
288 ---help---
289 Generate udev events for DM events.
290
285endif # MD 291endif # MD
diff --git a/drivers/md/Makefile b/drivers/md/Makefile
index fded842edeb..d9aa7edb878 100644
--- a/drivers/md/Makefile
+++ b/drivers/md/Makefile
@@ -50,6 +50,10 @@ ifeq ($(CONFIG_ALTIVEC),y)
50altivec_flags := -maltivec -mabi=altivec 50altivec_flags := -maltivec -mabi=altivec
51endif 51endif
52 52
53ifeq ($(CONFIG_DM_UEVENT),y)
54dm-mod-objs += dm-uevent.o
55endif
56
53targets += raid6int1.c 57targets += raid6int1.c
54$(obj)/raid6int1.c: UNROLL := 1 58$(obj)/raid6int1.c: UNROLL := 1
55$(obj)/raid6int1.c: $(src)/raid6int.uc $(src)/unroll.pl FORCE 59$(obj)/raid6int1.c: $(src)/raid6int.uc $(src)/unroll.pl FORCE
diff --git a/drivers/md/dm-uevent.c b/drivers/md/dm-uevent.c
new file mode 100644
index 00000000000..53200c96bcb
--- /dev/null
+++ b/drivers/md/dm-uevent.c
@@ -0,0 +1,72 @@
1/*
2 * Device Mapper Uevent Support (dm-uevent)
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Copyright IBM Corporation, 2007
19 * Author: Mike Anderson <andmike@linux.vnet.ibm.com>
20 */
21#include <linux/list.h>
22#include <linux/slab.h>
23#include <linux/kobject.h>
24
25#include "dm.h"
26#include "dm-uevent.h"
27
28#define DM_MSG_PREFIX "uevent"
29
30static struct kmem_cache *_dm_event_cache;
31
32struct dm_uevent {
33 struct mapped_device *md;
34 enum kobject_action action;
35 struct kobj_uevent_env ku_env;
36 struct list_head elist;
37};
38
39static void dm_uevent_free(struct dm_uevent *event)
40{
41 kmem_cache_free(_dm_event_cache, event);
42}
43
44static struct dm_uevent *dm_uevent_alloc(struct mapped_device *md)
45{
46 struct dm_uevent *event;
47
48 event = kmem_cache_zalloc(_dm_event_cache, GFP_ATOMIC);
49 if (!event)
50 return NULL;
51
52 INIT_LIST_HEAD(&event->elist);
53 event->md = md;
54
55 return event;
56}
57
58int dm_uevent_init(void)
59{
60 _dm_event_cache = KMEM_CACHE(dm_uevent, 0);
61 if (!_dm_event_cache)
62 return -ENOMEM;
63
64 DMINFO("version 1.0.3");
65
66 return 0;
67}
68
69void dm_uevent_exit(void)
70{
71 kmem_cache_destroy(_dm_event_cache);
72}
diff --git a/drivers/md/dm-uevent.h b/drivers/md/dm-uevent.h
new file mode 100644
index 00000000000..9d776836489
--- /dev/null
+++ b/drivers/md/dm-uevent.h
@@ -0,0 +1,41 @@
1/*
2 * Device Mapper Uevent Support
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Copyright IBM Corporation, 2007
19 * Author: Mike Anderson <andmike@linux.vnet.ibm.com>
20 */
21#ifndef DM_UEVENT_H
22#define DM_UEVENT_H
23
24#ifdef CONFIG_DM_UEVENT
25
26extern int dm_uevent_init(void);
27extern void dm_uevent_exit(void);
28
29#else
30
31static inline int dm_uevent_init(void)
32{
33 return 0;
34}
35static inline void dm_uevent_exit(void)
36{
37}
38
39#endif /* CONFIG_DM_UEVENT */
40
41#endif /* DM_UEVENT_H */
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 41c9549b32a..bb5c1eaca52 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -7,6 +7,7 @@
7 7
8#include "dm.h" 8#include "dm.h"
9#include "dm-bio-list.h" 9#include "dm-bio-list.h"
10#include "dm-uevent.h"
10 11
11#include <linux/init.h> 12#include <linux/init.h>
12#include <linux/module.h> 13#include <linux/module.h>
@@ -143,11 +144,19 @@ static int __init local_init(void)
143 return -ENOMEM; 144 return -ENOMEM;
144 } 145 }
145 146
147 r = dm_uevent_init();
148 if (r) {
149 kmem_cache_destroy(_tio_cache);
150 kmem_cache_destroy(_io_cache);
151 return r;
152 }
153
146 _major = major; 154 _major = major;
147 r = register_blkdev(_major, _name); 155 r = register_blkdev(_major, _name);
148 if (r < 0) { 156 if (r < 0) {
149 kmem_cache_destroy(_tio_cache); 157 kmem_cache_destroy(_tio_cache);
150 kmem_cache_destroy(_io_cache); 158 kmem_cache_destroy(_io_cache);
159 dm_uevent_exit();
151 return r; 160 return r;
152 } 161 }
153 162
@@ -162,6 +171,7 @@ static void local_exit(void)
162 kmem_cache_destroy(_tio_cache); 171 kmem_cache_destroy(_tio_cache);
163 kmem_cache_destroy(_io_cache); 172 kmem_cache_destroy(_io_cache);
164 unregister_blkdev(_major, _name); 173 unregister_blkdev(_major, _name);
174 dm_uevent_exit();
165 175
166 _major = 0; 176 _major = 0;
167 177