[patch 1/3] dm-netlink: Add dm-netlink skeleton

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds a dm-netlink skeleton support to the Makefile, and the dm
directory.

Signed-off-by: Mike Anderson <andmike@xxxxxxxxxx>
---

 drivers/md/Kconfig      |    5 ++
 drivers/md/Makefile     |    4 +
 drivers/md/dm-netlink.c |   97 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/md/dm-netlink.h |   42 ++++++++++++++++++++
 drivers/md/dm.c         |    2 
 drivers/md/dm.h         |    1 
 include/linux/netlink.h |    2 
 7 files changed, 152 insertions(+), 1 deletion(-)

Index: linux-2.6-patched/drivers/md/dm-netlink.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-patched/drivers/md/dm-netlink.c	2007-01-16 10:56:00.000000000 -0800
@@ -0,0 +1,97 @@
+/*
+ * Device Mapper Netlink Support (dm-netlink)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright IBM Corporation, 2005, 2006
+ * 	Author: Mike Anderson <andmike@xxxxxxxxxx>
+ */
+#include <linux/module.h>
+#include <linux/mempool.h>
+#include <linux/time.h>
+#include <linux/jiffies.h>
+#include <linux/security.h>
+#include <net/sock.h>
+#include <net/netlink.h>
+#include "dm.h"
+
+#define EVENT_SKB_SIZE	NLMSG_GOODSIZE
+
+struct dm_event_cache {
+	struct kmem_cache *cache;
+	unsigned skb_size;
+};
+
+static struct dm_event_cache dme_cache;
+
+static int dme_cache_init(struct dm_event_cache *dc, unsigned skb_size)
+{
+	dc->skb_size = skb_size;
+
+	dc->cache = kmem_cache_create("dm_events",
+			   sizeof(struct dm_event), 0, 0, NULL, NULL);
+
+	if (!dc->cache)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static void dme_cache_destroy(struct dm_event_cache *dc)
+{
+	kmem_cache_destroy(dc->cache);
+}
+
+static void dme_cache_event_put(struct dm_event *evt)
+{
+	struct dm_event_cache *dc = evt->cdata;
+	kmem_cache_free(dc->cache, evt);
+}
+
+static struct dm_event* dme_cache_event_get(struct dm_event_cache *dc)
+{
+	struct dm_event *evt;
+
+	evt = kmem_cache_alloc(dc->cache, GFP_ATOMIC);
+	if (evt) {
+		INIT_LIST_HEAD(&evt->elist);
+		evt->cdata = dc;
+		evt->skb = alloc_skb(dc->skb_size, GFP_ATOMIC);
+		if (!evt->skb)
+			goto cache_out;
+	}
+
+	return evt;
+
+cache_out:
+	dme_cache_event_put(evt);
+	return NULL;
+}
+
+int __init dm_netlink_init(void)
+{
+	int err;
+
+	err = dme_cache_init(&dme_cache, EVENT_SKB_SIZE);
+	if (!err)
+		printk(KERN_DEBUG "dm-netlink version 0.0.6 loaded\n");
+
+	return err;
+}
+
+void dm_netlink_exit(void)
+{
+	dme_cache_destroy(&dme_cache);
+}
Index: linux-2.6-patched/include/linux/netlink.h
===================================================================
--- linux-2.6-patched.orig/include/linux/netlink.h	2007-01-16 10:42:04.000000000 -0800
+++ linux-2.6-patched/include/linux/netlink.h	2007-01-16 10:46:42.000000000 -0800
@@ -21,7 +21,7 @@
 #define NETLINK_DNRTMSG		14	/* DECnet routing messages */
 #define NETLINK_KOBJECT_UEVENT	15	/* Kernel messages to userspace */
 #define NETLINK_GENERIC		16
-/* leave room for NETLINK_DM (DM Events) */
+#define NETLINK_DM		17	/* Device Mapper */
 #define NETLINK_SCSITRANSPORT	18	/* SCSI Transports */
 
 #define MAX_LINKS 32		
Index: linux-2.6-patched/drivers/md/Makefile
===================================================================
--- linux-2.6-patched.orig/drivers/md/Makefile	2007-01-16 10:42:04.000000000 -0800
+++ linux-2.6-patched/drivers/md/Makefile	2007-01-16 10:46:42.000000000 -0800
@@ -45,6 +45,10 @@ ifeq ($(CONFIG_ALTIVEC),y)
 altivec_flags := -maltivec -mabi=altivec
 endif
 
+ifeq ($(CONFIG_DM_NETLINK_EVENT),y)
+dm-mod-objs			+= dm-netlink.o
+endif
+
 targets += raid6int1.c
 $(obj)/raid6int1.c:   UNROLL := 1
 $(obj)/raid6int1.c:   $(src)/raid6int.uc $(src)/unroll.pl FORCE
Index: linux-2.6-patched/drivers/md/Kconfig
===================================================================
--- linux-2.6-patched.orig/drivers/md/Kconfig	2007-01-16 10:42:04.000000000 -0800
+++ linux-2.6-patched/drivers/md/Kconfig	2007-01-16 10:46:42.000000000 -0800
@@ -262,6 +262,11 @@ config DM_MULTIPATH_EMC
 	---help---
 	  Multipath support for EMC CX/AX series hardware.
 
+config DM_NETLINK_EVENT
+	bool "DM netlink events (EXPERIMENTAL)"
+	depends on BLK_DEV_DM && EXPERIMENTAL
+	---help---
+	Generate netlink events for DM events.
 endmenu
 
 endif
Index: linux-2.6-patched/drivers/md/dm-netlink.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-patched/drivers/md/dm-netlink.h	2007-01-16 10:46:42.000000000 -0800
@@ -0,0 +1,42 @@
+/*
+ * Device Mapper Netlink Support
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright IBM Corporation, 2005, 2006
+ * 	Author: Mike Anderson <andmike@xxxxxxxxxx>
+ */
+#ifndef DM_NETLINK_H
+#define DM_NETLINK_H
+
+struct dm_event {
+	void *cdata;
+	struct sk_buff *skb;
+	struct list_head elist;
+};
+
+#ifdef CONFIG_DM_NETLINK_EVENT
+int dm_netlink_init(void);
+void dm_netlink_exit(void);
+#else
+static inline int __init dm_netlink_init(void)
+{
+	return 0;
+}
+static inline void dm_netlink_exit(void)
+{ }
+#endif
+
+#endif /* DM_NETLINK_H */
Index: linux-2.6-patched/drivers/md/dm.c
===================================================================
--- linux-2.6-patched.orig/drivers/md/dm.c	2007-01-16 10:42:04.000000000 -0800
+++ linux-2.6-patched/drivers/md/dm.c	2007-01-16 10:46:42.000000000 -0800
@@ -178,6 +178,7 @@ int (*_inits[])(void) __initdata = {
 	dm_linear_init,
 	dm_stripe_init,
 	dm_interface_init,
+	dm_netlink_init,
 };
 
 void (*_exits[])(void) = {
@@ -186,6 +187,7 @@ void (*_exits[])(void) = {
 	dm_linear_exit,
 	dm_stripe_exit,
 	dm_interface_exit,
+	dm_netlink_exit,
 };
 
 static int __init dm_init(void)
Index: linux-2.6-patched/drivers/md/dm.h
===================================================================
--- linux-2.6-patched.orig/drivers/md/dm.h	2007-01-16 10:42:04.000000000 -0800
+++ linux-2.6-patched/drivers/md/dm.h	2007-01-16 10:46:42.000000000 -0800
@@ -15,6 +15,7 @@
 #include <linux/list.h>
 #include <linux/blkdev.h>
 #include <linux/hdreg.h>
+#include "dm-netlink.h"
 
 #define DM_NAME "device-mapper"
 

-- 

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel

[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux