Commit 1952e916 authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Philipp Reisner

drbd: Map from (connection, volume number) to device in the asender handlers

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent e05e1e59
...@@ -60,11 +60,6 @@ enum finish_epoch { ...@@ -60,11 +60,6 @@ enum finish_epoch {
FE_RECYCLED, FE_RECYCLED,
}; };
enum mdev_or_conn {
MDEV,
CONN,
};
static int drbd_do_handshake(struct drbd_tconn *tconn); static int drbd_do_handshake(struct drbd_tconn *tconn);
static int drbd_do_auth(struct drbd_tconn *tconn); static int drbd_do_auth(struct drbd_tconn *tconn);
static int drbd_disconnected(int vnr, void *p, void *data); static int drbd_disconnected(int vnr, void *p, void *data);
...@@ -4476,11 +4471,16 @@ static int got_conn_RqSReply(struct drbd_tconn *tconn, struct packet_info *pi) ...@@ -4476,11 +4471,16 @@ static int got_conn_RqSReply(struct drbd_tconn *tconn, struct packet_info *pi)
return true; return true;
} }
static int got_RqSReply(struct drbd_conf *mdev, struct packet_info *pi) static int got_RqSReply(struct drbd_tconn *tconn, struct packet_info *pi)
{ {
struct p_req_state_reply *p = mdev->tconn->meta.rbuf; struct drbd_conf *mdev;
struct p_req_state_reply *p = tconn->meta.rbuf;
int retcode = be32_to_cpu(p->retcode); int retcode = be32_to_cpu(p->retcode);
mdev = vnr_to_mdev(tconn, pi->vnr);
if (!mdev)
return false;
if (retcode >= SS_SUCCESS) { if (retcode >= SS_SUCCESS) {
set_bit(CL_ST_CHG_SUCCESS, &mdev->flags); set_bit(CL_ST_CHG_SUCCESS, &mdev->flags);
} else { } else {
...@@ -4509,12 +4509,17 @@ static int got_PingAck(struct drbd_tconn *tconn, struct packet_info *pi) ...@@ -4509,12 +4509,17 @@ static int got_PingAck(struct drbd_tconn *tconn, struct packet_info *pi)
return true; return true;
} }
static int got_IsInSync(struct drbd_conf *mdev, struct packet_info *pi) static int got_IsInSync(struct drbd_tconn *tconn, struct packet_info *pi)
{ {
struct p_block_ack *p = mdev->tconn->meta.rbuf; struct drbd_conf *mdev;
struct p_block_ack *p = tconn->meta.rbuf;
sector_t sector = be64_to_cpu(p->sector); sector_t sector = be64_to_cpu(p->sector);
int blksize = be32_to_cpu(p->blksize); int blksize = be32_to_cpu(p->blksize);
mdev = vnr_to_mdev(tconn, pi->vnr);
if (!mdev)
return false;
D_ASSERT(mdev->tconn->agreed_pro_version >= 89); D_ASSERT(mdev->tconn->agreed_pro_version >= 89);
update_peer_seq(mdev, be32_to_cpu(p->seq_num)); update_peer_seq(mdev, be32_to_cpu(p->seq_num));
...@@ -4554,13 +4559,18 @@ validate_req_change_req_state(struct drbd_conf *mdev, u64 id, sector_t sector, ...@@ -4554,13 +4559,18 @@ validate_req_change_req_state(struct drbd_conf *mdev, u64 id, sector_t sector,
return true; return true;
} }
static int got_BlockAck(struct drbd_conf *mdev, struct packet_info *pi) static int got_BlockAck(struct drbd_tconn *tconn, struct packet_info *pi)
{ {
struct p_block_ack *p = mdev->tconn->meta.rbuf; struct drbd_conf *mdev;
struct p_block_ack *p = tconn->meta.rbuf;
sector_t sector = be64_to_cpu(p->sector); sector_t sector = be64_to_cpu(p->sector);
int blksize = be32_to_cpu(p->blksize); int blksize = be32_to_cpu(p->blksize);
enum drbd_req_event what; enum drbd_req_event what;
mdev = vnr_to_mdev(tconn, pi->vnr);
if (!mdev)
return false;
update_peer_seq(mdev, be32_to_cpu(p->seq_num)); update_peer_seq(mdev, be32_to_cpu(p->seq_num));
if (p->block_id == ID_SYNCER) { if (p->block_id == ID_SYNCER) {
...@@ -4599,15 +4609,20 @@ static int got_BlockAck(struct drbd_conf *mdev, struct packet_info *pi) ...@@ -4599,15 +4609,20 @@ static int got_BlockAck(struct drbd_conf *mdev, struct packet_info *pi)
what, false); what, false);
} }
static int got_NegAck(struct drbd_conf *mdev, struct packet_info *pi) static int got_NegAck(struct drbd_tconn *tconn, struct packet_info *pi)
{ {
struct p_block_ack *p = mdev->tconn->meta.rbuf; struct drbd_conf *mdev;
struct p_block_ack *p = tconn->meta.rbuf;
sector_t sector = be64_to_cpu(p->sector); sector_t sector = be64_to_cpu(p->sector);
int size = be32_to_cpu(p->blksize); int size = be32_to_cpu(p->blksize);
bool missing_ok = mdev->tconn->net_conf->wire_protocol == DRBD_PROT_A || bool missing_ok = tconn->net_conf->wire_protocol == DRBD_PROT_A ||
mdev->tconn->net_conf->wire_protocol == DRBD_PROT_B; tconn->net_conf->wire_protocol == DRBD_PROT_B;
bool found; bool found;
mdev = vnr_to_mdev(tconn, pi->vnr);
if (!mdev)
return false;
update_peer_seq(mdev, be32_to_cpu(p->seq_num)); update_peer_seq(mdev, be32_to_cpu(p->seq_num));
if (p->block_id == ID_SYNCER) { if (p->block_id == ID_SYNCER) {
...@@ -4632,11 +4647,16 @@ static int got_NegAck(struct drbd_conf *mdev, struct packet_info *pi) ...@@ -4632,11 +4647,16 @@ static int got_NegAck(struct drbd_conf *mdev, struct packet_info *pi)
return true; return true;
} }
static int got_NegDReply(struct drbd_conf *mdev, struct packet_info *pi) static int got_NegDReply(struct drbd_tconn *tconn, struct packet_info *pi)
{ {
struct p_block_ack *p = mdev->tconn->meta.rbuf; struct drbd_conf *mdev;
struct p_block_ack *p = tconn->meta.rbuf;
sector_t sector = be64_to_cpu(p->sector); sector_t sector = be64_to_cpu(p->sector);
mdev = vnr_to_mdev(tconn, pi->vnr);
if (!mdev)
return false;
update_peer_seq(mdev, be32_to_cpu(p->seq_num)); update_peer_seq(mdev, be32_to_cpu(p->seq_num));
dev_err(DEV, "Got NegDReply; Sector %llus, len %u; Fail original request.\n", dev_err(DEV, "Got NegDReply; Sector %llus, len %u; Fail original request.\n",
...@@ -4647,11 +4667,16 @@ static int got_NegDReply(struct drbd_conf *mdev, struct packet_info *pi) ...@@ -4647,11 +4667,16 @@ static int got_NegDReply(struct drbd_conf *mdev, struct packet_info *pi)
NEG_ACKED, false); NEG_ACKED, false);
} }
static int got_NegRSDReply(struct drbd_conf *mdev, struct packet_info *pi) static int got_NegRSDReply(struct drbd_tconn *tconn, struct packet_info *pi)
{ {
struct drbd_conf *mdev;
sector_t sector; sector_t sector;
int size; int size;
struct p_block_ack *p = mdev->tconn->meta.rbuf; struct p_block_ack *p = tconn->meta.rbuf;
mdev = vnr_to_mdev(tconn, pi->vnr);
if (!mdev)
return false;
sector = be64_to_cpu(p->sector); sector = be64_to_cpu(p->sector);
size = be32_to_cpu(p->blksize); size = be32_to_cpu(p->blksize);
...@@ -4678,9 +4703,14 @@ static int got_NegRSDReply(struct drbd_conf *mdev, struct packet_info *pi) ...@@ -4678,9 +4703,14 @@ static int got_NegRSDReply(struct drbd_conf *mdev, struct packet_info *pi)
return true; return true;
} }
static int got_BarrierAck(struct drbd_conf *mdev, struct packet_info *pi) static int got_BarrierAck(struct drbd_tconn *tconn, struct packet_info *pi)
{ {
struct p_barrier_ack *p = mdev->tconn->meta.rbuf; struct drbd_conf *mdev;
struct p_barrier_ack *p = tconn->meta.rbuf;
mdev = vnr_to_mdev(tconn, pi->vnr);
if (!mdev)
return false;
tl_release(mdev->tconn, p->barrier, be32_to_cpu(p->set_size)); tl_release(mdev->tconn, p->barrier, be32_to_cpu(p->set_size));
...@@ -4694,13 +4724,18 @@ static int got_BarrierAck(struct drbd_conf *mdev, struct packet_info *pi) ...@@ -4694,13 +4724,18 @@ static int got_BarrierAck(struct drbd_conf *mdev, struct packet_info *pi)
return true; return true;
} }
static int got_OVResult(struct drbd_conf *mdev, struct packet_info *pi) static int got_OVResult(struct drbd_tconn *tconn, struct packet_info *pi)
{ {
struct p_block_ack *p = mdev->tconn->meta.rbuf; struct drbd_conf *mdev;
struct p_block_ack *p = tconn->meta.rbuf;
struct drbd_work *w; struct drbd_work *w;
sector_t sector; sector_t sector;
int size; int size;
mdev = vnr_to_mdev(tconn, pi->vnr);
if (!mdev)
return false;
sector = be64_to_cpu(p->sector); sector = be64_to_cpu(p->sector);
size = be32_to_cpu(p->blksize); size = be32_to_cpu(p->blksize);
...@@ -4739,7 +4774,7 @@ static int got_OVResult(struct drbd_conf *mdev, struct packet_info *pi) ...@@ -4739,7 +4774,7 @@ static int got_OVResult(struct drbd_conf *mdev, struct packet_info *pi)
return true; return true;
} }
static int got_skip(struct drbd_conf *mdev, struct packet_info *pi) static int got_skip(struct drbd_tconn *tconn, struct packet_info *pi)
{ {
return true; return true;
} }
...@@ -4772,31 +4807,27 @@ static int tconn_process_done_ee(struct drbd_tconn *tconn) ...@@ -4772,31 +4807,27 @@ static int tconn_process_done_ee(struct drbd_tconn *tconn)
struct asender_cmd { struct asender_cmd {
size_t pkt_size; size_t pkt_size;
enum mdev_or_conn fa_type; /* first argument's type */ int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
union {
int (*mdev_fn)(struct drbd_conf *mdev, struct packet_info *);
int (*conn_fn)(struct drbd_tconn *tconn, struct packet_info *);
};
}; };
static struct asender_cmd asender_tbl[] = { static struct asender_cmd asender_tbl[] = {
[P_PING] = { sizeof(struct p_header), CONN, { .conn_fn = got_Ping } }, [P_PING] = { sizeof(struct p_header), got_Ping },
[P_PING_ACK] = { sizeof(struct p_header), CONN, { .conn_fn = got_PingAck } }, [P_PING_ACK] = { sizeof(struct p_header), got_PingAck },
[P_RECV_ACK] = { sizeof(struct p_block_ack), MDEV, { got_BlockAck } }, [P_RECV_ACK] = { sizeof(struct p_block_ack), got_BlockAck },
[P_WRITE_ACK] = { sizeof(struct p_block_ack), MDEV, { got_BlockAck } }, [P_WRITE_ACK] = { sizeof(struct p_block_ack), got_BlockAck },
[P_RS_WRITE_ACK] = { sizeof(struct p_block_ack), MDEV, { got_BlockAck } }, [P_RS_WRITE_ACK] = { sizeof(struct p_block_ack), got_BlockAck },
[P_DISCARD_WRITE] = { sizeof(struct p_block_ack), MDEV, { got_BlockAck } }, [P_DISCARD_WRITE] = { sizeof(struct p_block_ack), got_BlockAck },
[P_NEG_ACK] = { sizeof(struct p_block_ack), MDEV, { got_NegAck } }, [P_NEG_ACK] = { sizeof(struct p_block_ack), got_NegAck },
[P_NEG_DREPLY] = { sizeof(struct p_block_ack), MDEV, { got_NegDReply } }, [P_NEG_DREPLY] = { sizeof(struct p_block_ack), got_NegDReply },
[P_NEG_RS_DREPLY] = { sizeof(struct p_block_ack), MDEV, { got_NegRSDReply } }, [P_NEG_RS_DREPLY] = { sizeof(struct p_block_ack), got_NegRSDReply },
[P_OV_RESULT] = { sizeof(struct p_block_ack), MDEV, { got_OVResult } }, [P_OV_RESULT] = { sizeof(struct p_block_ack), got_OVResult },
[P_BARRIER_ACK] = { sizeof(struct p_barrier_ack), MDEV, { got_BarrierAck } }, [P_BARRIER_ACK] = { sizeof(struct p_barrier_ack), got_BarrierAck },
[P_STATE_CHG_REPLY] = { sizeof(struct p_req_state_reply), MDEV, { got_RqSReply } }, [P_STATE_CHG_REPLY] = { sizeof(struct p_req_state_reply), got_RqSReply },
[P_RS_IS_IN_SYNC] = { sizeof(struct p_block_ack), MDEV, { got_IsInSync } }, [P_RS_IS_IN_SYNC] = { sizeof(struct p_block_ack), got_IsInSync },
[P_DELAY_PROBE] = { sizeof(struct p_delay_probe93), MDEV, { got_skip } }, [P_DELAY_PROBE] = { sizeof(struct p_delay_probe93), got_skip },
[P_RS_CANCEL] = { sizeof(struct p_block_ack), MDEV, { got_NegRSDReply } }, [P_RS_CANCEL] = { sizeof(struct p_block_ack), got_NegRSDReply },
[P_CONN_ST_CHG_REPLY]={ sizeof(struct p_req_state_reply), CONN, {.conn_fn = got_conn_RqSReply}}, [P_CONN_ST_CHG_REPLY]={ sizeof(struct p_req_state_reply), got_conn_RqSReply },
[P_RETRY_WRITE] = { sizeof(struct p_block_ack), MDEV, { got_BlockAck } }, [P_RETRY_WRITE] = { sizeof(struct p_block_ack), got_BlockAck },
}; };
int drbd_asender(struct drbd_thread *thi) int drbd_asender(struct drbd_thread *thi)
...@@ -4886,7 +4917,7 @@ int drbd_asender(struct drbd_thread *thi) ...@@ -4886,7 +4917,7 @@ int drbd_asender(struct drbd_thread *thi)
if (decode_header(tconn, h, &pi)) if (decode_header(tconn, h, &pi))
goto reconnect; goto reconnect;
cmd = &asender_tbl[pi.cmd]; cmd = &asender_tbl[pi.cmd];
if (pi.cmd >= ARRAY_SIZE(asender_tbl) || !cmd) { if (pi.cmd >= ARRAY_SIZE(asender_tbl) || !cmd->fn) {
conn_err(tconn, "unknown command %d on meta (l: %d)\n", conn_err(tconn, "unknown command %d on meta (l: %d)\n",
pi.cmd, pi.size); pi.cmd, pi.size);
goto disconnect; goto disconnect;
...@@ -4901,15 +4932,11 @@ int drbd_asender(struct drbd_thread *thi) ...@@ -4901,15 +4932,11 @@ int drbd_asender(struct drbd_thread *thi)
if (received == expect) { if (received == expect) {
bool rv; bool rv;
if (cmd->fa_type == CONN) { rv = cmd->fn(tconn, &pi);
rv = cmd->conn_fn(tconn, &pi); if (!rv) {
} else { conn_err(tconn, "%pf failed\n", cmd->fn);
struct drbd_conf *mdev = vnr_to_mdev(tconn, pi.vnr);
rv = cmd->mdev_fn(mdev, &pi);
}
if (!rv)
goto reconnect; goto reconnect;
}
tconn->last_received = jiffies; tconn->last_received = jiffies;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment