Skip to content

Commit f264b33

Browse files
chrboekawasaki
authored andcommitted
drbd: switch from genl_magic macros to YNL-generated code
Replace the genl_magic multi-include macro system with proper YNL generation. The bulk of the changes are mechanical renames to fit the generator naming conventions: - Handler functions: drbd_adm_* -> drbd_nl_*_doit/dumpit - GENL_MAGIC_VERSION -> DRBD_FAMILY_VERSION - GENL_MAGIC_FAMILY_HDRSZ -> sizeof(struct drbd_genlmsghdr) - drbd_genl_family -> drbd_nl_family - Attribute IDs: T_* -> DRBD_A_* Remove the nested_attr_tb static global buffer and move to a per-call allocation approach: each deserialization manages its own nested attribute table. This will be needed anyway when we eventually move to parallel_ops, and it's actually simpler to generate, so make this move now. Replace the functionality of the "sensitive" flag: this was only used by a single field (shared_secret), open-code redaction logic for that locally. Also replace the "invariant" flag: this only had a couple of users, and those basically never change. Hard code the check directly inline. Define the genl_family struct manually in drbd_nl.c; this is not emitted by the generator for genetlink-legacy families. Also replace a couple of drbd-specific wrappers (nla_put_u64_0pad, drbd_nla_find_nested) and replace by standard kernel functions while we're at it. Finally, completely remove the genl_magic system; DRBD was its only user. Signed-off-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
1 parent 0838240 commit f264b33

13 files changed

Lines changed: 3618 additions & 1422 deletions

File tree

drivers/block/drbd/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ drbd-y := drbd_buildtag.o drbd_bitmap.o drbd_proc.o
33
drbd-y += drbd_worker.o drbd_receiver.o drbd_req.o drbd_actlog.o
44
drbd-y += drbd_main.o drbd_strings.o drbd_nl.o
55
drbd-y += drbd_interval.o drbd_state.o
6+
drbd-y += drbd_nl_gen.o
67
drbd-$(CONFIG_DEBUG_FS) += drbd_debugfs.o
78

89
obj-$(CONFIG_BLK_DEV_DRBD) += drbd.o

drivers/block/drbd/drbd_debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ static int drbd_version_show(struct seq_file *m, void *ignored)
844844
{
845845
seq_printf(m, "# %s\n", drbd_buildtag());
846846
seq_printf(m, "VERSION=%s\n", REL_VERSION);
847-
seq_printf(m, "API_VERSION=%u\n", GENL_MAGIC_VERSION);
847+
seq_printf(m, "API_VERSION=%u\n", DRBD_FAMILY_VERSION);
848848
seq_printf(m, "PRO_VERSION_MIN=%u\n", PRO_VERSION_MIN);
849849
seq_printf(m, "PRO_VERSION_MAX=%u\n", PRO_VERSION_MAX);
850850
return 0;

drivers/block/drbd/drbd_int.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@
3232
#include <net/tcp.h>
3333
#include <linux/lru_cache.h>
3434
#include <linux/prefetch.h>
35-
#include <linux/drbd_genl_api.h>
3635
#include <linux/drbd.h>
3736
#include "drbd_config.h"
37+
#include "drbd_nl_gen.h"
3838
#include "drbd_strings.h"
3939
#include "drbd_state.h"
4040
#include "drbd_protocol.h"
4141
#include "drbd_polymorph_printk.h"
4242

43+
extern struct genl_family drbd_nl_family;
44+
4345
/* shared module parameters, defined in drbd_main.c */
4446
#ifdef CONFIG_DRBD_FAULT_INJECTION
4547
extern int drbd_enable_faults;

drivers/block/drbd/drbd_main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,7 +2324,7 @@ static void drbd_cleanup(void)
23242324
if (retry.wq)
23252325
destroy_workqueue(retry.wq);
23262326

2327-
drbd_genl_unregister();
2327+
genl_unregister_family(&drbd_nl_family);
23282328

23292329
idr_for_each_entry(&drbd_devices, device, i)
23302330
drbd_delete_device(device);
@@ -2846,7 +2846,7 @@ static int __init drbd_init(void)
28462846
mutex_init(&resources_mutex);
28472847
INIT_LIST_HEAD(&drbd_resources);
28482848

2849-
err = drbd_genl_register();
2849+
err = genl_register_family(&drbd_nl_family);
28502850
if (err) {
28512851
pr_err("unable to register generic netlink family\n");
28522852
goto fail;
@@ -2876,7 +2876,7 @@ static int __init drbd_init(void)
28762876

28772877
pr_info("initialized. "
28782878
"Version: " REL_VERSION " (api:%d/proto:%d-%d)\n",
2879-
GENL_MAGIC_VERSION, PRO_VERSION_MIN, PRO_VERSION_MAX);
2879+
DRBD_FAMILY_VERSION, PRO_VERSION_MIN, PRO_VERSION_MAX);
28802880
pr_info("%s\n", drbd_buildtag());
28812881
pr_info("registered as block device major %d\n", DRBD_MAJOR);
28822882
return 0; /* Success! */

0 commit comments

Comments
 (0)