···11+/*22+ * Device Mapper Uevent Support (dm-uevent)33+ *44+ * This program is free software; you can redistribute it and/or modify it55+ * under the terms of the GNU General Public License as published by the66+ * Free Software Foundation; either version 2 of the License, or (at your77+ * option) any later version.88+ *99+ * This program is distributed in the hope that it will be useful, but1010+ * WITHOUT ANY WARRANTY; without even the implied warranty of1111+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU1212+ * General Public License for more details.1313+ *1414+ * You should have received a copy of the GNU General Public License along1515+ * with this program; if not, write to the Free Software Foundation, Inc.,1616+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.1717+ *1818+ * Copyright IBM Corporation, 20071919+ * Author: Mike Anderson <andmike@linux.vnet.ibm.com>2020+ */2121+#include <linux/list.h>2222+#include <linux/slab.h>2323+#include <linux/kobject.h>2424+2525+#include "dm.h"2626+#include "dm-uevent.h"2727+2828+#define DM_MSG_PREFIX "uevent"2929+3030+static struct kmem_cache *_dm_event_cache;3131+3232+struct dm_uevent {3333+ struct mapped_device *md;3434+ enum kobject_action action;3535+ struct kobj_uevent_env ku_env;3636+ struct list_head elist;3737+};3838+3939+static void dm_uevent_free(struct dm_uevent *event)4040+{4141+ kmem_cache_free(_dm_event_cache, event);4242+}4343+4444+static struct dm_uevent *dm_uevent_alloc(struct mapped_device *md)4545+{4646+ struct dm_uevent *event;4747+4848+ event = kmem_cache_zalloc(_dm_event_cache, GFP_ATOMIC);4949+ if (!event)5050+ return NULL;5151+5252+ INIT_LIST_HEAD(&event->elist);5353+ event->md = md;5454+5555+ return event;5656+}5757+5858+int dm_uevent_init(void)5959+{6060+ _dm_event_cache = KMEM_CACHE(dm_uevent, 0);6161+ if (!_dm_event_cache)6262+ return -ENOMEM;6363+6464+ DMINFO("version 1.0.3");6565+6666+ return 0;6767+}6868+6969+void dm_uevent_exit(void)7070+{7171+ kmem_cache_destroy(_dm_event_cache);7272+}
+41
drivers/md/dm-uevent.h
···11+/*22+ * Device Mapper Uevent Support33+ *44+ * This program is free software; you can redistribute it and/or modify it55+ * under the terms of the GNU General Public License as published by the66+ * Free Software Foundation; either version 2 of the License, or (at your77+ * option) any later version.88+ *99+ * This program is distributed in the hope that it will be useful, but1010+ * WITHOUT ANY WARRANTY; without even the implied warranty of1111+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU1212+ * General Public License for more details.1313+ *1414+ * You should have received a copy of the GNU General Public License along1515+ * with this program; if not, write to the Free Software Foundation, Inc.,1616+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.1717+ *1818+ * Copyright IBM Corporation, 20071919+ * Author: Mike Anderson <andmike@linux.vnet.ibm.com>2020+ */2121+#ifndef DM_UEVENT_H2222+#define DM_UEVENT_H2323+2424+#ifdef CONFIG_DM_UEVENT2525+2626+extern int dm_uevent_init(void);2727+extern void dm_uevent_exit(void);2828+2929+#else3030+3131+static inline int dm_uevent_init(void)3232+{3333+ return 0;3434+}3535+static inline void dm_uevent_exit(void)3636+{3737+}3838+3939+#endif /* CONFIG_DM_UEVENT */4040+4141+#endif /* DM_UEVENT_H */