mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-09 14:43:16 +00:00
drbd: Sending of big packets, for payloads from 64KByte to 4GByte
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
This commit is contained in:
parent
204bba9965
commit
0b70a13dac
@ -337,13 +337,25 @@ static inline void bm_xfer_ctx_bit_to_word_offset(struct bm_xfer_ctx *c)
|
|||||||
* NOTE that the payload starts at a long aligned offset,
|
* NOTE that the payload starts at a long aligned offset,
|
||||||
* regardless of 32 or 64 bit arch!
|
* regardless of 32 or 64 bit arch!
|
||||||
*/
|
*/
|
||||||
struct p_header {
|
struct p_header80 {
|
||||||
u32 magic;
|
u32 magic;
|
||||||
u16 command;
|
u16 command;
|
||||||
u16 length; /* bytes of data after this header */
|
u16 length; /* bytes of data after this header */
|
||||||
u8 payload[0];
|
u8 payload[0];
|
||||||
} __packed;
|
} __packed;
|
||||||
/* 8 bytes. packet FIXED for the next century! */
|
|
||||||
|
/* Header for big packets, Used for data packets exceeding 64kB */
|
||||||
|
struct p_header95 {
|
||||||
|
u16 magic; /* use DRBD_MAGIC_BIG here */
|
||||||
|
u16 command;
|
||||||
|
u32 length;
|
||||||
|
u8 payload[0];
|
||||||
|
} __packed;
|
||||||
|
|
||||||
|
union p_header {
|
||||||
|
struct p_header80 h80;
|
||||||
|
struct p_header95 h95;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* short commands, packets without payload, plain p_header:
|
* short commands, packets without payload, plain p_header:
|
||||||
@ -367,7 +379,7 @@ struct p_header {
|
|||||||
#define DP_MAY_SET_IN_SYNC 4
|
#define DP_MAY_SET_IN_SYNC 4
|
||||||
|
|
||||||
struct p_data {
|
struct p_data {
|
||||||
struct p_header head;
|
union p_header head;
|
||||||
u64 sector; /* 64 bits sector number */
|
u64 sector; /* 64 bits sector number */
|
||||||
u64 block_id; /* to identify the request in protocol B&C */
|
u64 block_id; /* to identify the request in protocol B&C */
|
||||||
u32 seq_num;
|
u32 seq_num;
|
||||||
@ -383,7 +395,7 @@ struct p_data {
|
|||||||
* P_DATA_REQUEST, P_RS_DATA_REQUEST
|
* P_DATA_REQUEST, P_RS_DATA_REQUEST
|
||||||
*/
|
*/
|
||||||
struct p_block_ack {
|
struct p_block_ack {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
u64 sector;
|
u64 sector;
|
||||||
u64 block_id;
|
u64 block_id;
|
||||||
u32 blksize;
|
u32 blksize;
|
||||||
@ -392,7 +404,7 @@ struct p_block_ack {
|
|||||||
|
|
||||||
|
|
||||||
struct p_block_req {
|
struct p_block_req {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
u64 sector;
|
u64 sector;
|
||||||
u64 block_id;
|
u64 block_id;
|
||||||
u32 blksize;
|
u32 blksize;
|
||||||
@ -409,7 +421,7 @@ struct p_block_req {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
struct p_handshake {
|
struct p_handshake {
|
||||||
struct p_header head; /* 8 bytes */
|
struct p_header80 head; /* 8 bytes */
|
||||||
u32 protocol_min;
|
u32 protocol_min;
|
||||||
u32 feature_flags;
|
u32 feature_flags;
|
||||||
u32 protocol_max;
|
u32 protocol_max;
|
||||||
@ -424,19 +436,19 @@ struct p_handshake {
|
|||||||
/* 80 bytes, FIXED for the next century */
|
/* 80 bytes, FIXED for the next century */
|
||||||
|
|
||||||
struct p_barrier {
|
struct p_barrier {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
u32 barrier; /* barrier number _handle_ only */
|
u32 barrier; /* barrier number _handle_ only */
|
||||||
u32 pad; /* to multiple of 8 Byte */
|
u32 pad; /* to multiple of 8 Byte */
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
struct p_barrier_ack {
|
struct p_barrier_ack {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
u32 barrier;
|
u32 barrier;
|
||||||
u32 set_size;
|
u32 set_size;
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
struct p_rs_param {
|
struct p_rs_param {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
u32 rate;
|
u32 rate;
|
||||||
|
|
||||||
/* Since protocol version 88 and higher. */
|
/* Since protocol version 88 and higher. */
|
||||||
@ -444,7 +456,7 @@ struct p_rs_param {
|
|||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
struct p_rs_param_89 {
|
struct p_rs_param_89 {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
u32 rate;
|
u32 rate;
|
||||||
/* protocol version 89: */
|
/* protocol version 89: */
|
||||||
char verify_alg[SHARED_SECRET_MAX];
|
char verify_alg[SHARED_SECRET_MAX];
|
||||||
@ -452,7 +464,7 @@ struct p_rs_param_89 {
|
|||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
struct p_rs_param_95 {
|
struct p_rs_param_95 {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
u32 rate;
|
u32 rate;
|
||||||
char verify_alg[SHARED_SECRET_MAX];
|
char verify_alg[SHARED_SECRET_MAX];
|
||||||
char csums_alg[SHARED_SECRET_MAX];
|
char csums_alg[SHARED_SECRET_MAX];
|
||||||
@ -468,7 +480,7 @@ enum drbd_conn_flags {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct p_protocol {
|
struct p_protocol {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
u32 protocol;
|
u32 protocol;
|
||||||
u32 after_sb_0p;
|
u32 after_sb_0p;
|
||||||
u32 after_sb_1p;
|
u32 after_sb_1p;
|
||||||
@ -482,17 +494,17 @@ struct p_protocol {
|
|||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
struct p_uuids {
|
struct p_uuids {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
u64 uuid[UI_EXTENDED_SIZE];
|
u64 uuid[UI_EXTENDED_SIZE];
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
struct p_rs_uuid {
|
struct p_rs_uuid {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
u64 uuid;
|
u64 uuid;
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
struct p_sizes {
|
struct p_sizes {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
u64 d_size; /* size of disk */
|
u64 d_size; /* size of disk */
|
||||||
u64 u_size; /* user requested size */
|
u64 u_size; /* user requested size */
|
||||||
u64 c_size; /* current exported size */
|
u64 c_size; /* current exported size */
|
||||||
@ -502,18 +514,18 @@ struct p_sizes {
|
|||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
struct p_state {
|
struct p_state {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
u32 state;
|
u32 state;
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
struct p_req_state {
|
struct p_req_state {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
u32 mask;
|
u32 mask;
|
||||||
u32 val;
|
u32 val;
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
struct p_req_state_reply {
|
struct p_req_state_reply {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
u32 retcode;
|
u32 retcode;
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
@ -528,7 +540,7 @@ struct p_drbd06_param {
|
|||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
struct p_discard {
|
struct p_discard {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
u64 block_id;
|
u64 block_id;
|
||||||
u32 seq_num;
|
u32 seq_num;
|
||||||
u32 pad;
|
u32 pad;
|
||||||
@ -544,7 +556,7 @@ enum drbd_bitmap_code {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct p_compressed_bm {
|
struct p_compressed_bm {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
/* (encoding & 0x0f): actual encoding, see enum drbd_bitmap_code
|
/* (encoding & 0x0f): actual encoding, see enum drbd_bitmap_code
|
||||||
* (encoding & 0x80): polarity (set/unset) of first runlength
|
* (encoding & 0x80): polarity (set/unset) of first runlength
|
||||||
* ((encoding >> 4) & 0x07): pad_bits, number of trailing zero bits
|
* ((encoding >> 4) & 0x07): pad_bits, number of trailing zero bits
|
||||||
@ -555,10 +567,10 @@ struct p_compressed_bm {
|
|||||||
u8 code[0];
|
u8 code[0];
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
struct p_delay_probe {
|
struct p_delay_probe93 {
|
||||||
struct p_header head;
|
struct p_header80 head;
|
||||||
u32 seq_num; /* sequence number to match the two probe packets */
|
u32 seq_num; /* sequence number to match the two probe packets */
|
||||||
u32 offset; /* usecs the probe got sent after the reference time point */
|
u32 offset; /* usecs the probe got sent after the reference time point */
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
/* DCBP: Drbd Compressed Bitmap Packet ... */
|
/* DCBP: Drbd Compressed Bitmap Packet ... */
|
||||||
@ -605,7 +617,7 @@ DCBP_set_pad_bits(struct p_compressed_bm *p, int n)
|
|||||||
* so we need to use the fixed size 4KiB page size
|
* so we need to use the fixed size 4KiB page size
|
||||||
* most architechtures have used for a long time.
|
* most architechtures have used for a long time.
|
||||||
*/
|
*/
|
||||||
#define BM_PACKET_PAYLOAD_BYTES (4096 - sizeof(struct p_header))
|
#define BM_PACKET_PAYLOAD_BYTES (4096 - sizeof(struct p_header80))
|
||||||
#define BM_PACKET_WORDS (BM_PACKET_PAYLOAD_BYTES/sizeof(long))
|
#define BM_PACKET_WORDS (BM_PACKET_PAYLOAD_BYTES/sizeof(long))
|
||||||
#define BM_PACKET_VLI_BYTES_MAX (4096 - sizeof(struct p_compressed_bm))
|
#define BM_PACKET_VLI_BYTES_MAX (4096 - sizeof(struct p_compressed_bm))
|
||||||
#if (PAGE_SIZE < 4096)
|
#if (PAGE_SIZE < 4096)
|
||||||
@ -614,7 +626,7 @@ DCBP_set_pad_bits(struct p_compressed_bm *p, int n)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
union p_polymorph {
|
union p_polymorph {
|
||||||
struct p_header header;
|
struct p_header80 header;
|
||||||
struct p_handshake handshake;
|
struct p_handshake handshake;
|
||||||
struct p_data data;
|
struct p_data data;
|
||||||
struct p_block_ack block_ack;
|
struct p_block_ack block_ack;
|
||||||
@ -1188,12 +1200,12 @@ extern int drbd_send_sizes(struct drbd_conf *mdev, int trigger_reply, enum dds_f
|
|||||||
extern int _drbd_send_state(struct drbd_conf *mdev);
|
extern int _drbd_send_state(struct drbd_conf *mdev);
|
||||||
extern int drbd_send_state(struct drbd_conf *mdev);
|
extern int drbd_send_state(struct drbd_conf *mdev);
|
||||||
extern int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock,
|
extern int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock,
|
||||||
enum drbd_packets cmd, struct p_header *h,
|
enum drbd_packets cmd, struct p_header80 *h,
|
||||||
size_t size, unsigned msg_flags);
|
size_t size, unsigned msg_flags);
|
||||||
#define USE_DATA_SOCKET 1
|
#define USE_DATA_SOCKET 1
|
||||||
#define USE_META_SOCKET 0
|
#define USE_META_SOCKET 0
|
||||||
extern int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket,
|
extern int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket,
|
||||||
enum drbd_packets cmd, struct p_header *h,
|
enum drbd_packets cmd, struct p_header80 *h,
|
||||||
size_t size);
|
size_t size);
|
||||||
extern int drbd_send_cmd2(struct drbd_conf *mdev, enum drbd_packets cmd,
|
extern int drbd_send_cmd2(struct drbd_conf *mdev, enum drbd_packets cmd,
|
||||||
char *data, size_t size);
|
char *data, size_t size);
|
||||||
@ -1936,19 +1948,19 @@ static inline void request_ping(struct drbd_conf *mdev)
|
|||||||
static inline int drbd_send_short_cmd(struct drbd_conf *mdev,
|
static inline int drbd_send_short_cmd(struct drbd_conf *mdev,
|
||||||
enum drbd_packets cmd)
|
enum drbd_packets cmd)
|
||||||
{
|
{
|
||||||
struct p_header h;
|
struct p_header80 h;
|
||||||
return drbd_send_cmd(mdev, USE_DATA_SOCKET, cmd, &h, sizeof(h));
|
return drbd_send_cmd(mdev, USE_DATA_SOCKET, cmd, &h, sizeof(h));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int drbd_send_ping(struct drbd_conf *mdev)
|
static inline int drbd_send_ping(struct drbd_conf *mdev)
|
||||||
{
|
{
|
||||||
struct p_header h;
|
struct p_header80 h;
|
||||||
return drbd_send_cmd(mdev, USE_META_SOCKET, P_PING, &h, sizeof(h));
|
return drbd_send_cmd(mdev, USE_META_SOCKET, P_PING, &h, sizeof(h));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int drbd_send_ping_ack(struct drbd_conf *mdev)
|
static inline int drbd_send_ping_ack(struct drbd_conf *mdev)
|
||||||
{
|
{
|
||||||
struct p_header h;
|
struct p_header80 h;
|
||||||
return drbd_send_cmd(mdev, USE_META_SOCKET, P_PING_ACK, &h, sizeof(h));
|
return drbd_send_cmd(mdev, USE_META_SOCKET, P_PING_ACK, &h, sizeof(h));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1647,7 +1647,7 @@ void drbd_thread_current_set_cpu(struct drbd_conf *mdev)
|
|||||||
|
|
||||||
/* the appropriate socket mutex must be held already */
|
/* the appropriate socket mutex must be held already */
|
||||||
int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock,
|
int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock,
|
||||||
enum drbd_packets cmd, struct p_header *h,
|
enum drbd_packets cmd, struct p_header80 *h,
|
||||||
size_t size, unsigned msg_flags)
|
size_t size, unsigned msg_flags)
|
||||||
{
|
{
|
||||||
int sent, ok;
|
int sent, ok;
|
||||||
@ -1657,7 +1657,7 @@ int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock,
|
|||||||
|
|
||||||
h->magic = BE_DRBD_MAGIC;
|
h->magic = BE_DRBD_MAGIC;
|
||||||
h->command = cpu_to_be16(cmd);
|
h->command = cpu_to_be16(cmd);
|
||||||
h->length = cpu_to_be16(size-sizeof(struct p_header));
|
h->length = cpu_to_be16(size-sizeof(struct p_header80));
|
||||||
|
|
||||||
sent = drbd_send(mdev, sock, h, size, msg_flags);
|
sent = drbd_send(mdev, sock, h, size, msg_flags);
|
||||||
|
|
||||||
@ -1672,7 +1672,7 @@ int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock,
|
|||||||
* when we hold the appropriate socket mutex.
|
* when we hold the appropriate socket mutex.
|
||||||
*/
|
*/
|
||||||
int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket,
|
int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket,
|
||||||
enum drbd_packets cmd, struct p_header *h, size_t size)
|
enum drbd_packets cmd, struct p_header80 *h, size_t size)
|
||||||
{
|
{
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
struct socket *sock;
|
struct socket *sock;
|
||||||
@ -1700,7 +1700,7 @@ int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket,
|
|||||||
int drbd_send_cmd2(struct drbd_conf *mdev, enum drbd_packets cmd, char *data,
|
int drbd_send_cmd2(struct drbd_conf *mdev, enum drbd_packets cmd, char *data,
|
||||||
size_t size)
|
size_t size)
|
||||||
{
|
{
|
||||||
struct p_header h;
|
struct p_header80 h;
|
||||||
int ok;
|
int ok;
|
||||||
|
|
||||||
h.magic = BE_DRBD_MAGIC;
|
h.magic = BE_DRBD_MAGIC;
|
||||||
@ -1807,7 +1807,7 @@ int drbd_send_protocol(struct drbd_conf *mdev)
|
|||||||
strcpy(p->integrity_alg, mdev->net_conf->integrity_alg);
|
strcpy(p->integrity_alg, mdev->net_conf->integrity_alg);
|
||||||
|
|
||||||
rv = drbd_send_cmd(mdev, USE_DATA_SOCKET, P_PROTOCOL,
|
rv = drbd_send_cmd(mdev, USE_DATA_SOCKET, P_PROTOCOL,
|
||||||
(struct p_header *)p, size);
|
(struct p_header80 *)p, size);
|
||||||
kfree(p);
|
kfree(p);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@ -1833,7 +1833,7 @@ int _drbd_send_uuids(struct drbd_conf *mdev, u64 uuid_flags)
|
|||||||
put_ldev(mdev);
|
put_ldev(mdev);
|
||||||
|
|
||||||
return drbd_send_cmd(mdev, USE_DATA_SOCKET, P_UUIDS,
|
return drbd_send_cmd(mdev, USE_DATA_SOCKET, P_UUIDS,
|
||||||
(struct p_header *)&p, sizeof(p));
|
(struct p_header80 *)&p, sizeof(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
int drbd_send_uuids(struct drbd_conf *mdev)
|
int drbd_send_uuids(struct drbd_conf *mdev)
|
||||||
@ -1854,7 +1854,7 @@ int drbd_send_sync_uuid(struct drbd_conf *mdev, u64 val)
|
|||||||
p.uuid = cpu_to_be64(val);
|
p.uuid = cpu_to_be64(val);
|
||||||
|
|
||||||
return drbd_send_cmd(mdev, USE_DATA_SOCKET, P_SYNC_UUID,
|
return drbd_send_cmd(mdev, USE_DATA_SOCKET, P_SYNC_UUID,
|
||||||
(struct p_header *)&p, sizeof(p));
|
(struct p_header80 *)&p, sizeof(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
int drbd_send_sizes(struct drbd_conf *mdev, int trigger_reply, enum dds_flags flags)
|
int drbd_send_sizes(struct drbd_conf *mdev, int trigger_reply, enum dds_flags flags)
|
||||||
@ -1884,7 +1884,7 @@ int drbd_send_sizes(struct drbd_conf *mdev, int trigger_reply, enum dds_flags fl
|
|||||||
p.dds_flags = cpu_to_be16(flags);
|
p.dds_flags = cpu_to_be16(flags);
|
||||||
|
|
||||||
ok = drbd_send_cmd(mdev, USE_DATA_SOCKET, P_SIZES,
|
ok = drbd_send_cmd(mdev, USE_DATA_SOCKET, P_SIZES,
|
||||||
(struct p_header *)&p, sizeof(p));
|
(struct p_header80 *)&p, sizeof(p));
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1909,7 +1909,7 @@ int drbd_send_state(struct drbd_conf *mdev)
|
|||||||
|
|
||||||
if (likely(sock != NULL)) {
|
if (likely(sock != NULL)) {
|
||||||
ok = _drbd_send_cmd(mdev, sock, P_STATE,
|
ok = _drbd_send_cmd(mdev, sock, P_STATE,
|
||||||
(struct p_header *)&p, sizeof(p), 0);
|
(struct p_header80 *)&p, sizeof(p), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&mdev->data.mutex);
|
mutex_unlock(&mdev->data.mutex);
|
||||||
@ -1927,7 +1927,7 @@ int drbd_send_state_req(struct drbd_conf *mdev,
|
|||||||
p.val = cpu_to_be32(val.i);
|
p.val = cpu_to_be32(val.i);
|
||||||
|
|
||||||
return drbd_send_cmd(mdev, USE_DATA_SOCKET, P_STATE_CHG_REQ,
|
return drbd_send_cmd(mdev, USE_DATA_SOCKET, P_STATE_CHG_REQ,
|
||||||
(struct p_header *)&p, sizeof(p));
|
(struct p_header80 *)&p, sizeof(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
int drbd_send_sr_reply(struct drbd_conf *mdev, int retcode)
|
int drbd_send_sr_reply(struct drbd_conf *mdev, int retcode)
|
||||||
@ -1937,7 +1937,7 @@ int drbd_send_sr_reply(struct drbd_conf *mdev, int retcode)
|
|||||||
p.retcode = cpu_to_be32(retcode);
|
p.retcode = cpu_to_be32(retcode);
|
||||||
|
|
||||||
return drbd_send_cmd(mdev, USE_META_SOCKET, P_STATE_CHG_REPLY,
|
return drbd_send_cmd(mdev, USE_META_SOCKET, P_STATE_CHG_REPLY,
|
||||||
(struct p_header *)&p, sizeof(p));
|
(struct p_header80 *)&p, sizeof(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
int fill_bitmap_rle_bits(struct drbd_conf *mdev,
|
int fill_bitmap_rle_bits(struct drbd_conf *mdev,
|
||||||
@ -2036,7 +2036,7 @@ int fill_bitmap_rle_bits(struct drbd_conf *mdev,
|
|||||||
|
|
||||||
enum { OK, FAILED, DONE }
|
enum { OK, FAILED, DONE }
|
||||||
send_bitmap_rle_or_plain(struct drbd_conf *mdev,
|
send_bitmap_rle_or_plain(struct drbd_conf *mdev,
|
||||||
struct p_header *h, struct bm_xfer_ctx *c)
|
struct p_header80 *h, struct bm_xfer_ctx *c)
|
||||||
{
|
{
|
||||||
struct p_compressed_bm *p = (void*)h;
|
struct p_compressed_bm *p = (void*)h;
|
||||||
unsigned long num_words;
|
unsigned long num_words;
|
||||||
@ -2066,12 +2066,12 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev,
|
|||||||
if (len)
|
if (len)
|
||||||
drbd_bm_get_lel(mdev, c->word_offset, num_words, (unsigned long*)h->payload);
|
drbd_bm_get_lel(mdev, c->word_offset, num_words, (unsigned long*)h->payload);
|
||||||
ok = _drbd_send_cmd(mdev, mdev->data.socket, P_BITMAP,
|
ok = _drbd_send_cmd(mdev, mdev->data.socket, P_BITMAP,
|
||||||
h, sizeof(struct p_header) + len, 0);
|
h, sizeof(struct p_header80) + len, 0);
|
||||||
c->word_offset += num_words;
|
c->word_offset += num_words;
|
||||||
c->bit_offset = c->word_offset * BITS_PER_LONG;
|
c->bit_offset = c->word_offset * BITS_PER_LONG;
|
||||||
|
|
||||||
c->packets[1]++;
|
c->packets[1]++;
|
||||||
c->bytes[1] += sizeof(struct p_header) + len;
|
c->bytes[1] += sizeof(struct p_header80) + len;
|
||||||
|
|
||||||
if (c->bit_offset > c->bm_bits)
|
if (c->bit_offset > c->bm_bits)
|
||||||
c->bit_offset = c->bm_bits;
|
c->bit_offset = c->bm_bits;
|
||||||
@ -2087,14 +2087,14 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev,
|
|||||||
int _drbd_send_bitmap(struct drbd_conf *mdev)
|
int _drbd_send_bitmap(struct drbd_conf *mdev)
|
||||||
{
|
{
|
||||||
struct bm_xfer_ctx c;
|
struct bm_xfer_ctx c;
|
||||||
struct p_header *p;
|
struct p_header80 *p;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ERR_IF(!mdev->bitmap) return FALSE;
|
ERR_IF(!mdev->bitmap) return FALSE;
|
||||||
|
|
||||||
/* maybe we should use some per thread scratch page,
|
/* maybe we should use some per thread scratch page,
|
||||||
* and allocate that during initial device creation? */
|
* and allocate that during initial device creation? */
|
||||||
p = (struct p_header *) __get_free_page(GFP_NOIO);
|
p = (struct p_header80 *) __get_free_page(GFP_NOIO);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
dev_err(DEV, "failed to allocate one page buffer in %s\n", __func__);
|
dev_err(DEV, "failed to allocate one page buffer in %s\n", __func__);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -2152,7 +2152,7 @@ int drbd_send_b_ack(struct drbd_conf *mdev, u32 barrier_nr, u32 set_size)
|
|||||||
if (mdev->state.conn < C_CONNECTED)
|
if (mdev->state.conn < C_CONNECTED)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
ok = drbd_send_cmd(mdev, USE_META_SOCKET, P_BARRIER_ACK,
|
ok = drbd_send_cmd(mdev, USE_META_SOCKET, P_BARRIER_ACK,
|
||||||
(struct p_header *)&p, sizeof(p));
|
(struct p_header80 *)&p, sizeof(p));
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2180,7 +2180,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packets cmd,
|
|||||||
if (!mdev->meta.socket || mdev->state.conn < C_CONNECTED)
|
if (!mdev->meta.socket || mdev->state.conn < C_CONNECTED)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
ok = drbd_send_cmd(mdev, USE_META_SOCKET, cmd,
|
ok = drbd_send_cmd(mdev, USE_META_SOCKET, cmd,
|
||||||
(struct p_header *)&p, sizeof(p));
|
(struct p_header80 *)&p, sizeof(p));
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2188,8 +2188,8 @@ int drbd_send_ack_dp(struct drbd_conf *mdev, enum drbd_packets cmd,
|
|||||||
struct p_data *dp)
|
struct p_data *dp)
|
||||||
{
|
{
|
||||||
const int header_size = sizeof(struct p_data)
|
const int header_size = sizeof(struct p_data)
|
||||||
- sizeof(struct p_header);
|
- sizeof(struct p_header80);
|
||||||
int data_size = ((struct p_header *)dp)->length - header_size;
|
int data_size = ((struct p_header80 *)dp)->length - header_size;
|
||||||
|
|
||||||
return _drbd_send_ack(mdev, cmd, dp->sector, cpu_to_be32(data_size),
|
return _drbd_send_ack(mdev, cmd, dp->sector, cpu_to_be32(data_size),
|
||||||
dp->block_id);
|
dp->block_id);
|
||||||
@ -2238,7 +2238,7 @@ int drbd_send_drequest(struct drbd_conf *mdev, int cmd,
|
|||||||
p.blksize = cpu_to_be32(size);
|
p.blksize = cpu_to_be32(size);
|
||||||
|
|
||||||
ok = drbd_send_cmd(mdev, USE_DATA_SOCKET, cmd,
|
ok = drbd_send_cmd(mdev, USE_DATA_SOCKET, cmd,
|
||||||
(struct p_header *)&p, sizeof(p));
|
(struct p_header80 *)&p, sizeof(p));
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2256,7 +2256,7 @@ int drbd_send_drequest_csum(struct drbd_conf *mdev,
|
|||||||
|
|
||||||
p.head.magic = BE_DRBD_MAGIC;
|
p.head.magic = BE_DRBD_MAGIC;
|
||||||
p.head.command = cpu_to_be16(cmd);
|
p.head.command = cpu_to_be16(cmd);
|
||||||
p.head.length = cpu_to_be16(sizeof(p) - sizeof(struct p_header) + digest_size);
|
p.head.length = cpu_to_be16(sizeof(p) - sizeof(struct p_header80) + digest_size);
|
||||||
|
|
||||||
mutex_lock(&mdev->data.mutex);
|
mutex_lock(&mdev->data.mutex);
|
||||||
|
|
||||||
@ -2278,7 +2278,7 @@ int drbd_send_ov_request(struct drbd_conf *mdev, sector_t sector, int size)
|
|||||||
p.blksize = cpu_to_be32(size);
|
p.blksize = cpu_to_be32(size);
|
||||||
|
|
||||||
ok = drbd_send_cmd(mdev, USE_DATA_SOCKET, P_OV_REQUEST,
|
ok = drbd_send_cmd(mdev, USE_DATA_SOCKET, P_OV_REQUEST,
|
||||||
(struct p_header *)&p, sizeof(p));
|
(struct p_header80 *)&p, sizeof(p));
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2447,10 +2447,17 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
|
|||||||
dgs = (mdev->agreed_pro_version >= 87 && mdev->integrity_w_tfm) ?
|
dgs = (mdev->agreed_pro_version >= 87 && mdev->integrity_w_tfm) ?
|
||||||
crypto_hash_digestsize(mdev->integrity_w_tfm) : 0;
|
crypto_hash_digestsize(mdev->integrity_w_tfm) : 0;
|
||||||
|
|
||||||
p.head.magic = BE_DRBD_MAGIC;
|
if (req->size <= (1 << 15)) {
|
||||||
p.head.command = cpu_to_be16(P_DATA);
|
p.head.h80.magic = BE_DRBD_MAGIC;
|
||||||
p.head.length =
|
p.head.h80.command = cpu_to_be16(P_DATA);
|
||||||
cpu_to_be16(sizeof(p) - sizeof(struct p_header) + dgs + req->size);
|
p.head.h80.length =
|
||||||
|
cpu_to_be16(sizeof(p) - sizeof(union p_header) + dgs + req->size);
|
||||||
|
} else {
|
||||||
|
p.head.h95.magic = BE_DRBD_MAGIC_BIG;
|
||||||
|
p.head.h95.command = cpu_to_be16(P_DATA);
|
||||||
|
p.head.h95.length =
|
||||||
|
cpu_to_be32(sizeof(p) - sizeof(union p_header) + dgs + req->size);
|
||||||
|
}
|
||||||
|
|
||||||
p.sector = cpu_to_be64(req->sector);
|
p.sector = cpu_to_be64(req->sector);
|
||||||
p.block_id = (unsigned long)req;
|
p.block_id = (unsigned long)req;
|
||||||
@ -2511,10 +2518,17 @@ int drbd_send_block(struct drbd_conf *mdev, enum drbd_packets cmd,
|
|||||||
dgs = (mdev->agreed_pro_version >= 87 && mdev->integrity_w_tfm) ?
|
dgs = (mdev->agreed_pro_version >= 87 && mdev->integrity_w_tfm) ?
|
||||||
crypto_hash_digestsize(mdev->integrity_w_tfm) : 0;
|
crypto_hash_digestsize(mdev->integrity_w_tfm) : 0;
|
||||||
|
|
||||||
p.head.magic = BE_DRBD_MAGIC;
|
if (e->size <= (1 << 15)) {
|
||||||
p.head.command = cpu_to_be16(cmd);
|
p.head.h80.magic = BE_DRBD_MAGIC;
|
||||||
p.head.length =
|
p.head.h80.command = cpu_to_be16(cmd);
|
||||||
cpu_to_be16(sizeof(p) - sizeof(struct p_header) + dgs + e->size);
|
p.head.h80.length =
|
||||||
|
cpu_to_be16(sizeof(p) - sizeof(struct p_header80) + dgs + e->size);
|
||||||
|
} else {
|
||||||
|
p.head.h95.magic = BE_DRBD_MAGIC_BIG;
|
||||||
|
p.head.h95.command = cpu_to_be16(cmd);
|
||||||
|
p.head.h95.length =
|
||||||
|
cpu_to_be32(sizeof(p) - sizeof(struct p_header80) + dgs + e->size);
|
||||||
|
}
|
||||||
|
|
||||||
p.sector = cpu_to_be64(e->sector);
|
p.sector = cpu_to_be64(e->sector);
|
||||||
p.block_id = e->block_id;
|
p.block_id = e->block_id;
|
||||||
@ -2527,8 +2541,7 @@ int drbd_send_block(struct drbd_conf *mdev, enum drbd_packets cmd,
|
|||||||
if (!drbd_get_data_sock(mdev))
|
if (!drbd_get_data_sock(mdev))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ok = sizeof(p) == drbd_send(mdev, mdev->data.socket, &p,
|
ok = sizeof(p) == drbd_send(mdev, mdev->data.socket, &p, sizeof(p), dgs ? MSG_MORE : 0);
|
||||||
sizeof(p), dgs ? MSG_MORE : 0);
|
|
||||||
if (ok && dgs) {
|
if (ok && dgs) {
|
||||||
dgb = mdev->int_dig_out;
|
dgb = mdev->int_dig_out;
|
||||||
drbd_csum_ee(mdev, mdev->integrity_w_tfm, e, dgb);
|
drbd_csum_ee(mdev, mdev->integrity_w_tfm, e, dgb);
|
||||||
|
@ -720,14 +720,14 @@ out:
|
|||||||
static int drbd_send_fp(struct drbd_conf *mdev,
|
static int drbd_send_fp(struct drbd_conf *mdev,
|
||||||
struct socket *sock, enum drbd_packets cmd)
|
struct socket *sock, enum drbd_packets cmd)
|
||||||
{
|
{
|
||||||
struct p_header *h = (struct p_header *) &mdev->data.sbuf.header;
|
struct p_header80 *h = (struct p_header80 *) &mdev->data.sbuf.header;
|
||||||
|
|
||||||
return _drbd_send_cmd(mdev, sock, cmd, h, sizeof(*h), 0);
|
return _drbd_send_cmd(mdev, sock, cmd, h, sizeof(*h), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum drbd_packets drbd_recv_fp(struct drbd_conf *mdev, struct socket *sock)
|
static enum drbd_packets drbd_recv_fp(struct drbd_conf *mdev, struct socket *sock)
|
||||||
{
|
{
|
||||||
struct p_header *h = (struct p_header *) &mdev->data.sbuf.header;
|
struct p_header80 *h = (struct p_header80 *) &mdev->data.sbuf.header;
|
||||||
int rr;
|
int rr;
|
||||||
|
|
||||||
rr = drbd_recv_short(mdev, sock, h, sizeof(*h), 0);
|
rr = drbd_recv_short(mdev, sock, h, sizeof(*h), 0);
|
||||||
@ -944,7 +944,7 @@ out_release_sockets:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int drbd_recv_header(struct drbd_conf *mdev, struct p_header *h)
|
static int drbd_recv_header(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -1266,7 +1266,7 @@ int w_e_reissue(struct drbd_conf *mdev, struct drbd_work *w, int cancel) __relea
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_Barrier(struct drbd_conf *mdev, struct p_header *h)
|
static int receive_Barrier(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
int rv, issue_flush;
|
int rv, issue_flush;
|
||||||
struct p_barrier *p = (struct p_barrier *)h;
|
struct p_barrier *p = (struct p_barrier *)h;
|
||||||
@ -1570,7 +1570,7 @@ fail:
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_DataReply(struct drbd_conf *mdev, struct p_header *h)
|
static int receive_DataReply(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
struct drbd_request *req;
|
struct drbd_request *req;
|
||||||
sector_t sector;
|
sector_t sector;
|
||||||
@ -1610,7 +1610,7 @@ static int receive_DataReply(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_RSDataReply(struct drbd_conf *mdev, struct p_header *h)
|
static int receive_RSDataReply(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
sector_t sector;
|
sector_t sector;
|
||||||
unsigned int header_size, data_size;
|
unsigned int header_size, data_size;
|
||||||
@ -1767,7 +1767,7 @@ static int drbd_wait_peer_seq(struct drbd_conf *mdev, const u32 packet_seq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* mirrored write */
|
/* mirrored write */
|
||||||
static int receive_Data(struct drbd_conf *mdev, struct p_header *h)
|
static int receive_Data(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
sector_t sector;
|
sector_t sector;
|
||||||
struct drbd_epoch_entry *e;
|
struct drbd_epoch_entry *e;
|
||||||
@ -2066,7 +2066,7 @@ int drbd_rs_should_slow_down(struct drbd_conf *mdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int receive_DataRequest(struct drbd_conf *mdev, struct p_header *h)
|
static int receive_DataRequest(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
sector_t sector;
|
sector_t sector;
|
||||||
const sector_t capacity = drbd_get_capacity(mdev->this_bdev);
|
const sector_t capacity = drbd_get_capacity(mdev->this_bdev);
|
||||||
@ -2756,7 +2756,7 @@ static int cmp_after_sb(enum drbd_after_sb_p peer, enum drbd_after_sb_p self)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_protocol(struct drbd_conf *mdev, struct p_header *h)
|
static int receive_protocol(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
struct p_protocol *p = (struct p_protocol *)h;
|
struct p_protocol *p = (struct p_protocol *)h;
|
||||||
int header_size, data_size;
|
int header_size, data_size;
|
||||||
@ -2862,7 +2862,7 @@ struct crypto_hash *drbd_crypto_alloc_digest_safe(const struct drbd_conf *mdev,
|
|||||||
return tfm;
|
return tfm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_SyncParam(struct drbd_conf *mdev, struct p_header *h)
|
static int receive_SyncParam(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
int ok = TRUE;
|
int ok = TRUE;
|
||||||
struct p_rs_param_95 *p = (struct p_rs_param_95 *)h;
|
struct p_rs_param_95 *p = (struct p_rs_param_95 *)h;
|
||||||
@ -3032,7 +3032,7 @@ static void warn_if_differ_considerably(struct drbd_conf *mdev,
|
|||||||
(unsigned long long)a, (unsigned long long)b);
|
(unsigned long long)a, (unsigned long long)b);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_sizes(struct drbd_conf *mdev, struct p_header *h)
|
static int receive_sizes(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
struct p_sizes *p = (struct p_sizes *)h;
|
struct p_sizes *p = (struct p_sizes *)h;
|
||||||
enum determine_dev_size dd = unchanged;
|
enum determine_dev_size dd = unchanged;
|
||||||
@ -3148,7 +3148,7 @@ static int receive_sizes(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_uuids(struct drbd_conf *mdev, struct p_header *h)
|
static int receive_uuids(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
struct p_uuids *p = (struct p_uuids *)h;
|
struct p_uuids *p = (struct p_uuids *)h;
|
||||||
u64 *p_uuid;
|
u64 *p_uuid;
|
||||||
@ -3241,7 +3241,7 @@ static union drbd_state convert_state(union drbd_state ps)
|
|||||||
return ms;
|
return ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_req_state(struct drbd_conf *mdev, struct p_header *h)
|
static int receive_req_state(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
struct p_req_state *p = (struct p_req_state *)h;
|
struct p_req_state *p = (struct p_req_state *)h;
|
||||||
union drbd_state mask, val;
|
union drbd_state mask, val;
|
||||||
@ -3271,7 +3271,7 @@ static int receive_req_state(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_state(struct drbd_conf *mdev, struct p_header *h)
|
static int receive_state(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
struct p_state *p = (struct p_state *)h;
|
struct p_state *p = (struct p_state *)h;
|
||||||
enum drbd_conns nconn, oconn;
|
enum drbd_conns nconn, oconn;
|
||||||
@ -3395,7 +3395,7 @@ static int receive_state(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_sync_uuid(struct drbd_conf *mdev, struct p_header *h)
|
static int receive_sync_uuid(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
struct p_rs_uuid *p = (struct p_rs_uuid *)h;
|
struct p_rs_uuid *p = (struct p_rs_uuid *)h;
|
||||||
|
|
||||||
@ -3428,7 +3428,7 @@ static int receive_sync_uuid(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
enum receive_bitmap_ret { OK, DONE, FAILED };
|
enum receive_bitmap_ret { OK, DONE, FAILED };
|
||||||
|
|
||||||
static enum receive_bitmap_ret
|
static enum receive_bitmap_ret
|
||||||
receive_bitmap_plain(struct drbd_conf *mdev, struct p_header *h,
|
receive_bitmap_plain(struct drbd_conf *mdev, struct p_header80 *h,
|
||||||
unsigned long *buffer, struct bm_xfer_ctx *c)
|
unsigned long *buffer, struct bm_xfer_ctx *c)
|
||||||
{
|
{
|
||||||
unsigned num_words = min_t(size_t, BM_PACKET_WORDS, c->bm_words - c->word_offset);
|
unsigned num_words = min_t(size_t, BM_PACKET_WORDS, c->bm_words - c->word_offset);
|
||||||
@ -3533,7 +3533,7 @@ void INFO_bm_xfer_stats(struct drbd_conf *mdev,
|
|||||||
const char *direction, struct bm_xfer_ctx *c)
|
const char *direction, struct bm_xfer_ctx *c)
|
||||||
{
|
{
|
||||||
/* what would it take to transfer it "plaintext" */
|
/* what would it take to transfer it "plaintext" */
|
||||||
unsigned plain = sizeof(struct p_header) *
|
unsigned plain = sizeof(struct p_header80) *
|
||||||
((c->bm_words+BM_PACKET_WORDS-1)/BM_PACKET_WORDS+1)
|
((c->bm_words+BM_PACKET_WORDS-1)/BM_PACKET_WORDS+1)
|
||||||
+ c->bm_words * sizeof(long);
|
+ c->bm_words * sizeof(long);
|
||||||
unsigned total = c->bytes[0] + c->bytes[1];
|
unsigned total = c->bytes[0] + c->bytes[1];
|
||||||
@ -3571,7 +3571,7 @@ void INFO_bm_xfer_stats(struct drbd_conf *mdev,
|
|||||||
in order to be agnostic to the 32 vs 64 bits issue.
|
in order to be agnostic to the 32 vs 64 bits issue.
|
||||||
|
|
||||||
returns 0 on failure, 1 if we successfully received it. */
|
returns 0 on failure, 1 if we successfully received it. */
|
||||||
static int receive_bitmap(struct drbd_conf *mdev, struct p_header *h)
|
static int receive_bitmap(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
struct bm_xfer_ctx c;
|
struct bm_xfer_ctx c;
|
||||||
void *buffer;
|
void *buffer;
|
||||||
@ -3623,7 +3623,7 @@ static int receive_bitmap(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.packets[h->command == P_BITMAP]++;
|
c.packets[h->command == P_BITMAP]++;
|
||||||
c.bytes[h->command == P_BITMAP] += sizeof(struct p_header) + h->length;
|
c.bytes[h->command == P_BITMAP] += sizeof(struct p_header80) + h->length;
|
||||||
|
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
break;
|
break;
|
||||||
@ -3659,7 +3659,7 @@ static int receive_bitmap(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_skip_(struct drbd_conf *mdev, struct p_header *h, int silent)
|
static int receive_skip_(struct drbd_conf *mdev, struct p_header80 *h, int silent)
|
||||||
{
|
{
|
||||||
/* TODO zero copy sink :) */
|
/* TODO zero copy sink :) */
|
||||||
static char sink[128];
|
static char sink[128];
|
||||||
@ -3679,17 +3679,17 @@ static int receive_skip_(struct drbd_conf *mdev, struct p_header *h, int silent)
|
|||||||
return size == 0;
|
return size == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_skip(struct drbd_conf *mdev, struct p_header *h)
|
static int receive_skip(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
return receive_skip_(mdev, h, 0);
|
return receive_skip_(mdev, h, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_skip_silent(struct drbd_conf *mdev, struct p_header *h)
|
static int receive_skip_silent(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
return receive_skip_(mdev, h, 1);
|
return receive_skip_(mdev, h, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_UnplugRemote(struct drbd_conf *mdev, struct p_header *h)
|
static int receive_UnplugRemote(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
if (mdev->state.disk >= D_INCONSISTENT)
|
if (mdev->state.disk >= D_INCONSISTENT)
|
||||||
drbd_kick_lo(mdev);
|
drbd_kick_lo(mdev);
|
||||||
@ -3701,7 +3701,7 @@ static int receive_UnplugRemote(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef int (*drbd_cmd_handler_f)(struct drbd_conf *, struct p_header *);
|
typedef int (*drbd_cmd_handler_f)(struct drbd_conf *, struct p_header80 *);
|
||||||
|
|
||||||
static drbd_cmd_handler_f drbd_default_handler[] = {
|
static drbd_cmd_handler_f drbd_default_handler[] = {
|
||||||
[P_DATA] = receive_Data,
|
[P_DATA] = receive_Data,
|
||||||
@ -3736,7 +3736,7 @@ static drbd_cmd_handler_f *drbd_opt_cmd_handler;
|
|||||||
static void drbdd(struct drbd_conf *mdev)
|
static void drbdd(struct drbd_conf *mdev)
|
||||||
{
|
{
|
||||||
drbd_cmd_handler_f handler;
|
drbd_cmd_handler_f handler;
|
||||||
struct p_header *header = &mdev->data.rbuf.header;
|
struct p_header80 *header = &mdev->data.rbuf.header;
|
||||||
|
|
||||||
while (get_t_state(&mdev->receiver) == Running) {
|
while (get_t_state(&mdev->receiver) == Running) {
|
||||||
drbd_thread_current_set_cpu(mdev);
|
drbd_thread_current_set_cpu(mdev);
|
||||||
@ -3964,7 +3964,7 @@ static int drbd_send_handshake(struct drbd_conf *mdev)
|
|||||||
p->protocol_min = cpu_to_be32(PRO_VERSION_MIN);
|
p->protocol_min = cpu_to_be32(PRO_VERSION_MIN);
|
||||||
p->protocol_max = cpu_to_be32(PRO_VERSION_MAX);
|
p->protocol_max = cpu_to_be32(PRO_VERSION_MAX);
|
||||||
ok = _drbd_send_cmd( mdev, mdev->data.socket, P_HAND_SHAKE,
|
ok = _drbd_send_cmd( mdev, mdev->data.socket, P_HAND_SHAKE,
|
||||||
(struct p_header *)p, sizeof(*p), 0 );
|
(struct p_header80 *)p, sizeof(*p), 0 );
|
||||||
mutex_unlock(&mdev->data.mutex);
|
mutex_unlock(&mdev->data.mutex);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
@ -3981,7 +3981,7 @@ static int drbd_do_handshake(struct drbd_conf *mdev)
|
|||||||
/* ASSERT current == mdev->receiver ... */
|
/* ASSERT current == mdev->receiver ... */
|
||||||
struct p_handshake *p = &mdev->data.rbuf.handshake;
|
struct p_handshake *p = &mdev->data.rbuf.handshake;
|
||||||
const int expect = sizeof(struct p_handshake)
|
const int expect = sizeof(struct p_handshake)
|
||||||
-sizeof(struct p_header);
|
-sizeof(struct p_header80);
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
rv = drbd_send_handshake(mdev);
|
rv = drbd_send_handshake(mdev);
|
||||||
@ -4058,7 +4058,7 @@ static int drbd_do_auth(struct drbd_conf *mdev)
|
|||||||
char *response = NULL;
|
char *response = NULL;
|
||||||
char *right_response = NULL;
|
char *right_response = NULL;
|
||||||
char *peers_ch = NULL;
|
char *peers_ch = NULL;
|
||||||
struct p_header p;
|
struct p_header80 p;
|
||||||
unsigned int key_len = strlen(mdev->net_conf->shared_secret);
|
unsigned int key_len = strlen(mdev->net_conf->shared_secret);
|
||||||
unsigned int resp_size;
|
unsigned int resp_size;
|
||||||
struct hash_desc desc;
|
struct hash_desc desc;
|
||||||
@ -4231,7 +4231,7 @@ int drbdd_init(struct drbd_thread *thi)
|
|||||||
|
|
||||||
/* ********* acknowledge sender ******** */
|
/* ********* acknowledge sender ******** */
|
||||||
|
|
||||||
static int got_RqSReply(struct drbd_conf *mdev, struct p_header *h)
|
static int got_RqSReply(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
struct p_req_state_reply *p = (struct p_req_state_reply *)h;
|
struct p_req_state_reply *p = (struct p_req_state_reply *)h;
|
||||||
|
|
||||||
@ -4249,13 +4249,13 @@ static int got_RqSReply(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int got_Ping(struct drbd_conf *mdev, struct p_header *h)
|
static int got_Ping(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
return drbd_send_ping_ack(mdev);
|
return drbd_send_ping_ack(mdev);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int got_PingAck(struct drbd_conf *mdev, struct p_header *h)
|
static int got_PingAck(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
/* restore idle timeout */
|
/* restore idle timeout */
|
||||||
mdev->meta.socket->sk->sk_rcvtimeo = mdev->net_conf->ping_int*HZ;
|
mdev->meta.socket->sk->sk_rcvtimeo = mdev->net_conf->ping_int*HZ;
|
||||||
@ -4265,7 +4265,7 @@ static int got_PingAck(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int got_IsInSync(struct drbd_conf *mdev, struct p_header *h)
|
static int got_IsInSync(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
struct p_block_ack *p = (struct p_block_ack *)h;
|
struct p_block_ack *p = (struct p_block_ack *)h;
|
||||||
sector_t sector = be64_to_cpu(p->sector);
|
sector_t sector = be64_to_cpu(p->sector);
|
||||||
@ -4336,7 +4336,7 @@ static int validate_req_change_req_state(struct drbd_conf *mdev,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int got_BlockAck(struct drbd_conf *mdev, struct p_header *h)
|
static int got_BlockAck(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
struct p_block_ack *p = (struct p_block_ack *)h;
|
struct p_block_ack *p = (struct p_block_ack *)h;
|
||||||
sector_t sector = be64_to_cpu(p->sector);
|
sector_t sector = be64_to_cpu(p->sector);
|
||||||
@ -4376,7 +4376,7 @@ static int got_BlockAck(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
_ack_id_to_req, __func__ , what);
|
_ack_id_to_req, __func__ , what);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int got_NegAck(struct drbd_conf *mdev, struct p_header *h)
|
static int got_NegAck(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
struct p_block_ack *p = (struct p_block_ack *)h;
|
struct p_block_ack *p = (struct p_block_ack *)h;
|
||||||
sector_t sector = be64_to_cpu(p->sector);
|
sector_t sector = be64_to_cpu(p->sector);
|
||||||
@ -4396,7 +4396,7 @@ static int got_NegAck(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
_ack_id_to_req, __func__ , neg_acked);
|
_ack_id_to_req, __func__ , neg_acked);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int got_NegDReply(struct drbd_conf *mdev, struct p_header *h)
|
static int got_NegDReply(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
struct p_block_ack *p = (struct p_block_ack *)h;
|
struct p_block_ack *p = (struct p_block_ack *)h;
|
||||||
sector_t sector = be64_to_cpu(p->sector);
|
sector_t sector = be64_to_cpu(p->sector);
|
||||||
@ -4409,7 +4409,7 @@ static int got_NegDReply(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
_ar_id_to_req, __func__ , neg_acked);
|
_ar_id_to_req, __func__ , neg_acked);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int got_NegRSDReply(struct drbd_conf *mdev, struct p_header *h)
|
static int got_NegRSDReply(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
sector_t sector;
|
sector_t sector;
|
||||||
int size;
|
int size;
|
||||||
@ -4431,7 +4431,7 @@ static int got_NegRSDReply(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int got_BarrierAck(struct drbd_conf *mdev, struct p_header *h)
|
static int got_BarrierAck(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
struct p_barrier_ack *p = (struct p_barrier_ack *)h;
|
struct p_barrier_ack *p = (struct p_barrier_ack *)h;
|
||||||
|
|
||||||
@ -4440,7 +4440,7 @@ static int got_BarrierAck(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int got_OVResult(struct drbd_conf *mdev, struct p_header *h)
|
static int got_OVResult(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
struct p_block_ack *p = (struct p_block_ack *)h;
|
struct p_block_ack *p = (struct p_block_ack *)h;
|
||||||
struct drbd_work *w;
|
struct drbd_work *w;
|
||||||
@ -4474,7 +4474,7 @@ static int got_OVResult(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int got_something_to_ignore_m(struct drbd_conf *mdev, struct p_header *h)
|
static int got_something_to_ignore_m(struct drbd_conf *mdev, struct p_header80 *h)
|
||||||
{
|
{
|
||||||
/* IGNORE */
|
/* IGNORE */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -4482,7 +4482,7 @@ static int got_something_to_ignore_m(struct drbd_conf *mdev, struct p_header *h)
|
|||||||
|
|
||||||
struct asender_cmd {
|
struct asender_cmd {
|
||||||
size_t pkt_size;
|
size_t pkt_size;
|
||||||
int (*process)(struct drbd_conf *mdev, struct p_header *h);
|
int (*process)(struct drbd_conf *mdev, struct p_header80 *h);
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct asender_cmd *get_asender_cmd(int cmd)
|
static struct asender_cmd *get_asender_cmd(int cmd)
|
||||||
@ -4491,8 +4491,8 @@ static struct asender_cmd *get_asender_cmd(int cmd)
|
|||||||
/* anything missing from this table is in
|
/* anything missing from this table is in
|
||||||
* the drbd_cmd_handler (drbd_default_handler) table,
|
* the drbd_cmd_handler (drbd_default_handler) table,
|
||||||
* see the beginning of drbdd() */
|
* see the beginning of drbdd() */
|
||||||
[P_PING] = { sizeof(struct p_header), got_Ping },
|
[P_PING] = { sizeof(struct p_header80), got_Ping },
|
||||||
[P_PING_ACK] = { sizeof(struct p_header), got_PingAck },
|
[P_PING_ACK] = { sizeof(struct p_header80), got_PingAck },
|
||||||
[P_RECV_ACK] = { sizeof(struct p_block_ack), got_BlockAck },
|
[P_RECV_ACK] = { sizeof(struct p_block_ack), got_BlockAck },
|
||||||
[P_WRITE_ACK] = { sizeof(struct p_block_ack), got_BlockAck },
|
[P_WRITE_ACK] = { sizeof(struct p_block_ack), got_BlockAck },
|
||||||
[P_RS_WRITE_ACK] = { sizeof(struct p_block_ack), got_BlockAck },
|
[P_RS_WRITE_ACK] = { sizeof(struct p_block_ack), got_BlockAck },
|
||||||
@ -4504,7 +4504,7 @@ static struct asender_cmd *get_asender_cmd(int cmd)
|
|||||||
[P_BARRIER_ACK] = { sizeof(struct p_barrier_ack), got_BarrierAck },
|
[P_BARRIER_ACK] = { sizeof(struct p_barrier_ack), got_BarrierAck },
|
||||||
[P_STATE_CHG_REPLY] = { sizeof(struct p_req_state_reply), got_RqSReply },
|
[P_STATE_CHG_REPLY] = { sizeof(struct p_req_state_reply), got_RqSReply },
|
||||||
[P_RS_IS_IN_SYNC] = { sizeof(struct p_block_ack), got_IsInSync },
|
[P_RS_IS_IN_SYNC] = { sizeof(struct p_block_ack), got_IsInSync },
|
||||||
[P_DELAY_PROBE] = { sizeof(struct p_delay_probe), got_something_to_ignore_m },
|
[P_DELAY_PROBE] = { sizeof(struct p_delay_probe93), got_something_to_ignore_m },
|
||||||
[P_MAX_CMD] = { 0, NULL },
|
[P_MAX_CMD] = { 0, NULL },
|
||||||
};
|
};
|
||||||
if (cmd > P_MAX_CMD || asender_tbl[cmd].process == NULL)
|
if (cmd > P_MAX_CMD || asender_tbl[cmd].process == NULL)
|
||||||
@ -4515,13 +4515,13 @@ static struct asender_cmd *get_asender_cmd(int cmd)
|
|||||||
int drbd_asender(struct drbd_thread *thi)
|
int drbd_asender(struct drbd_thread *thi)
|
||||||
{
|
{
|
||||||
struct drbd_conf *mdev = thi->mdev;
|
struct drbd_conf *mdev = thi->mdev;
|
||||||
struct p_header *h = &mdev->meta.rbuf.header;
|
struct p_header80 *h = &mdev->meta.rbuf.header;
|
||||||
struct asender_cmd *cmd = NULL;
|
struct asender_cmd *cmd = NULL;
|
||||||
|
|
||||||
int rv, len;
|
int rv, len;
|
||||||
void *buf = h;
|
void *buf = h;
|
||||||
int received = 0;
|
int received = 0;
|
||||||
int expect = sizeof(struct p_header);
|
int expect = sizeof(struct p_header80);
|
||||||
int empty;
|
int empty;
|
||||||
|
|
||||||
sprintf(current->comm, "drbd%d_asender", mdev_to_minor(mdev));
|
sprintf(current->comm, "drbd%d_asender", mdev_to_minor(mdev));
|
||||||
@ -4621,7 +4621,7 @@ int drbd_asender(struct drbd_thread *thi)
|
|||||||
goto disconnect;
|
goto disconnect;
|
||||||
}
|
}
|
||||||
expect = cmd->pkt_size;
|
expect = cmd->pkt_size;
|
||||||
ERR_IF(len != expect-sizeof(struct p_header))
|
ERR_IF(len != expect-sizeof(struct p_header80))
|
||||||
goto reconnect;
|
goto reconnect;
|
||||||
}
|
}
|
||||||
if (received == expect) {
|
if (received == expect) {
|
||||||
@ -4631,7 +4631,7 @@ int drbd_asender(struct drbd_thread *thi)
|
|||||||
|
|
||||||
buf = h;
|
buf = h;
|
||||||
received = 0;
|
received = 0;
|
||||||
expect = sizeof(struct p_header);
|
expect = sizeof(struct p_header80);
|
||||||
cmd = NULL;
|
cmd = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1204,7 +1204,7 @@ int w_send_barrier(struct drbd_conf *mdev, struct drbd_work *w, int cancel)
|
|||||||
* dec_ap_pending will be done in got_BarrierAck
|
* dec_ap_pending will be done in got_BarrierAck
|
||||||
* or (on connection loss) in w_clear_epoch. */
|
* or (on connection loss) in w_clear_epoch. */
|
||||||
ok = _drbd_send_cmd(mdev, mdev->data.socket, P_BARRIER,
|
ok = _drbd_send_cmd(mdev, mdev->data.socket, P_BARRIER,
|
||||||
(struct p_header *)p, sizeof(*p), 0);
|
(struct p_header80 *)p, sizeof(*p), 0);
|
||||||
drbd_put_data_sock(mdev);
|
drbd_put_data_sock(mdev);
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
|
@ -318,6 +318,8 @@ enum drbd_timeout_flag {
|
|||||||
|
|
||||||
#define DRBD_MAGIC 0x83740267
|
#define DRBD_MAGIC 0x83740267
|
||||||
#define BE_DRBD_MAGIC __constant_cpu_to_be32(DRBD_MAGIC)
|
#define BE_DRBD_MAGIC __constant_cpu_to_be32(DRBD_MAGIC)
|
||||||
|
#define DRBD_MAGIC_BIG 0x835a
|
||||||
|
#define BE_DRBD_MAGIC_BIG __constant_cpu_to_be16(DRBD_MAGIC_BIG)
|
||||||
|
|
||||||
/* these are of type "int" */
|
/* these are of type "int" */
|
||||||
#define DRBD_MD_INDEX_INTERNAL -1
|
#define DRBD_MD_INDEX_INTERNAL -1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user