Commit 3b98c0c2 authored by Lars Ellenberg's avatar Lars Ellenberg Committed by Philipp Reisner

drbd: switch configuration interface from connector to genetlink

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent ec2c35ac
...@@ -702,6 +702,7 @@ static int w_update_odbm(struct drbd_work *w, int unused) ...@@ -702,6 +702,7 @@ static int w_update_odbm(struct drbd_work *w, int unused)
{ {
struct update_odbm_work *udw = container_of(w, struct update_odbm_work, w); struct update_odbm_work *udw = container_of(w, struct update_odbm_work, w);
struct drbd_conf *mdev = w->mdev; struct drbd_conf *mdev = w->mdev;
struct sib_info sib = { .sib_reason = SIB_SYNC_PROGRESS, };
if (!get_ldev(mdev)) { if (!get_ldev(mdev)) {
if (__ratelimit(&drbd_ratelimit_state)) if (__ratelimit(&drbd_ratelimit_state))
...@@ -725,7 +726,7 @@ static int w_update_odbm(struct drbd_work *w, int unused) ...@@ -725,7 +726,7 @@ static int w_update_odbm(struct drbd_work *w, int unused)
break; break;
} }
} }
drbd_bcast_sync_progress(mdev); drbd_bcast_event(mdev, &sib);
return 1; return 1;
} }
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <net/tcp.h> #include <net/tcp.h>
#include <linux/lru_cache.h> #include <linux/lru_cache.h>
#include <linux/prefetch.h> #include <linux/prefetch.h>
#include <linux/drbd_genl_api.h>
#include <linux/drbd.h> #include <linux/drbd.h>
#include "drbd_state.h" #include "drbd_state.h"
...@@ -65,7 +66,6 @@ ...@@ -65,7 +66,6 @@
extern unsigned int minor_count; extern unsigned int minor_count;
extern int disable_sendpage; extern int disable_sendpage;
extern int allow_oos; extern int allow_oos;
extern unsigned int cn_idx;
#ifdef CONFIG_DRBD_FAULT_INJECTION #ifdef CONFIG_DRBD_FAULT_INJECTION
extern int enable_faults; extern int enable_faults;
...@@ -865,14 +865,6 @@ struct drbd_md { ...@@ -865,14 +865,6 @@ struct drbd_md {
*/ */
}; };
/* for sync_conf and other types... */
#define NL_PACKET(name, number, fields) struct name { fields };
#define NL_INTEGER(pn,pr,member) int member;
#define NL_INT64(pn,pr,member) __u64 member;
#define NL_BIT(pn,pr,member) unsigned member:1;
#define NL_STRING(pn,pr,member,len) unsigned char member[len]; int member ## _len;
#include "linux/drbd_nl.h"
struct drbd_backing_dev { struct drbd_backing_dev {
struct block_device *backing_bdev; struct block_device *backing_bdev;
struct block_device *md_bdev; struct block_device *md_bdev;
...@@ -1502,7 +1494,7 @@ enum drbd_ret_code conn_new_minor(struct drbd_tconn *tconn, unsigned int minor, ...@@ -1502,7 +1494,7 @@ enum drbd_ret_code conn_new_minor(struct drbd_tconn *tconn, unsigned int minor,
extern void drbd_free_mdev(struct drbd_conf *mdev); extern void drbd_free_mdev(struct drbd_conf *mdev);
extern void drbd_delete_device(unsigned int minor); extern void drbd_delete_device(unsigned int minor);
struct drbd_tconn *drbd_new_tconn(char *name); struct drbd_tconn *drbd_new_tconn(const char *name);
extern void drbd_free_tconn(struct drbd_tconn *tconn); extern void drbd_free_tconn(struct drbd_tconn *tconn);
struct drbd_tconn *conn_by_name(const char *name); struct drbd_tconn *conn_by_name(const char *name);
...@@ -1679,16 +1671,22 @@ extern int __drbd_set_out_of_sync(struct drbd_conf *mdev, sector_t sector, ...@@ -1679,16 +1671,22 @@ extern int __drbd_set_out_of_sync(struct drbd_conf *mdev, sector_t sector,
extern void drbd_al_apply_to_bm(struct drbd_conf *mdev); extern void drbd_al_apply_to_bm(struct drbd_conf *mdev);
extern void drbd_al_shrink(struct drbd_conf *mdev); extern void drbd_al_shrink(struct drbd_conf *mdev);
/* drbd_nl.c */ /* drbd_nl.c */
/* state info broadcast */
void drbd_nl_cleanup(void); struct sib_info {
int __init drbd_nl_init(void); enum drbd_state_info_bcast_reason sib_reason;
void drbd_bcast_state(struct drbd_conf *mdev, union drbd_state); union {
void drbd_bcast_sync_progress(struct drbd_conf *mdev); struct {
void drbd_bcast_ee(struct drbd_conf *, const char *, const int, const char *, char *helper_name;
const char *, const struct drbd_peer_request *); unsigned helper_exit_code;
};
struct {
union drbd_state os;
union drbd_state ns;
};
};
};
void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib);
/* /*
* inline helper functions * inline helper functions
......
...@@ -86,7 +86,6 @@ MODULE_PARM_DESC(allow_oos, "DONT USE!"); ...@@ -86,7 +86,6 @@ MODULE_PARM_DESC(allow_oos, "DONT USE!");
module_param(minor_count, uint, 0444); module_param(minor_count, uint, 0444);
module_param(disable_sendpage, bool, 0644); module_param(disable_sendpage, bool, 0644);
module_param(allow_oos, bool, 0); module_param(allow_oos, bool, 0);
module_param(cn_idx, uint, 0444);
module_param(proc_details, int, 0644); module_param(proc_details, int, 0644);
#ifdef CONFIG_DRBD_FAULT_INJECTION #ifdef CONFIG_DRBD_FAULT_INJECTION
...@@ -108,7 +107,6 @@ module_param(fault_devs, int, 0644); ...@@ -108,7 +107,6 @@ module_param(fault_devs, int, 0644);
unsigned int minor_count = DRBD_MINOR_COUNT_DEF; unsigned int minor_count = DRBD_MINOR_COUNT_DEF;
int disable_sendpage; int disable_sendpage;
int allow_oos; int allow_oos;
unsigned int cn_idx = CN_IDX_DRBD;
int proc_details; /* Detail level in proc drbd*/ int proc_details; /* Detail level in proc drbd*/
/* Module parameter for setting the user mode helper program /* Module parameter for setting the user mode helper program
...@@ -2175,7 +2173,7 @@ static void drbd_cleanup(void) ...@@ -2175,7 +2173,7 @@ static void drbd_cleanup(void)
if (drbd_proc) if (drbd_proc)
remove_proc_entry("drbd", NULL); remove_proc_entry("drbd", NULL);
drbd_nl_cleanup(); drbd_genl_unregister();
idr_for_each_entry(&minors, mdev, i) idr_for_each_entry(&minors, mdev, i)
drbd_delete_device(i); drbd_delete_device(i);
...@@ -2237,6 +2235,9 @@ struct drbd_tconn *conn_by_name(const char *name) ...@@ -2237,6 +2235,9 @@ struct drbd_tconn *conn_by_name(const char *name)
{ {
struct drbd_tconn *tconn; struct drbd_tconn *tconn;
if (!name || !name[0])
return NULL;
write_lock_irq(&global_state_lock); write_lock_irq(&global_state_lock);
list_for_each_entry(tconn, &drbd_tconns, all_tconn) { list_for_each_entry(tconn, &drbd_tconns, all_tconn) {
if (!strcmp(tconn->name, name)) if (!strcmp(tconn->name, name))
...@@ -2248,7 +2249,7 @@ struct drbd_tconn *conn_by_name(const char *name) ...@@ -2248,7 +2249,7 @@ struct drbd_tconn *conn_by_name(const char *name)
return tconn; return tconn;
} }
struct drbd_tconn *drbd_new_tconn(char *name) struct drbd_tconn *drbd_new_tconn(const char *name)
{ {
struct drbd_tconn *tconn; struct drbd_tconn *tconn;
...@@ -2333,6 +2334,7 @@ enum drbd_ret_code conn_new_minor(struct drbd_tconn *tconn, unsigned int minor, ...@@ -2333,6 +2334,7 @@ enum drbd_ret_code conn_new_minor(struct drbd_tconn *tconn, unsigned int minor,
mdev->tconn = tconn; mdev->tconn = tconn;
mdev->minor = minor; mdev->minor = minor;
mdev->vnr = vnr;
drbd_init_set_defaults(mdev); drbd_init_set_defaults(mdev);
...@@ -2461,10 +2463,6 @@ int __init drbd_init(void) ...@@ -2461,10 +2463,6 @@ int __init drbd_init(void)
#endif #endif
} }
err = drbd_nl_init();
if (err)
return err;
err = register_blkdev(DRBD_MAJOR, "drbd"); err = register_blkdev(DRBD_MAJOR, "drbd");
if (err) { if (err) {
printk(KERN_ERR printk(KERN_ERR
...@@ -2473,6 +2471,13 @@ int __init drbd_init(void) ...@@ -2473,6 +2471,13 @@ int __init drbd_init(void)
return err; return err;
} }
err = drbd_genl_register();
if (err) {
printk(KERN_ERR "drbd: unable to register generic netlink family\n");
goto fail;
}
register_reboot_notifier(&drbd_notifier); register_reboot_notifier(&drbd_notifier);
/* /*
...@@ -2487,12 +2492,12 @@ int __init drbd_init(void) ...@@ -2487,12 +2492,12 @@ int __init drbd_init(void)
err = drbd_create_mempools(); err = drbd_create_mempools();
if (err) if (err)
goto Enomem; goto fail;
drbd_proc = proc_create_data("drbd", S_IFREG | S_IRUGO , NULL, &drbd_proc_fops, NULL); drbd_proc = proc_create_data("drbd", S_IFREG | S_IRUGO , NULL, &drbd_proc_fops, NULL);
if (!drbd_proc) { if (!drbd_proc) {
printk(KERN_ERR "drbd: unable to register proc file\n"); printk(KERN_ERR "drbd: unable to register proc file\n");
goto Enomem; goto fail;
} }
rwlock_init(&global_state_lock); rwlock_init(&global_state_lock);
...@@ -2507,7 +2512,7 @@ int __init drbd_init(void) ...@@ -2507,7 +2512,7 @@ int __init drbd_init(void)
return 0; /* Success! */ return 0; /* Success! */
Enomem: fail:
drbd_cleanup(); drbd_cleanup();
if (err == -ENOMEM) if (err == -ENOMEM)
/* currently always the case */ /* currently always the case */
......
This diff is collapsed.
...@@ -970,6 +970,11 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os, ...@@ -970,6 +970,11 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
enum drbd_fencing_p fp; enum drbd_fencing_p fp;
enum drbd_req_event what = NOTHING; enum drbd_req_event what = NOTHING;
union drbd_state nsm = (union drbd_state){ .i = -1 }; union drbd_state nsm = (union drbd_state){ .i = -1 };
struct sib_info sib;
sib.sib_reason = SIB_STATE_CHANGE;
sib.os = os;
sib.ns = ns;
if (os.conn != C_CONNECTED && ns.conn == C_CONNECTED) { if (os.conn != C_CONNECTED && ns.conn == C_CONNECTED) {
clear_bit(CRASHED_PRIMARY, &mdev->flags); clear_bit(CRASHED_PRIMARY, &mdev->flags);
...@@ -984,7 +989,7 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os, ...@@ -984,7 +989,7 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
} }
/* Inform userspace about the change... */ /* Inform userspace about the change... */
drbd_bcast_state(mdev, ns); drbd_bcast_event(mdev, &sib);
if (!(os.role == R_PRIMARY && os.disk < D_UP_TO_DATE && os.pdsk < D_UP_TO_DATE) && if (!(os.role == R_PRIMARY && os.disk < D_UP_TO_DATE && os.pdsk < D_UP_TO_DATE) &&
(ns.role == R_PRIMARY && ns.disk < D_UP_TO_DATE && ns.pdsk < D_UP_TO_DATE)) (ns.role == R_PRIMARY && ns.disk < D_UP_TO_DATE && ns.pdsk < D_UP_TO_DATE))
......
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
#endif #endif
extern const char *drbd_buildtag(void); extern const char *drbd_buildtag(void);
#define REL_VERSION "8.3.11" #define REL_VERSION "8.3.11"
#define API_VERSION 88 #define API_VERSION 88
...@@ -159,6 +158,7 @@ enum drbd_ret_code { ...@@ -159,6 +158,7 @@ enum drbd_ret_code {
ERR_CONN_IN_USE = 159, ERR_CONN_IN_USE = 159,
ERR_MINOR_CONFIGURED = 160, ERR_MINOR_CONFIGURED = 160,
ERR_MINOR_EXISTS = 161, ERR_MINOR_EXISTS = 161,
ERR_INVALID_REQUEST = 162,
/* insert new ones above this line */ /* insert new ones above this line */
AFTER_LAST_ERR_CODE AFTER_LAST_ERR_CODE
...@@ -349,37 +349,4 @@ enum drbd_timeout_flag { ...@@ -349,37 +349,4 @@ enum drbd_timeout_flag {
#define DRBD_MD_INDEX_FLEX_EXT -2 #define DRBD_MD_INDEX_FLEX_EXT -2
#define DRBD_MD_INDEX_FLEX_INT -3 #define DRBD_MD_INDEX_FLEX_INT -3
/* Start of the new netlink/connector stuff */
enum drbd_ncr_flags {
DRBD_NL_CREATE_DEVICE = 0x01,
DRBD_NL_SET_DEFAULTS = 0x02,
};
#define DRBD_NL_OBJ_NAME_LEN 32
/* For searching a vacant cn_idx value */
#define CN_IDX_STEP 6977
struct drbd_nl_cfg_req {
int packet_type;
union {
struct {
unsigned int drbd_minor;
enum drbd_ncr_flags flags;
};
struct {
char obj_name[DRBD_NL_OBJ_NAME_LEN];
};
};
unsigned short tag_list[];
};
struct drbd_nl_cfg_reply {
int packet_type;
unsigned int minor;
int ret_code; /* enum ret_code or set_st_err_t */
unsigned short tag_list[]; /* only used with get_* calls */
};
#endif #endif
...@@ -95,7 +95,7 @@ static struct nla_policy s_name ## _nl_policy[] __read_mostly = \ ...@@ -95,7 +95,7 @@ static struct nla_policy s_name ## _nl_policy[] __read_mostly = \
#endif #endif
#endif #endif
#if 1 #ifdef GENL_MAGIC_DEBUG
static void dprint_field(const char *dir, int nla_type, static void dprint_field(const char *dir, int nla_type,
const char *name, void *valp) const char *name, void *valp)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment