Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 345987
b: refs/heads/master
c: e658983
h: refs/heads/master
i:
  345985: 724b378
  345983: 0fa6f10
v: v3
  • Loading branch information
Andreas Gruenbacher authored and Philipp Reisner committed Nov 8, 2012
1 parent f491232 commit 7fdefaa
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 155 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 50d0b1ad78b99aa776c3ddf9b1d45163fff435b9
refs/heads/master: e658983af6e62304be785cd6b0ae756723057395
45 changes: 0 additions & 45 deletions trunk/drivers/block/drbd/drbd_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,32 +307,8 @@ struct p_header95 {
u32 length; /* Use only 24 bits of that. Ignore the highest 8 bit. */
} __packed;

struct p_header {
union {
struct p_header80 h80;
struct p_header95 h95;
};
u8 payload[0];
};

extern unsigned int drbd_header_size(struct drbd_tconn *tconn);

/*
* short commands, packets without payload, plain p_header:
* P_PING
* P_PING_ACK
* P_BECOME_SYNC_TARGET
* P_BECOME_SYNC_SOURCE
* P_UNPLUG_REMOTE
*/

/*
* commands with out-of-struct payload:
* P_BITMAP (no additional fields)
* P_DATA, P_DATA_REPLY (see p_data)
* P_COMPRESSED_BITMAP (see receive_compressed_bitmap)
*/

/* these defines must not be changed without changing the protocol version */
#define DP_HARDBARRIER 1 /* depricated */
#define DP_RW_SYNC 2 /* equals REQ_SYNC */
Expand All @@ -343,7 +319,6 @@ extern unsigned int drbd_header_size(struct drbd_tconn *tconn);
#define DP_DISCARD 64 /* equals REQ_DISCARD */

struct p_data {
struct p_header head;
u64 sector; /* 64 bits sector number */
u64 block_id; /* to identify the request in protocol B&C */
u32 seq_num;
Expand All @@ -359,15 +334,13 @@ struct p_data {
* P_DATA_REQUEST, P_RS_DATA_REQUEST
*/
struct p_block_ack {
struct p_header head;
u64 sector;
u64 block_id;
u32 blksize;
u32 seq_num;
} __packed;

struct p_block_req {
struct p_header head;
u64 sector;
u64 block_id;
u32 blksize;
Expand All @@ -384,7 +357,6 @@ struct p_block_req {
*/

struct p_connection_features {
struct p_header head; /* Note: vnr will be ignored */
u32 protocol_min;
u32 feature_flags;
u32 protocol_max;
Expand All @@ -396,38 +368,32 @@ struct p_connection_features {
u32 _pad;
u64 reserverd[7];
} __packed;
/* 80 bytes, FIXED for the next century */

struct p_barrier {
struct p_header head;
u32 barrier; /* barrier number _handle_ only */
u32 pad; /* to multiple of 8 Byte */
} __packed;

struct p_barrier_ack {
struct p_header head;
u32 barrier;
u32 set_size;
} __packed;

struct p_rs_param {
struct p_header head;
u32 rate;

/* Since protocol version 88 and higher. */
char verify_alg[0];
} __packed;

struct p_rs_param_89 {
struct p_header head;
u32 rate;
/* protocol version 89: */
char verify_alg[SHARED_SECRET_MAX];
char csums_alg[SHARED_SECRET_MAX];
} __packed;

struct p_rs_param_95 {
struct p_header head;
u32 rate;
char verify_alg[SHARED_SECRET_MAX];
char csums_alg[SHARED_SECRET_MAX];
Expand All @@ -443,7 +409,6 @@ enum drbd_conn_flags {
};

struct p_protocol {
struct p_header head;
u32 protocol;
u32 after_sb_0p;
u32 after_sb_1p;
Expand All @@ -457,17 +422,14 @@ struct p_protocol {
} __packed;

struct p_uuids {
struct p_header head;
u64 uuid[UI_EXTENDED_SIZE];
} __packed;

struct p_rs_uuid {
struct p_header head;
u64 uuid;
} __packed;

struct p_sizes {
struct p_header head;
u64 d_size; /* size of disk */
u64 u_size; /* user requested size */
u64 c_size; /* current exported size */
Expand All @@ -477,18 +439,15 @@ struct p_sizes {
} __packed;

struct p_state {
struct p_header head;
u32 state;
} __packed;

struct p_req_state {
struct p_header head;
u32 mask;
u32 val;
} __packed;

struct p_req_state_reply {
struct p_header head;
u32 retcode;
} __packed;

Expand All @@ -503,14 +462,12 @@ struct p_drbd06_param {
} __packed;

struct p_discard {
struct p_header head;
u64 block_id;
u32 seq_num;
u32 pad;
} __packed;

struct p_block_desc {
struct p_header head;
u64 sector;
u32 blksize;
u32 pad; /* to multiple of 8 Byte */
Expand All @@ -526,7 +483,6 @@ enum drbd_bitmap_code {
};

struct p_compressed_bm {
struct p_header head;
/* (encoding & 0x0f): actual encoding, see enum drbd_bitmap_code
* (encoding & 0x80): polarity (set/unset) of first runlength
* ((encoding >> 4) & 0x07): pad_bits, number of trailing zero bits
Expand All @@ -538,7 +494,6 @@ struct p_compressed_bm {
} __packed;

struct p_delay_probe93 {
struct p_header head;
u32 seq_num; /* sequence number to match the two probe packets */
u32 offset; /* usecs the probe got sent after the reference time point */
} __packed;
Expand Down
45 changes: 22 additions & 23 deletions trunk/drivers/block/drbd/drbd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,27 +703,29 @@ unsigned int drbd_header_size(struct drbd_tconn *tconn)
return sizeof(struct p_header80);
}

static void prepare_header80(struct p_header80 *h, enum drbd_packet cmd, int size)
static unsigned int prepare_header80(struct p_header80 *h, enum drbd_packet cmd, int size)
{
h->magic = cpu_to_be32(DRBD_MAGIC);
h->command = cpu_to_be16(cmd);
h->length = cpu_to_be16(size);
return sizeof(struct p_header80);
}

static void prepare_header95(struct p_header95 *h, enum drbd_packet cmd, int size)
static unsigned int prepare_header95(struct p_header95 *h, enum drbd_packet cmd, int size)
{
h->magic = cpu_to_be16(DRBD_MAGIC_BIG);
h->command = cpu_to_be16(cmd);
h->length = cpu_to_be32(size);
return sizeof(struct p_header95);
}

static void prepare_header(struct drbd_tconn *tconn, int vnr, struct p_header *h,
enum drbd_packet cmd, int size)
static unsigned int prepare_header(struct drbd_tconn *tconn, int vnr, void *buffer,
enum drbd_packet cmd, int size)
{
if (tconn->agreed_pro_version >= 95)
prepare_header95(&h->h95, cmd, size);
return prepare_header95(buffer, cmd, size);
else
prepare_header80(&h->h80, cmd, size);
return prepare_header80(buffer, cmd, size);
}

void *conn_prepare_command(struct drbd_tconn *tconn, struct drbd_socket *sock)
Expand All @@ -733,7 +735,7 @@ void *conn_prepare_command(struct drbd_tconn *tconn, struct drbd_socket *sock)
mutex_unlock(&sock->mutex);
return NULL;
}
return sock->sbuf;
return sock->sbuf + drbd_header_size(tconn);
}

void *drbd_prepare_command(struct drbd_conf *mdev, struct drbd_socket *sock)
Expand All @@ -758,8 +760,8 @@ static int __send_command(struct drbd_tconn *tconn, int vnr,
*/
msg_flags = data ? MSG_MORE : 0;

prepare_header(tconn, vnr, sock->sbuf, cmd,
header_size - sizeof(struct p_header) + size);
header_size += prepare_header(tconn, vnr, sock->sbuf, cmd,
header_size + size);
err = drbd_send_all(tconn, sock->socket, sock->sbuf, header_size,
msg_flags);
if (data && !err)
Expand Down Expand Up @@ -797,7 +799,7 @@ int drbd_send_ping(struct drbd_tconn *tconn)
sock = &tconn->meta;
if (!conn_prepare_command(tconn, sock))
return -EIO;
return conn_send_command(tconn, sock, P_PING, sizeof(struct p_header), NULL, 0);
return conn_send_command(tconn, sock, P_PING, 0, NULL, 0);
}

int drbd_send_ping_ack(struct drbd_tconn *tconn)
Expand All @@ -807,7 +809,7 @@ int drbd_send_ping_ack(struct drbd_tconn *tconn)
sock = &tconn->meta;
if (!conn_prepare_command(tconn, sock))
return -EIO;
return conn_send_command(tconn, sock, P_PING_ACK, sizeof(struct p_header), NULL, 0);
return conn_send_command(tconn, sock, P_PING_ACK, 0, NULL, 0);
}

int drbd_send_sync_param(struct drbd_conf *mdev)
Expand Down Expand Up @@ -1205,10 +1207,11 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev, struct bm_xfer_ctx *c)
{
struct drbd_socket *sock = &mdev->tconn->data;
unsigned int header_size = drbd_header_size(mdev->tconn);
struct p_compressed_bm *p = sock->sbuf;
struct p_compressed_bm *p = sock->sbuf + header_size;
int len, err;

len = fill_bitmap_rle_bits(mdev, p, DRBD_SOCKET_BUFFER_SIZE - sizeof(*p) /* FIXME */, c);
len = fill_bitmap_rle_bits(mdev, p,
DRBD_SOCKET_BUFFER_SIZE - header_size - sizeof(*p), c);
if (len < 0)
return -EIO;

Expand All @@ -1218,7 +1221,7 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev, struct bm_xfer_ctx *c)
P_COMPRESSED_BITMAP, sizeof(*p) + len,
NULL, 0);
c->packets[0]++;
c->bytes[0] += sizeof(*p) + len;
c->bytes[0] += header_size + sizeof(*p) + len;

if (c->bit_offset >= c->bm_bits)
len = 0; /* DONE */
Expand All @@ -1227,17 +1230,15 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev, struct bm_xfer_ctx *c)
* send a buffer full of plain text bits instead. */
unsigned int data_size;
unsigned long num_words;
struct p_header *h = sock->sbuf;
unsigned long *p = sock->sbuf + header_size;

data_size = DRBD_SOCKET_BUFFER_SIZE - header_size;
num_words = min_t(size_t, data_size / sizeof(unsigned long),
num_words = min_t(size_t, data_size / sizeof(*p),
c->bm_words - c->word_offset);
len = num_words * sizeof(unsigned long);
len = num_words * sizeof(*p);
if (len)
drbd_bm_get_lel(mdev, c->word_offset, num_words,
(unsigned long *)h->payload);
err = __send_command(mdev->tconn, mdev->vnr, sock, P_BITMAP,
sizeof(*h) + len, NULL, 0);
drbd_bm_get_lel(mdev, c->word_offset, num_words, p);
err = __send_command(mdev->tconn, mdev->vnr, sock, P_BITMAP, len, NULL, 0);
c->word_offset += num_words;
c->bit_offset = c->word_offset * BITS_PER_LONG;

Expand Down Expand Up @@ -2556,8 +2557,6 @@ int __init drbd_init(void)
{
int err;

BUILD_BUG_ON(sizeof(struct p_connection_features) != 80);

if (minor_count < DRBD_MINOR_COUNT_MIN || minor_count > DRBD_MINOR_COUNT_MAX) {
printk(KERN_ERR
"drbd: invalid minor_count (%d)\n", minor_count);
Expand Down
Loading

0 comments on commit 7fdefaa

Please sign in to comment.