Skip to content

Commit b97f852

Browse files
Alexander Aringteigland
authored andcommitted
fs: dlm: implement delayed ack handling
This patch changes that we don't ack each message. Lowcomms will take care about to send an ack back after a bulk of messages was processed. Currently it's only when the whole receive buffer was processed, there might better positions to send an ack back but only the lowcomms implementation know when there are more data to receive. This patch has also disadvantages that we might retransmit more on errors, however this is a very rare case. Tested with make_panic on gfs2 with three nodes by running: trace-cmd record -p function -l 'dlm_send_ack' sleep 100 and trace-cmd report | wc -l Before patch: - 20548 - 21376 - 21398 After patch: - 18338 - 20679 - 19949 Signed-off-by: Alexander Aring <aahringo@redhat.com> Signed-off-by: David Teigland <teigland@redhat.com>
1 parent 62699b3 commit b97f852

3 files changed

Lines changed: 50 additions & 8 deletions

File tree

fs/dlm/lowcomms.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,7 @@ static int receive_from_sock(struct connection *con)
947947
}
948948
}
949949

950+
dlm_midcomms_receive_done(con->nodeid);
950951
mutex_unlock(&con->sock_mutex);
951952
return 0;
952953

fs/dlm/lowcomms.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ int dlm_lowcomms_resend_msg(struct dlm_msg *msg);
4646
int dlm_lowcomms_connect_node(int nodeid);
4747
int dlm_lowcomms_nodes_set_mark(int nodeid, unsigned int mark);
4848
int dlm_lowcomms_addr(int nodeid, struct sockaddr_storage *addr, int len);
49+
void dlm_midcomms_receive_done(int nodeid);
4950

5051
#endif /* __LOWCOMMS_DOT_H__ */
5152

fs/dlm/midcomms.c

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,6 @@
109109
* compatibility. There exists better ways to make a better handling.
110110
* However this should be changed in the next major version bump of dlm.
111111
*
112-
* Ack handling:
113-
*
114-
* Currently we send an ack message for every dlm message. However we
115-
* can ack multiple dlm messages with one ack by just delaying the ack
116-
* message. Will reduce some traffic but makes the drop detection slower.
117-
*
118112
* Tail Size checking:
119113
*
120114
* There exists a message tail payload in e.g. DLM_MSG however we don't
@@ -169,6 +163,7 @@ struct midcomms_node {
169163
#define DLM_NODE_FLAG_CLOSE 1
170164
#define DLM_NODE_FLAG_STOP_TX 2
171165
#define DLM_NODE_FLAG_STOP_RX 3
166+
#define DLM_NODE_ULP_DELIVERED 4
172167
unsigned long flags;
173168
wait_queue_head_t shutdown_wait;
174169

@@ -480,11 +475,12 @@ static void dlm_midcomms_receive_buffer(union dlm_packet *p,
480475
{
481476
if (seq == node->seq_next) {
482477
node->seq_next++;
483-
/* send ack before fin */
484-
dlm_send_ack(node->nodeid, node->seq_next);
485478

486479
switch (p->header.h_cmd) {
487480
case DLM_FIN:
481+
/* send ack before fin */
482+
dlm_send_ack(node->nodeid, node->seq_next);
483+
488484
spin_lock(&node->state_lock);
489485
pr_debug("receive fin msg from node %d with state %s\n",
490486
node->nodeid, dlm_state_str(node->state));
@@ -534,6 +530,7 @@ static void dlm_midcomms_receive_buffer(union dlm_packet *p,
534530
default:
535531
WARN_ON(test_bit(DLM_NODE_FLAG_STOP_RX, &node->flags));
536532
dlm_receive_buffer(p, node->nodeid);
533+
set_bit(DLM_NODE_ULP_DELIVERED, &node->flags);
537534
break;
538535
}
539536
} else {
@@ -933,6 +930,49 @@ int dlm_process_incoming_buffer(int nodeid, unsigned char *buf, int len)
933930
return ret;
934931
}
935932

933+
void dlm_midcomms_receive_done(int nodeid)
934+
{
935+
struct midcomms_node *node;
936+
int idx;
937+
938+
idx = srcu_read_lock(&nodes_srcu);
939+
node = nodeid2node(nodeid, 0);
940+
if (!node) {
941+
srcu_read_unlock(&nodes_srcu, idx);
942+
return;
943+
}
944+
945+
/* old protocol, we do nothing */
946+
switch (node->version) {
947+
case DLM_VERSION_3_2:
948+
break;
949+
default:
950+
srcu_read_unlock(&nodes_srcu, idx);
951+
return;
952+
}
953+
954+
/* do nothing if we didn't delivered stateful to ulp */
955+
if (!test_and_clear_bit(DLM_NODE_ULP_DELIVERED,
956+
&node->flags)) {
957+
srcu_read_unlock(&nodes_srcu, idx);
958+
return;
959+
}
960+
961+
spin_lock(&node->state_lock);
962+
/* we only ack if state is ESTABLISHED */
963+
switch (node->state) {
964+
case DLM_ESTABLISHED:
965+
spin_unlock(&node->state_lock);
966+
dlm_send_ack(node->nodeid, node->seq_next);
967+
break;
968+
default:
969+
spin_unlock(&node->state_lock);
970+
/* do nothing FIN has it's own ack send */
971+
break;
972+
};
973+
srcu_read_unlock(&nodes_srcu, idx);
974+
}
975+
936976
void dlm_midcomms_unack_msg_resend(int nodeid)
937977
{
938978
struct midcomms_node *node;

0 commit comments

Comments
 (0)