[DRBD-cvs] drbd by phil; [patch by LGE] * pad in Param_Packet may...
drbd-user@lists.linbit.com
drbd-user@lists.linbit.com
Fri, 9 Jul 2004 14:08:04 +0200 (CEST)
DRBD CVS committal
Author : phil
Module : drbd
Dir : drbd/drbd
Modified Files:
Tag: rel-0_7-branch
drbd_int.h drbd_main.c drbd_receiver.c
Log Message:
[patch by LGE]
* pad in Param_Packet may as well be magic
* fix several comment typos
* added a few FIXME comments
* give more verbose reason if we are going to StandAlone
in receive_param()
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/drbd/drbd_int.h,v
retrieving revision 1.58.2.185
retrieving revision 1.58.2.186
diff -u -3 -r1.58.2.185 -r1.58.2.186
--- drbd_int.h 6 Jul 2004 09:39:11 -0000 1.58.2.185
+++ drbd_int.h 9 Jul 2004 12:07:59 -0000 1.58.2.186
@@ -398,7 +398,7 @@
* which just echoes them as received.)
*
* NOTE that the payload starts at a long aligned offset,
- * regardless off 32 or 64 bit arch!
+ * regardless of 32 or 64 bit arch!
*/
typedef struct {
u32 magic;
@@ -437,7 +437,7 @@
u64 sector;
u64 block_id;
u32 blksize;
- u32 pad; //make sure packes it is a multiple of 8 Byte
+ u32 pad; //make sure packet is a multiple of 8 Byte
} Drbd_BlockAck_Packet __attribute((packed));
typedef struct {
@@ -445,7 +445,7 @@
u64 sector;
u64 block_id;
u32 blksize;
- u32 pad; //make sure packes it is a multiple of 8 Byte
+ u32 pad; //make sure packet is a multiple of 8 Byte
} Drbd_BlockRequest_Packet __attribute((packed));
/*
@@ -458,7 +458,7 @@
typedef struct {
Drbd_Header head;
u32 barrier; // may be 0 or a barrier number
- u32 pad; //make sure packes it is a multiple of 8 Byte
+ u32 pad; //make sure packet is a multiple of 8 Byte
} Drbd_Barrier_Packet __attribute((packed));
typedef struct {
@@ -475,6 +475,8 @@
u32 group;
} Drbd_SyncParam_Packet __attribute((packed));
+/* FIXME add more members here, until we introduce a new fixed size
+ * protocol version handshake packet! */
typedef struct {
Drbd_Header head;
u64 p_size; // size of disk
@@ -487,10 +489,20 @@
u32 sync_use_csums;
u32 skip_sync;
u32 sync_group;
- u32 flags; // flags & 1 -> reply call drbd_send_param(mdev);
- u32 pad; //make sure packes it is a multiple of 8 Byte
+ u32 flags; // flags & 1 -> reply call drbd_send_param(mdev);
+ u32 magic; //make sure packet is a multiple of 8 Byte
} Drbd_Parameter_Packet __attribute((packed));
+typedef struct {
+ u64 size;
+ u32 state;
+ u32 blksize;
+ u32 protocol;
+ u32 version;
+ u32 gen_cnt[5];
+ u32 bit_map_gen[5];
+} Drbd06_Parameter_P __attribute((packed));
+
typedef union {
Drbd_Header head;
Drbd_Data_Packet Data;
@@ -699,8 +711,8 @@
unsigned int al_writ_cnt;
unsigned int bm_writ_cnt;
atomic_t ap_bio_cnt; // Requests we need to complete
- atomic_t ap_pending_cnt; // AP data packes on the wire, ack expected
- atomic_t rs_pending_cnt; // RS request/data packes onthe wire
+ atomic_t ap_pending_cnt; // AP data packets on the wire, ack expected
+ atomic_t rs_pending_cnt; // RS request/data packets on the wire
atomic_t unacked_cnt; // Need to send replys for
atomic_t local_cnt; // Waiting for local disk to signal completion
spinlock_t req_lock;
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/drbd/drbd_main.c,v
retrieving revision 1.73.2.199
retrieving revision 1.73.2.200
diff -u -3 -r1.73.2.199 -r1.73.2.200
--- drbd_main.c 6 Jul 2004 09:39:11 -0000 1.73.2.199
+++ drbd_main.c 9 Jul 2004 12:07:59 -0000 1.73.2.200
@@ -702,6 +702,7 @@
p.skip_sync = cpu_to_be32(mdev->sync_conf.skip);
p.sync_group = cpu_to_be32(mdev->sync_conf.group);
p.flags = cpu_to_be32(flags);
+ p.magic = BE_DRBD_MAGIC;
ok = drbd_send_cmd(mdev,mdev->data.socket,ReportParams,(Drbd_Header*)&p,sizeof(p));
if (have_disk) dec_local(mdev);
@@ -1620,6 +1621,7 @@
SZO(Drbd_BarrierAck_Packet);
SZO(Drbd_SyncParam_Packet);
SZO(Drbd_Parameter_Packet);
+ SZO(Drbd06_Parameter_P);
SZO(Drbd_Data_Packet);
SZO(Drbd_BlockAck_Packet);
printk(KERN_ERR "AL_EXTENTS_PT = %d\n",AL_EXTENTS_PT);
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/drbd/drbd_receiver.c,v
retrieving revision 1.97.2.178
retrieving revision 1.97.2.179
diff -u -3 -r1.97.2.178 -r1.97.2.179
--- drbd_receiver.c 6 Jul 2004 09:39:11 -0000 1.97.2.178
+++ drbd_receiver.c 9 Jul 2004 12:07:59 -0000 1.97.2.179
@@ -1304,27 +1304,73 @@
int oo_state;
unsigned long p_size;
- ERR_IF(h->length != (sizeof(*p)-sizeof(*h))) return FALSE;
+ /* FIXME never change the size of the first handshake packet again.
+ * I think we should introduce a protocol version handshake
+ * independently of the other parameters. */
+
+ /* we expect 72 byte.
+ * unfortunately h->length of drbd-0.6 Parameter_Packet is 72, too,
+ * but it includes the header size itself, so there are only 64 byte
+ * remaining...
+ */
+ if (h->length != (sizeof(*p)-sizeof(*h))) {
+ ERR("Incompatible packet size of Parameter packet!\n");
+ set_cstate(mdev,StandAlone);
+ drbd_thread_stop_nowait(&mdev->receiver);
+ return FALSE;
+ }
+ /* FIXME. If this connects to some drbd 0.6.X, it will timeout,
+ * and reconnect, in a loop, forever. annoying!
+ * maybe we want to change the on-the-wire-magic?
+ */
if (drbd_recv(mdev, h->payload, h->length) != h->length)
return FALSE;
- if(be32_to_cpu(p->state) == Primary && mdev->state == Primary ) {
- ERR("incompatible states\n");
+ if (p->magic != BE_DRBD_MAGIC) {
+ ERR("invalid Parameter_Packet magic! Protocol version: me %d, peer %d\n",
+ PRO_VERSION, be32_to_cpu(p->version));
set_cstate(mdev,StandAlone);
drbd_thread_stop_nowait(&mdev->receiver);
return FALSE;
}
if(be32_to_cpu(p->version)!=PRO_VERSION) {
- ERR("incompatible releases\n");
+ ERR("incompatible releases! Protocol version: me %d, peer %d\n",
+ PRO_VERSION, be32_to_cpu(p->version));
+ set_cstate(mdev,StandAlone);
+ drbd_thread_stop_nowait(&mdev->receiver);
+ return FALSE;
+ }
+
+ oo_state = be32_to_cpu(p->state);
+ if (oo_state != Primary && oo_state != Secondary) {
+ ERR("unexpected peer state: 0x%x\n", oo_state);
+ set_cstate(mdev,StandAlone);
+ drbd_thread_stop_nowait(&mdev->receiver);
+ return FALSE;
+ }
+
+ if(be32_to_cpu(p->state) == Primary && mdev->state == Primary ) {
+ ERR("incompatible states (both Primary!)\n");
set_cstate(mdev,StandAlone);
drbd_thread_stop_nowait(&mdev->receiver);
return FALSE;
}
if(be32_to_cpu(p->protocol)!=mdev->conf.wire_protocol) {
- ERR("incompatible protocols\n");
+ int peer_proto = be32_to_cpu(p->protocol);
+ if (DRBD_PROT_A <= peer_proto && peer_proto <= DRBD_PROT_C) {
+ ERR("incompatible communication protocols: "
+ "me %c, peer %c\n",
+ 'A'-1+mdev->conf.wire_protocol,
+ 'A'-1+peer_proto);
+ } else {
+ ERR("incompatible communication protocols: "
+ "me %c, peer [%d]\n",
+ 'A'-1+mdev->conf.wire_protocol,
+ peer_proto);
+ }
set_cstate(mdev,StandAlone);
drbd_thread_stop_nowait(&mdev->receiver);
return FALSE;
@@ -1333,6 +1379,8 @@
p_size=be64_to_cpu(p->p_size);
if(p_size == 0 && test_bit(DISKLESS,&mdev->flags)) {
+ /* FIXME maybe allow connection,
+ * but refuse to become primary? */
ERR("some backing storage is needed\n");
set_cstate(mdev,StandAlone);
drbd_thread_stop_nowait(&mdev->receiver);
@@ -1425,7 +1473,6 @@
}
if (mdev->cstate == WFReportParams) set_cstate(mdev,Connected);
- // see above. if (p_size && mdev->cstate==Connected) clear_bit(PARTNER_DISKLESS,&mdev->flags);
oo_state = mdev->o_state;
mdev->o_state = be32_to_cpu(p->state);
@@ -1644,6 +1691,10 @@
ERR("unknown packet type %d, l: %d!\n",
header->command, header->length);
break;
+ }
+ if (mdev->cstate == WFReportParams && header->command != ReportParams) {
+ ERR("received %s packet while WFReportParams!?\n",
+ cmdname(header->command));
}
if (unlikely(!handler(mdev,header))) {
ERR("error receiving %s, l: %d!\n",