aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/drbd/drbd_int.h
diff options
context:
space:
mode:
authorPhilipp Reisner <philipp.reisner@linbit.com>2010-08-20 07:36:10 -0400
committerPhilipp Reisner <philipp.reisner@linbit.com>2010-10-14 12:38:23 -0400
commit0b70a13dac014ec9274640b9e945bde493ba365e (patch)
treecf771e2f8018c0b59bc14fbf00c5c9cdc9caed7c /drivers/block/drbd/drbd_int.h
parent204bba9965c4cc175bf5bc65ddd19889e9085c72 (diff)
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>
Diffstat (limited to 'drivers/block/drbd/drbd_int.h')
-rw-r--r--drivers/block/drbd/drbd_int.h74
1 files changed, 43 insertions, 31 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 0fedcc0b8dc9..3f10efc2ac14 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -337,13 +337,25 @@ static inline void bm_xfer_ctx_bit_to_word_offset(struct bm_xfer_ctx *c)
337 * NOTE that the payload starts at a long aligned offset, 337 * NOTE that the payload starts at a long aligned offset,
338 * regardless of 32 or 64 bit arch! 338 * regardless of 32 or 64 bit arch!
339 */ 339 */
340struct p_header { 340struct p_header80 {
341 u32 magic; 341 u32 magic;
342 u16 command; 342 u16 command;
343 u16 length; /* bytes of data after this header */ 343 u16 length; /* bytes of data after this header */
344 u8 payload[0]; 344 u8 payload[0];
345} __packed; 345} __packed;
346/* 8 bytes. packet FIXED for the next century! */ 346
347/* Header for big packets, Used for data packets exceeding 64kB */
348struct p_header95 {
349 u16 magic; /* use DRBD_MAGIC_BIG here */
350 u16 command;
351 u32 length;
352 u8 payload[0];
353} __packed;
354
355union p_header {
356 struct p_header80 h80;
357 struct p_header95 h95;
358};
347 359
348/* 360/*
349 * short commands, packets without payload, plain p_header: 361 * short commands, packets without payload, plain p_header:
@@ -367,7 +379,7 @@ struct p_header {
367#define DP_MAY_SET_IN_SYNC 4 379#define DP_MAY_SET_IN_SYNC 4
368 380
369struct p_data { 381struct p_data {
370 struct p_header head; 382 union p_header head;
371 u64 sector; /* 64 bits sector number */ 383 u64 sector; /* 64 bits sector number */
372 u64 block_id; /* to identify the request in protocol B&C */ 384 u64 block_id; /* to identify the request in protocol B&C */
373 u32 seq_num; 385 u32 seq_num;
@@ -383,7 +395,7 @@ struct p_data {
383 * P_DATA_REQUEST, P_RS_DATA_REQUEST 395 * P_DATA_REQUEST, P_RS_DATA_REQUEST
384 */ 396 */
385struct p_block_ack { 397struct p_block_ack {
386 struct p_header head; 398 struct p_header80 head;
387 u64 sector; 399 u64 sector;
388 u64 block_id; 400 u64 block_id;
389 u32 blksize; 401 u32 blksize;
@@ -392,7 +404,7 @@ struct p_block_ack {
392 404
393 405
394struct p_block_req { 406struct p_block_req {
395 struct p_header head; 407 struct p_header80 head;
396 u64 sector; 408 u64 sector;
397 u64 block_id; 409 u64 block_id;
398 u32 blksize; 410 u32 blksize;
@@ -409,7 +421,7 @@ struct p_block_req {
409 */ 421 */
410 422
411struct p_handshake { 423struct p_handshake {
412 struct p_header head; /* 8 bytes */ 424 struct p_header80 head; /* 8 bytes */
413 u32 protocol_min; 425 u32 protocol_min;
414 u32 feature_flags; 426 u32 feature_flags;
415 u32 protocol_max; 427 u32 protocol_max;
@@ -424,19 +436,19 @@ struct p_handshake {
424/* 80 bytes, FIXED for the next century */ 436/* 80 bytes, FIXED for the next century */
425 437
426struct p_barrier { 438struct p_barrier {
427 struct p_header head; 439 struct p_header80 head;
428 u32 barrier; /* barrier number _handle_ only */ 440 u32 barrier; /* barrier number _handle_ only */
429 u32 pad; /* to multiple of 8 Byte */ 441 u32 pad; /* to multiple of 8 Byte */
430} __packed; 442} __packed;
431 443
432struct p_barrier_ack { 444struct p_barrier_ack {
433 struct p_header head; 445 struct p_header80 head;
434 u32 barrier; 446 u32 barrier;
435 u32 set_size; 447 u32 set_size;
436} __packed; 448} __packed;
437 449
438struct p_rs_param { 450struct p_rs_param {
439 struct p_header head; 451 struct p_header80 head;
440 u32 rate; 452 u32 rate;
441 453
442 /* Since protocol version 88 and higher. */ 454 /* Since protocol version 88 and higher. */
@@ -444,7 +456,7 @@ struct p_rs_param {
444} __packed; 456} __packed;
445 457
446struct p_rs_param_89 { 458struct p_rs_param_89 {
447 struct p_header head; 459 struct p_header80 head;
448 u32 rate; 460 u32 rate;
449 /* protocol version 89: */ 461 /* protocol version 89: */
450 char verify_alg[SHARED_SECRET_MAX]; 462 char verify_alg[SHARED_SECRET_MAX];
@@ -452,7 +464,7 @@ struct p_rs_param_89 {
452} __packed; 464} __packed;
453 465
454struct p_rs_param_95 { 466struct p_rs_param_95 {
455 struct p_header head; 467 struct p_header80 head;
456 u32 rate; 468 u32 rate;
457 char verify_alg[SHARED_SECRET_MAX]; 469 char verify_alg[SHARED_SECRET_MAX];
458 char csums_alg[SHARED_SECRET_MAX]; 470 char csums_alg[SHARED_SECRET_MAX];
@@ -468,7 +480,7 @@ enum drbd_conn_flags {
468}; 480};
469 481
470struct p_protocol { 482struct p_protocol {
471 struct p_header head; 483 struct p_header80 head;
472 u32 protocol; 484 u32 protocol;
473 u32 after_sb_0p; 485 u32 after_sb_0p;
474 u32 after_sb_1p; 486 u32 after_sb_1p;
@@ -482,17 +494,17 @@ struct p_protocol {
482} __packed; 494} __packed;
483 495
484struct p_uuids { 496struct p_uuids {
485 struct p_header head; 497 struct p_header80 head;
486 u64 uuid[UI_EXTENDED_SIZE]; 498 u64 uuid[UI_EXTENDED_SIZE];
487} __packed; 499} __packed;
488 500
489struct p_rs_uuid { 501struct p_rs_uuid {
490 struct p_header head; 502 struct p_header80 head;
491 u64 uuid; 503 u64 uuid;
492} __packed; 504} __packed;
493 505
494struct p_sizes { 506struct p_sizes {
495 struct p_header head; 507 struct p_header80 head;
496 u64 d_size; /* size of disk */ 508 u64 d_size; /* size of disk */
497 u64 u_size; /* user requested size */ 509 u64 u_size; /* user requested size */
498 u64 c_size; /* current exported size */ 510 u64 c_size; /* current exported size */
@@ -502,18 +514,18 @@ struct p_sizes {
502} __packed; 514} __packed;
503 515
504struct p_state { 516struct p_state {
505 struct p_header head; 517 struct p_header80 head;
506 u32 state; 518 u32 state;
507} __packed; 519} __packed;
508 520
509struct p_req_state { 521struct p_req_state {
510 struct p_header head; 522 struct p_header80 head;
511 u32 mask; 523 u32 mask;
512 u32 val; 524 u32 val;
513} __packed; 525} __packed;
514 526
515struct p_req_state_reply { 527struct p_req_state_reply {
516 struct p_header head; 528 struct p_header80 head;
517 u32 retcode; 529 u32 retcode;
518} __packed; 530} __packed;
519 531
@@ -528,7 +540,7 @@ struct p_drbd06_param {
528} __packed; 540} __packed;
529 541
530struct p_discard { 542struct p_discard {
531 struct p_header head; 543 struct p_header80 head;
532 u64 block_id; 544 u64 block_id;
533 u32 seq_num; 545 u32 seq_num;
534 u32 pad; 546 u32 pad;
@@ -544,7 +556,7 @@ enum drbd_bitmap_code {
544}; 556};
545 557
546struct p_compressed_bm { 558struct p_compressed_bm {
547 struct p_header head; 559 struct p_header80 head;
548 /* (encoding & 0x0f): actual encoding, see enum drbd_bitmap_code 560 /* (encoding & 0x0f): actual encoding, see enum drbd_bitmap_code
549 * (encoding & 0x80): polarity (set/unset) of first runlength 561 * (encoding & 0x80): polarity (set/unset) of first runlength
550 * ((encoding >> 4) & 0x07): pad_bits, number of trailing zero bits 562 * ((encoding >> 4) & 0x07): pad_bits, number of trailing zero bits
@@ -555,10 +567,10 @@ struct p_compressed_bm {
555 u8 code[0]; 567 u8 code[0];
556} __packed; 568} __packed;
557 569
558struct p_delay_probe { 570struct p_delay_probe93 {
559 struct p_header head; 571 struct p_header80 head;
560 u32 seq_num; /* sequence number to match the two probe packets */ 572 u32 seq_num; /* sequence number to match the two probe packets */
561 u32 offset; /* usecs the probe got sent after the reference time point */ 573 u32 offset; /* usecs the probe got sent after the reference time point */
562} __packed; 574} __packed;
563 575
564/* DCBP: Drbd Compressed Bitmap Packet ... */ 576/* DCBP: Drbd Compressed Bitmap Packet ... */
@@ -605,7 +617,7 @@ DCBP_set_pad_bits(struct p_compressed_bm *p, int n)
605 * so we need to use the fixed size 4KiB page size 617 * so we need to use the fixed size 4KiB page size
606 * most architechtures have used for a long time. 618 * most architechtures have used for a long time.
607 */ 619 */
608#define BM_PACKET_PAYLOAD_BYTES (4096 - sizeof(struct p_header)) 620#define BM_PACKET_PAYLOAD_BYTES (4096 - sizeof(struct p_header80))
609#define BM_PACKET_WORDS (BM_PACKET_PAYLOAD_BYTES/sizeof(long)) 621#define BM_PACKET_WORDS (BM_PACKET_PAYLOAD_BYTES/sizeof(long))
610#define BM_PACKET_VLI_BYTES_MAX (4096 - sizeof(struct p_compressed_bm)) 622#define BM_PACKET_VLI_BYTES_MAX (4096 - sizeof(struct p_compressed_bm))
611#if (PAGE_SIZE < 4096) 623#if (PAGE_SIZE < 4096)
@@ -614,7 +626,7 @@ DCBP_set_pad_bits(struct p_compressed_bm *p, int n)
614#endif 626#endif
615 627
616union p_polymorph { 628union p_polymorph {
617 struct p_header header; 629 struct p_header80 header;
618 struct p_handshake handshake; 630 struct p_handshake handshake;
619 struct p_data data; 631 struct p_data data;
620 struct p_block_ack block_ack; 632 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
1188extern int _drbd_send_state(struct drbd_conf *mdev); 1200extern int _drbd_send_state(struct drbd_conf *mdev);
1189extern int drbd_send_state(struct drbd_conf *mdev); 1201extern int drbd_send_state(struct drbd_conf *mdev);
1190extern int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock, 1202extern int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock,
1191 enum drbd_packets cmd, struct p_header *h, 1203 enum drbd_packets cmd, struct p_header80 *h,
1192 size_t size, unsigned msg_flags); 1204 size_t size, unsigned msg_flags);
1193#define USE_DATA_SOCKET 1 1205#define USE_DATA_SOCKET 1
1194#define USE_META_SOCKET 0 1206#define USE_META_SOCKET 0
1195extern int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket, 1207extern int drbd_send_cmd(struct drbd_conf *mdev, int use_data_socket,
1196 enum drbd_packets cmd, struct p_header *h, 1208 enum drbd_packets cmd, struct p_header80 *h,
1197 size_t size); 1209 size_t size);
1198extern int drbd_send_cmd2(struct drbd_conf *mdev, enum drbd_packets cmd, 1210extern int drbd_send_cmd2(struct drbd_conf *mdev, enum drbd_packets cmd,
1199 char *data, size_t size); 1211 char *data, size_t size);
@@ -1936,19 +1948,19 @@ static inline void request_ping(struct drbd_conf *mdev)
1936static inline int drbd_send_short_cmd(struct drbd_conf *mdev, 1948static inline int drbd_send_short_cmd(struct drbd_conf *mdev,
1937 enum drbd_packets cmd) 1949 enum drbd_packets cmd)
1938{ 1950{
1939 struct p_header h; 1951 struct p_header80 h;
1940 return drbd_send_cmd(mdev, USE_DATA_SOCKET, cmd, &h, sizeof(h)); 1952 return drbd_send_cmd(mdev, USE_DATA_SOCKET, cmd, &h, sizeof(h));
1941} 1953}
1942 1954
1943static inline int drbd_send_ping(struct drbd_conf *mdev) 1955static inline int drbd_send_ping(struct drbd_conf *mdev)
1944{ 1956{
1945 struct p_header h; 1957 struct p_header80 h;
1946 return drbd_send_cmd(mdev, USE_META_SOCKET, P_PING, &h, sizeof(h)); 1958 return drbd_send_cmd(mdev, USE_META_SOCKET, P_PING, &h, sizeof(h));
1947} 1959}
1948 1960
1949static inline int drbd_send_ping_ack(struct drbd_conf *mdev) 1961static inline int drbd_send_ping_ack(struct drbd_conf *mdev)
1950{ 1962{
1951 struct p_header h; 1963 struct p_header80 h;
1952 return drbd_send_cmd(mdev, USE_META_SOCKET, P_PING_ACK, &h, sizeof(h)); 1964 return drbd_send_cmd(mdev, USE_META_SOCKET, P_PING_ACK, &h, sizeof(h));
1953} 1965}
1954 1966