Commit 8e26f9cc authored by Philipp Reisner's avatar Philipp Reisner

drbd: New sync_param packet, that includes the parameters of the new controller

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent 9a31d716
...@@ -451,6 +451,17 @@ struct p_rs_param_89 { ...@@ -451,6 +451,17 @@ struct p_rs_param_89 {
char csums_alg[SHARED_SECRET_MAX]; char csums_alg[SHARED_SECRET_MAX];
} __packed; } __packed;
struct p_rs_param_95 {
struct p_header head;
u32 rate;
char verify_alg[SHARED_SECRET_MAX];
char csums_alg[SHARED_SECRET_MAX];
u32 c_plan_ahead;
u32 c_delay_target;
u32 c_fill_target;
u32 c_max_rate;
} __packed;
enum drbd_conn_flags { enum drbd_conn_flags {
CF_WANT_LOSE = 1, CF_WANT_LOSE = 1,
CF_DRY_RUN = 2, CF_DRY_RUN = 2,
...@@ -610,6 +621,7 @@ union p_polymorph { ...@@ -610,6 +621,7 @@ union p_polymorph {
struct p_barrier barrier; struct p_barrier barrier;
struct p_barrier_ack barrier_ack; struct p_barrier_ack barrier_ack;
struct p_rs_param_89 rs_param_89; struct p_rs_param_89 rs_param_89;
struct p_rs_param_95 rs_param_95;
struct p_protocol protocol; struct p_protocol protocol;
struct p_sizes sizes; struct p_sizes sizes;
struct p_uuids uuids; struct p_uuids uuids;
...@@ -1268,6 +1280,8 @@ struct bm_extent { ...@@ -1268,6 +1280,8 @@ struct bm_extent {
* Bit 1 ==> local node thinks this block needs to be synced. * Bit 1 ==> local node thinks this block needs to be synced.
*/ */
#define SLEEP_TIME (HZ/10)
#define BM_BLOCK_SHIFT 12 /* 4k per bit */ #define BM_BLOCK_SHIFT 12 /* 4k per bit */
#define BM_BLOCK_SIZE (1<<BM_BLOCK_SHIFT) #define BM_BLOCK_SIZE (1<<BM_BLOCK_SHIFT)
/* (9+3) : 512 bytes @ 8 bits; representing 16M storage /* (9+3) : 512 bytes @ 8 bits; representing 16M storage
......
...@@ -1713,7 +1713,7 @@ int drbd_send_cmd2(struct drbd_conf *mdev, enum drbd_packets cmd, char *data, ...@@ -1713,7 +1713,7 @@ int drbd_send_cmd2(struct drbd_conf *mdev, enum drbd_packets cmd, char *data,
int drbd_send_sync_param(struct drbd_conf *mdev, struct syncer_conf *sc) int drbd_send_sync_param(struct drbd_conf *mdev, struct syncer_conf *sc)
{ {
struct p_rs_param_89 *p; struct p_rs_param_95 *p;
struct socket *sock; struct socket *sock;
int size, rv; int size, rv;
const int apv = mdev->agreed_pro_version; const int apv = mdev->agreed_pro_version;
...@@ -1721,7 +1721,8 @@ int drbd_send_sync_param(struct drbd_conf *mdev, struct syncer_conf *sc) ...@@ -1721,7 +1721,8 @@ int drbd_send_sync_param(struct drbd_conf *mdev, struct syncer_conf *sc)
size = apv <= 87 ? sizeof(struct p_rs_param) size = apv <= 87 ? sizeof(struct p_rs_param)
: apv == 88 ? sizeof(struct p_rs_param) : apv == 88 ? sizeof(struct p_rs_param)
+ strlen(mdev->sync_conf.verify_alg) + 1 + strlen(mdev->sync_conf.verify_alg) + 1
: /* 89 */ sizeof(struct p_rs_param_89); : apv <= 94 ? sizeof(struct p_rs_param_89)
: /* apv >= 95 */ sizeof(struct p_rs_param_95);
/* used from admin command context and receiver/worker context. /* used from admin command context and receiver/worker context.
* to avoid kmalloc, grab the socket right here, * to avoid kmalloc, grab the socket right here,
...@@ -1732,12 +1733,16 @@ int drbd_send_sync_param(struct drbd_conf *mdev, struct syncer_conf *sc) ...@@ -1732,12 +1733,16 @@ int drbd_send_sync_param(struct drbd_conf *mdev, struct syncer_conf *sc)
if (likely(sock != NULL)) { if (likely(sock != NULL)) {
enum drbd_packets cmd = apv >= 89 ? P_SYNC_PARAM89 : P_SYNC_PARAM; enum drbd_packets cmd = apv >= 89 ? P_SYNC_PARAM89 : P_SYNC_PARAM;
p = &mdev->data.sbuf.rs_param_89; p = &mdev->data.sbuf.rs_param_95;
/* initialize verify_alg and csums_alg */ /* initialize verify_alg and csums_alg */
memset(p->verify_alg, 0, 2 * SHARED_SECRET_MAX); memset(p->verify_alg, 0, 2 * SHARED_SECRET_MAX);
p->rate = cpu_to_be32(sc->rate); p->rate = cpu_to_be32(sc->rate);
p->c_plan_ahead = cpu_to_be32(sc->c_plan_ahead);
p->c_delay_target = cpu_to_be32(sc->c_delay_target);
p->c_fill_target = cpu_to_be32(sc->c_fill_target);
p->c_max_rate = cpu_to_be32(sc->c_max_rate);
if (apv >= 88) if (apv >= 88)
strcpy(p->verify_alg, mdev->sync_conf.verify_alg); strcpy(p->verify_alg, mdev->sync_conf.verify_alg);
......
...@@ -2805,7 +2805,7 @@ struct crypto_hash *drbd_crypto_alloc_digest_safe(const struct drbd_conf *mdev, ...@@ -2805,7 +2805,7 @@ struct crypto_hash *drbd_crypto_alloc_digest_safe(const struct drbd_conf *mdev,
static int receive_SyncParam(struct drbd_conf *mdev, struct p_header *h) static int receive_SyncParam(struct drbd_conf *mdev, struct p_header *h)
{ {
int ok = TRUE; int ok = TRUE;
struct p_rs_param_89 *p = (struct p_rs_param_89 *)h; struct p_rs_param_95 *p = (struct p_rs_param_95 *)h;
unsigned int header_size, data_size, exp_max_sz; unsigned int header_size, data_size, exp_max_sz;
struct crypto_hash *verify_tfm = NULL; struct crypto_hash *verify_tfm = NULL;
struct crypto_hash *csums_tfm = NULL; struct crypto_hash *csums_tfm = NULL;
...@@ -2814,7 +2814,8 @@ static int receive_SyncParam(struct drbd_conf *mdev, struct p_header *h) ...@@ -2814,7 +2814,8 @@ static int receive_SyncParam(struct drbd_conf *mdev, struct p_header *h)
exp_max_sz = apv <= 87 ? sizeof(struct p_rs_param) exp_max_sz = apv <= 87 ? sizeof(struct p_rs_param)
: apv == 88 ? sizeof(struct p_rs_param) : apv == 88 ? sizeof(struct p_rs_param)
+ SHARED_SECRET_MAX + SHARED_SECRET_MAX
: /* 89 */ sizeof(struct p_rs_param_89); : apv <= 94 ? sizeof(struct p_rs_param_89)
: /* apv >= 95 */ sizeof(struct p_rs_param_95);
if (h->length > exp_max_sz) { if (h->length > exp_max_sz) {
dev_err(DEV, "SyncParam packet too long: received %u, expected <= %u bytes\n", dev_err(DEV, "SyncParam packet too long: received %u, expected <= %u bytes\n",
...@@ -2825,10 +2826,14 @@ static int receive_SyncParam(struct drbd_conf *mdev, struct p_header *h) ...@@ -2825,10 +2826,14 @@ static int receive_SyncParam(struct drbd_conf *mdev, struct p_header *h)
if (apv <= 88) { if (apv <= 88) {
header_size = sizeof(struct p_rs_param) - sizeof(*h); header_size = sizeof(struct p_rs_param) - sizeof(*h);
data_size = h->length - header_size; data_size = h->length - header_size;
} else /* apv >= 89 */ { } else if (apv <= 94) {
header_size = sizeof(struct p_rs_param_89) - sizeof(*h); header_size = sizeof(struct p_rs_param_89) - sizeof(*h);
data_size = h->length - header_size; data_size = h->length - header_size;
D_ASSERT(data_size == 0); D_ASSERT(data_size == 0);
} else {
header_size = sizeof(struct p_rs_param_95) - sizeof(*h);
data_size = h->length - header_size;
D_ASSERT(data_size == 0);
} }
/* initialize verify_alg and csums_alg */ /* initialize verify_alg and csums_alg */
...@@ -2893,6 +2898,13 @@ static int receive_SyncParam(struct drbd_conf *mdev, struct p_header *h) ...@@ -2893,6 +2898,13 @@ static int receive_SyncParam(struct drbd_conf *mdev, struct p_header *h)
} }
} }
if (apv > 94) {
mdev->sync_conf.rate = be32_to_cpu(p->rate);
mdev->sync_conf.c_plan_ahead = be32_to_cpu(p->c_plan_ahead);
mdev->sync_conf.c_delay_target = be32_to_cpu(p->c_delay_target);
mdev->sync_conf.c_fill_target = be32_to_cpu(p->c_fill_target);
mdev->sync_conf.c_max_rate = be32_to_cpu(p->c_max_rate);
}
spin_lock(&mdev->peer_seq_lock); spin_lock(&mdev->peer_seq_lock);
/* lock against drbd_nl_syncer_conf() */ /* lock against drbd_nl_syncer_conf() */
......
...@@ -39,8 +39,6 @@ ...@@ -39,8 +39,6 @@
#include "drbd_int.h" #include "drbd_int.h"
#include "drbd_req.h" #include "drbd_req.h"
#define SLEEP_TIME (HZ/10)
static int w_make_ov_request(struct drbd_conf *mdev, struct drbd_work *w, int cancel); static int w_make_ov_request(struct drbd_conf *mdev, struct drbd_work *w, int cancel);
......
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