drbd: switch configuration interface from connector to genetlink

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
This commit is contained in:
Lars Ellenberg 2011-03-07 12:49:34 +01:00 committed by Philipp Reisner
parent ec2c35ac1e
commit 3b98c0c209
7 changed files with 808 additions and 842 deletions

View File

@ -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 drbd_conf *mdev = w->mdev;
struct sib_info sib = { .sib_reason = SIB_SYNC_PROGRESS, };
if (!get_ldev(mdev)) {
if (__ratelimit(&drbd_ratelimit_state))
@ -725,7 +726,7 @@ static int w_update_odbm(struct drbd_work *w, int unused)
break;
}
}
drbd_bcast_sync_progress(mdev);
drbd_bcast_event(mdev, &sib);
return 1;
}

View File

@ -44,6 +44,7 @@
#include <net/tcp.h>
#include <linux/lru_cache.h>
#include <linux/prefetch.h>
#include <linux/drbd_genl_api.h>
#include <linux/drbd.h>
#include "drbd_state.h"
@ -65,7 +66,6 @@
extern unsigned int minor_count;
extern int disable_sendpage;
extern int allow_oos;
extern unsigned int cn_idx;
#ifdef CONFIG_DRBD_FAULT_INJECTION
extern int enable_faults;
@ -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 block_device *backing_bdev;
struct block_device *md_bdev;
@ -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_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);
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,
extern void drbd_al_apply_to_bm(struct drbd_conf *mdev);
extern void drbd_al_shrink(struct drbd_conf *mdev);
/* drbd_nl.c */
void drbd_nl_cleanup(void);
int __init drbd_nl_init(void);
void drbd_bcast_state(struct drbd_conf *mdev, union drbd_state);
void drbd_bcast_sync_progress(struct drbd_conf *mdev);
void drbd_bcast_ee(struct drbd_conf *, const char *, const int, const char *,
const char *, const struct drbd_peer_request *);
/* state info broadcast */
struct sib_info {
enum drbd_state_info_bcast_reason sib_reason;
union {
struct {
char *helper_name;
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

View File

@ -86,7 +86,6 @@ MODULE_PARM_DESC(allow_oos, "DONT USE!");
module_param(minor_count, uint, 0444);
module_param(disable_sendpage, bool, 0644);
module_param(allow_oos, bool, 0);
module_param(cn_idx, uint, 0444);
module_param(proc_details, int, 0644);
#ifdef CONFIG_DRBD_FAULT_INJECTION
@ -108,7 +107,6 @@ module_param(fault_devs, int, 0644);
unsigned int minor_count = DRBD_MINOR_COUNT_DEF;
int disable_sendpage;
int allow_oos;
unsigned int cn_idx = CN_IDX_DRBD;
int proc_details; /* Detail level in proc drbd*/
/* Module parameter for setting the user mode helper program
@ -2175,7 +2173,7 @@ static void drbd_cleanup(void)
if (drbd_proc)
remove_proc_entry("drbd", NULL);
drbd_nl_cleanup();
drbd_genl_unregister();
idr_for_each_entry(&minors, mdev, i)
drbd_delete_device(i);
@ -2237,6 +2235,9 @@ struct drbd_tconn *conn_by_name(const char *name)
{
struct drbd_tconn *tconn;
if (!name || !name[0])
return NULL;
write_lock_irq(&global_state_lock);
list_for_each_entry(tconn, &drbd_tconns, all_tconn) {
if (!strcmp(tconn->name, name))
@ -2248,7 +2249,7 @@ struct drbd_tconn *conn_by_name(const char *name)
return tconn;
}
struct drbd_tconn *drbd_new_tconn(char *name)
struct drbd_tconn *drbd_new_tconn(const char *name)
{
struct drbd_tconn *tconn;
@ -2333,6 +2334,7 @@ enum drbd_ret_code conn_new_minor(struct drbd_tconn *tconn, unsigned int minor,
mdev->tconn = tconn;
mdev->minor = minor;
mdev->vnr = vnr;
drbd_init_set_defaults(mdev);
@ -2461,10 +2463,6 @@ int __init drbd_init(void)
#endif
}
err = drbd_nl_init();
if (err)
return err;
err = register_blkdev(DRBD_MAJOR, "drbd");
if (err) {
printk(KERN_ERR
@ -2473,6 +2471,13 @@ int __init drbd_init(void)
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);
/*
@ -2487,12 +2492,12 @@ int __init drbd_init(void)
err = drbd_create_mempools();
if (err)
goto Enomem;
goto fail;
drbd_proc = proc_create_data("drbd", S_IFREG | S_IRUGO , NULL, &drbd_proc_fops, NULL);
if (!drbd_proc) {
printk(KERN_ERR "drbd: unable to register proc file\n");
goto Enomem;
goto fail;
}
rwlock_init(&global_state_lock);
@ -2507,7 +2512,7 @@ int __init drbd_init(void)
return 0; /* Success! */
Enomem:
fail:
drbd_cleanup();
if (err == -ENOMEM)
/* currently always the case */

File diff suppressed because it is too large Load Diff

View File

@ -970,6 +970,11 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
enum drbd_fencing_p fp;
enum drbd_req_event what = NOTHING;
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) {
clear_bit(CRASHED_PRIMARY, &mdev->flags);
@ -984,7 +989,7 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
}
/* 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) &&
(ns.role == R_PRIMARY && ns.disk < D_UP_TO_DATE && ns.pdsk < D_UP_TO_DATE))

View File

@ -51,7 +51,6 @@
#endif
extern const char *drbd_buildtag(void);
#define REL_VERSION "8.3.11"
#define API_VERSION 88
@ -159,6 +158,7 @@ enum drbd_ret_code {
ERR_CONN_IN_USE = 159,
ERR_MINOR_CONFIGURED = 160,
ERR_MINOR_EXISTS = 161,
ERR_INVALID_REQUEST = 162,
/* insert new ones above this line */
AFTER_LAST_ERR_CODE
@ -349,37 +349,4 @@ enum drbd_timeout_flag {
#define DRBD_MD_INDEX_FLEX_EXT -2
#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

View File

@ -95,7 +95,7 @@ static struct nla_policy s_name ## _nl_policy[] __read_mostly = \
#endif
#endif
#if 1
#ifdef GENL_MAGIC_DEBUG
static void dprint_field(const char *dir, int nla_type,
const char *name, void *valp)
{