Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 345983
b: refs/heads/master
c: 52b061a
h: refs/heads/master
i:
  345981: 9831583
  345979: 5d4adc0
  345975: fb2cc31
  345967: d523e1b
  345951: 5c3b7f2
  345919: 9dc3f12
  345855: 7dcdeb1
v: v3
  • Loading branch information
Andreas Gruenbacher authored and Philipp Reisner committed Nov 8, 2012
1 parent 0292d12 commit 0fa6f10
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 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: dba58587506818211b042c7b6a37f73e0feb8862
refs/heads/master: 52b061a44021ca11ee2fd238040e91341ff8066d
2 changes: 2 additions & 0 deletions trunk/drivers/block/drbd/drbd_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ struct p_header {
u8 payload[0];
};

extern unsigned int drbd_header_size(struct drbd_tconn *tconn);

/*
* short commands, packets without payload, plain p_header:
* P_PING
Expand Down
14 changes: 14 additions & 0 deletions trunk/drivers/block/drbd/drbd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,20 @@ void drbd_thread_current_set_cpu(struct drbd_thread *thi)
}
#endif

/**
* drbd_header_size - size of a packet header
*
* The header size is a multiple of 8, so any payload following the header is
* word aligned on 64-bit architectures. (The bitmap send and receive code
* relies on this.)
*/
unsigned int drbd_header_size(struct drbd_tconn *tconn)
{
BUILD_BUG_ON(sizeof(struct p_header80) != sizeof(struct p_header95));
BUILD_BUG_ON(!IS_ALIGNED(sizeof(struct p_header80), 8));
return sizeof(struct p_header80);
}

static void prepare_header80(struct p_header80 *h, enum drbd_packet cmd, int size)
{
h->magic = cpu_to_be32(DRBD_MAGIC);
Expand Down
9 changes: 5 additions & 4 deletions trunk/drivers/block/drbd/drbd_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ static int drbd_recv_header(struct drbd_tconn *tconn, struct packet_info *pi)
struct p_header *h = tconn->data.rbuf;
int err;

err = drbd_recv_all_warn(tconn, h, sizeof(*h));
err = drbd_recv_all_warn(tconn, h, drbd_header_size(tconn));
if (err)
return err;

Expand Down Expand Up @@ -4842,7 +4842,8 @@ int drbd_asender(struct drbd_thread *thi)
int rv;
void *buf = h;
int received = 0;
int expect = sizeof(struct p_header);
unsigned int header_size = drbd_header_size(tconn);
int expect = header_size;
int ping_timeout_active = 0;

current->policy = SCHED_RR; /* Make this a realtime task! */
Expand Down Expand Up @@ -4926,7 +4927,7 @@ int drbd_asender(struct drbd_thread *thi)
goto disconnect;
}
expect = cmd->pkt_size;
if (pi.size != expect - sizeof(struct p_header)) {
if (pi.size != expect - header_size) {
conn_err(tconn, "Wrong packet size on meta (c: %d, l: %d)\n",
pi.cmd, pi.size);
goto reconnect;
Expand All @@ -4950,7 +4951,7 @@ int drbd_asender(struct drbd_thread *thi)

buf = h;
received = 0;
expect = sizeof(struct p_header);
expect = header_size;
cmd = NULL;
}
}
Expand Down

0 comments on commit 0fa6f10

Please sign in to comment.