提交 80883197 编写于 作者: P Philipp Reisner

drbd: Converted drbd_nl_(net_conf|disconnect)() from mdev to tconn

Signed-off-by: NPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: NLars Ellenberg <lars.ellenberg@linbit.com>
上级 1aba4d7f
...@@ -170,6 +170,7 @@ drbd_insert_fault(struct drbd_conf *mdev, unsigned int type) { ...@@ -170,6 +170,7 @@ drbd_insert_fault(struct drbd_conf *mdev, unsigned int type) {
extern struct drbd_conf **minor_table; extern struct drbd_conf **minor_table;
extern struct ratelimit_state drbd_ratelimit_state; extern struct ratelimit_state drbd_ratelimit_state;
extern struct list_head drbd_tconns;
/* on the wire */ /* on the wire */
enum drbd_packet { enum drbd_packet {
...@@ -1474,6 +1475,7 @@ extern wait_queue_head_t drbd_pp_wait; ...@@ -1474,6 +1475,7 @@ extern wait_queue_head_t drbd_pp_wait;
extern rwlock_t global_state_lock; extern rwlock_t global_state_lock;
extern int conn_lowest_minor(struct drbd_tconn *tconn);
extern struct drbd_conf *drbd_new_device(unsigned int minor); extern struct drbd_conf *drbd_new_device(unsigned int minor);
extern void drbd_free_mdev(struct drbd_conf *mdev); extern void drbd_free_mdev(struct drbd_conf *mdev);
......
...@@ -615,7 +615,7 @@ char *drbd_task_to_thread_name(struct drbd_tconn *tconn, struct task_struct *tas ...@@ -615,7 +615,7 @@ char *drbd_task_to_thread_name(struct drbd_tconn *tconn, struct task_struct *tas
} }
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
static int conn_lowest_minor(struct drbd_tconn *tconn) int conn_lowest_minor(struct drbd_tconn *tconn)
{ {
int minor = 0; int minor = 0;
idr_get_next(&tconn->volumes, &minor); idr_get_next(&tconn->volumes, &minor);
......
...@@ -1326,7 +1326,7 @@ static int drbd_nl_detach(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp, ...@@ -1326,7 +1326,7 @@ static int drbd_nl_detach(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
return 0; return 0;
} }
static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp, static int drbd_nl_net_conf(struct drbd_tconn *tconn, struct drbd_nl_cfg_req *nlp,
struct drbd_nl_cfg_reply *reply) struct drbd_nl_cfg_reply *reply)
{ {
int i; int i;
...@@ -1335,16 +1335,17 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp, ...@@ -1335,16 +1335,17 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
struct crypto_hash *tfm = NULL; struct crypto_hash *tfm = NULL;
struct crypto_hash *integrity_w_tfm = NULL; struct crypto_hash *integrity_w_tfm = NULL;
struct crypto_hash *integrity_r_tfm = NULL; struct crypto_hash *integrity_r_tfm = NULL;
struct drbd_conf *odev; struct drbd_conf *mdev;
char hmac_name[CRYPTO_MAX_ALG_NAME]; char hmac_name[CRYPTO_MAX_ALG_NAME];
void *int_dig_out = NULL; void *int_dig_out = NULL;
void *int_dig_in = NULL; void *int_dig_in = NULL;
void *int_dig_vv = NULL; void *int_dig_vv = NULL;
struct drbd_tconn *oconn;
struct sockaddr *new_my_addr, *new_peer_addr, *taken_addr; struct sockaddr *new_my_addr, *new_peer_addr, *taken_addr;
conn_reconfig_start(mdev->tconn); conn_reconfig_start(tconn);
if (mdev->state.conn > C_STANDALONE) { if (tconn->cstate > C_STANDALONE) {
retcode = ERR_NET_CONFIGURED; retcode = ERR_NET_CONFIGURED;
goto fail; goto fail;
} }
...@@ -1387,13 +1388,25 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp, ...@@ -1387,13 +1388,25 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
goto fail; goto fail;
} }
if (get_ldev(mdev)) { idr_for_each_entry(&tconn->volumes, mdev, i) {
enum drbd_fencing_p fp = mdev->ldev->dc.fencing; if (get_ldev(mdev)) {
put_ldev(mdev); enum drbd_fencing_p fp = mdev->ldev->dc.fencing;
if (new_conf->wire_protocol == DRBD_PROT_A && fp == FP_STONITH) { put_ldev(mdev);
retcode = ERR_STONITH_AND_PROT_A; if (new_conf->wire_protocol == DRBD_PROT_A && fp == FP_STONITH) {
retcode = ERR_STONITH_AND_PROT_A;
goto fail;
}
}
if (mdev->state.role == R_PRIMARY && new_conf->want_lose) {
retcode = ERR_DISCARD;
goto fail; goto fail;
} }
if (!mdev->bitmap) {
if(drbd_bm_init(mdev)) {
retcode = ERR_NOMEM;
goto fail;
}
}
} }
if (new_conf->on_congestion != OC_BLOCK && new_conf->wire_protocol != DRBD_PROT_A) { if (new_conf->on_congestion != OC_BLOCK && new_conf->wire_protocol != DRBD_PROT_A) {
...@@ -1401,31 +1414,25 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp, ...@@ -1401,31 +1414,25 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
goto fail; goto fail;
} }
if (mdev->state.role == R_PRIMARY && new_conf->want_lose) {
retcode = ERR_DISCARD;
goto fail;
}
retcode = NO_ERROR; retcode = NO_ERROR;
new_my_addr = (struct sockaddr *)&new_conf->my_addr; new_my_addr = (struct sockaddr *)&new_conf->my_addr;
new_peer_addr = (struct sockaddr *)&new_conf->peer_addr; new_peer_addr = (struct sockaddr *)&new_conf->peer_addr;
for (i = 0; i < minor_count; i++) { list_for_each_entry(oconn, &drbd_tconns, all_tconn) {
odev = minor_to_mdev(i); if (oconn == tconn)
if (!odev || odev == mdev)
continue; continue;
if (get_net_conf(odev->tconn)) { if (get_net_conf(oconn)) {
taken_addr = (struct sockaddr *)&odev->tconn->net_conf->my_addr; taken_addr = (struct sockaddr *)&oconn->net_conf->my_addr;
if (new_conf->my_addr_len == odev->tconn->net_conf->my_addr_len && if (new_conf->my_addr_len == oconn->net_conf->my_addr_len &&
!memcmp(new_my_addr, taken_addr, new_conf->my_addr_len)) !memcmp(new_my_addr, taken_addr, new_conf->my_addr_len))
retcode = ERR_LOCAL_ADDR; retcode = ERR_LOCAL_ADDR;
taken_addr = (struct sockaddr *)&odev->tconn->net_conf->peer_addr; taken_addr = (struct sockaddr *)&oconn->net_conf->peer_addr;
if (new_conf->peer_addr_len == odev->tconn->net_conf->peer_addr_len && if (new_conf->peer_addr_len == oconn->net_conf->peer_addr_len &&
!memcmp(new_peer_addr, taken_addr, new_conf->peer_addr_len)) !memcmp(new_peer_addr, taken_addr, new_conf->peer_addr_len))
retcode = ERR_PEER_ADDR; retcode = ERR_PEER_ADDR;
put_net_conf(odev->tconn); put_net_conf(oconn);
if (retcode != NO_ERROR) if (retcode != NO_ERROR)
goto fail; goto fail;
} }
...@@ -1470,6 +1477,7 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp, ...@@ -1470,6 +1477,7 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
((char *)new_conf->shared_secret)[SHARED_SECRET_MAX-1] = 0; ((char *)new_conf->shared_secret)[SHARED_SECRET_MAX-1] = 0;
/* allocation not in the IO path, cqueue thread context */
if (integrity_w_tfm) { if (integrity_w_tfm) {
i = crypto_hash_digestsize(integrity_w_tfm); i = crypto_hash_digestsize(integrity_w_tfm);
int_dig_out = kmalloc(i, GFP_KERNEL); int_dig_out = kmalloc(i, GFP_KERNEL);
...@@ -1489,46 +1497,40 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp, ...@@ -1489,46 +1497,40 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
} }
} }
if (!mdev->bitmap) { conn_flush_workqueue(tconn);
if(drbd_bm_init(mdev)) { spin_lock_irq(&tconn->req_lock);
retcode = ERR_NOMEM; if (tconn->net_conf != NULL) {
goto fail;
}
}
drbd_flush_workqueue(mdev);
spin_lock_irq(&mdev->tconn->req_lock);
if (mdev->tconn->net_conf != NULL) {
retcode = ERR_NET_CONFIGURED; retcode = ERR_NET_CONFIGURED;
spin_unlock_irq(&mdev->tconn->req_lock); spin_unlock_irq(&tconn->req_lock);
goto fail; goto fail;
} }
mdev->tconn->net_conf = new_conf; tconn->net_conf = new_conf;
mdev->send_cnt = 0; crypto_free_hash(tconn->cram_hmac_tfm);
mdev->recv_cnt = 0; tconn->cram_hmac_tfm = tfm;
crypto_free_hash(mdev->tconn->cram_hmac_tfm);
mdev->tconn->cram_hmac_tfm = tfm;
crypto_free_hash(mdev->tconn->integrity_w_tfm); crypto_free_hash(tconn->integrity_w_tfm);
mdev->tconn->integrity_w_tfm = integrity_w_tfm; tconn->integrity_w_tfm = integrity_w_tfm;
crypto_free_hash(mdev->tconn->integrity_r_tfm); crypto_free_hash(tconn->integrity_r_tfm);
mdev->tconn->integrity_r_tfm = integrity_r_tfm; tconn->integrity_r_tfm = integrity_r_tfm;
kfree(mdev->tconn->int_dig_out); kfree(tconn->int_dig_out);
kfree(mdev->tconn->int_dig_in); kfree(tconn->int_dig_in);
kfree(mdev->tconn->int_dig_vv); kfree(tconn->int_dig_vv);
mdev->tconn->int_dig_out=int_dig_out; tconn->int_dig_out=int_dig_out;
mdev->tconn->int_dig_in=int_dig_in; tconn->int_dig_in=int_dig_in;
mdev->tconn->int_dig_vv=int_dig_vv; tconn->int_dig_vv=int_dig_vv;
retcode = _conn_request_state(mdev->tconn, NS(conn, C_UNCONNECTED), CS_VERBOSE); retcode = _conn_request_state(tconn, NS(conn, C_UNCONNECTED), CS_VERBOSE);
spin_unlock_irq(&mdev->tconn->req_lock); spin_unlock_irq(&tconn->req_lock);
kobject_uevent(&disk_to_dev(mdev->vdisk)->kobj, KOBJ_CHANGE); idr_for_each_entry(&tconn->volumes, mdev, i) {
mdev->send_cnt = 0;
mdev->recv_cnt = 0;
kobject_uevent(&disk_to_dev(mdev->vdisk)->kobj, KOBJ_CHANGE);
}
reply->ret_code = retcode; reply->ret_code = retcode;
conn_reconfig_done(mdev->tconn); conn_reconfig_done(tconn);
return 0; return 0;
fail: fail:
...@@ -1541,14 +1543,13 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp, ...@@ -1541,14 +1543,13 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
kfree(new_conf); kfree(new_conf);
reply->ret_code = retcode; reply->ret_code = retcode;
conn_reconfig_done(mdev->tconn); conn_reconfig_done(tconn);
return 0; return 0;
} }
static int drbd_nl_disconnect(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp, static int drbd_nl_disconnect(struct drbd_tconn *tconn, struct drbd_nl_cfg_req *nlp,
struct drbd_nl_cfg_reply *reply) struct drbd_nl_cfg_reply *reply)
{ {
struct drbd_tconn *tconn = mdev->tconn;
int retcode; int retcode;
struct disconnect dc; struct disconnect dc;
...@@ -1600,7 +1601,6 @@ static int drbd_nl_disconnect(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nl ...@@ -1600,7 +1601,6 @@ static int drbd_nl_disconnect(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nl
done: done:
retcode = NO_ERROR; retcode = NO_ERROR;
fail: fail:
drbd_md_sync(mdev);
reply->ret_code = retcode; reply->ret_code = retcode;
return 0; return 0;
} }
...@@ -2211,8 +2211,8 @@ static struct cn_handler_struct cnd_table[] = { ...@@ -2211,8 +2211,8 @@ static struct cn_handler_struct cnd_table[] = {
[ P_secondary ] = { CHT_MINOR, { &drbd_nl_secondary }, 0 }, [ P_secondary ] = { CHT_MINOR, { &drbd_nl_secondary }, 0 },
[ P_disk_conf ] = { CHT_MINOR, { &drbd_nl_disk_conf }, 0 }, [ P_disk_conf ] = { CHT_MINOR, { &drbd_nl_disk_conf }, 0 },
[ P_detach ] = { CHT_MINOR, { &drbd_nl_detach }, 0 }, [ P_detach ] = { CHT_MINOR, { &drbd_nl_detach }, 0 },
[ P_net_conf ] = { CHT_MINOR, { &drbd_nl_net_conf }, 0 }, [ P_net_conf ] = { CHT_CONN, { .conn_based = &drbd_nl_net_conf }, 0 },
[ P_disconnect ] = { CHT_MINOR, { &drbd_nl_disconnect }, 0 }, [ P_disconnect ] = { CHT_CONN, { .conn_based = &drbd_nl_disconnect }, 0 },
[ P_resize ] = { CHT_MINOR, { &drbd_nl_resize }, 0 }, [ P_resize ] = { CHT_MINOR, { &drbd_nl_resize }, 0 },
[ P_syncer_conf ] = { CHT_MINOR, { &drbd_nl_syncer_conf },0 }, [ P_syncer_conf ] = { CHT_MINOR, { &drbd_nl_syncer_conf },0 },
[ P_invalidate ] = { CHT_MINOR, { &drbd_nl_invalidate }, 0 }, [ P_invalidate ] = { CHT_MINOR, { &drbd_nl_invalidate }, 0 },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册