Skip to content

Commit 941f8d5

Browse files
RDS: RDMA: Fix the composite message user notification
When application sends an RDS RDMA composite message consist of RDMA transfer to be followed up by non RDMA payload, it expect to be notified *only* when the full message gets delivered. RDS RDMA notification doesn't behave this way though. Thanks to Venkat for debug and root casuing the issue where only first part of the message(RDMA) was successfully delivered but remainder payload delivery failed. In that case, application should not be notified with a false positive of message delivery success. Fix this case by making sure the user gets notified only after the full message delivery. Reviewed-by: Venkat Venkatsubra <[email protected]> Signed-off-by: Santosh Shilimkar <[email protected]>
1 parent be2f76e commit 941f8d5

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

net/rds/ib_send.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,6 @@ static void rds_ib_send_complete(struct rds_message *rm,
6969
complete(rm, notify_status);
7070
}
7171

72-
static void rds_ib_send_unmap_data(struct rds_ib_connection *ic,
73-
struct rm_data_op *op,
74-
int wc_status)
75-
{
76-
if (op->op_nents)
77-
ib_dma_unmap_sg(ic->i_cm_id->device,
78-
op->op_sg, op->op_nents,
79-
DMA_TO_DEVICE);
80-
}
81-
8272
static void rds_ib_send_unmap_rdma(struct rds_ib_connection *ic,
8373
struct rm_rdma_op *op,
8474
int wc_status)
@@ -139,6 +129,21 @@ static void rds_ib_send_unmap_atomic(struct rds_ib_connection *ic,
139129
rds_ib_stats_inc(s_ib_atomic_fadd);
140130
}
141131

132+
static void rds_ib_send_unmap_data(struct rds_ib_connection *ic,
133+
struct rm_data_op *op,
134+
int wc_status)
135+
{
136+
struct rds_message *rm = container_of(op, struct rds_message, data);
137+
138+
if (op->op_nents)
139+
ib_dma_unmap_sg(ic->i_cm_id->device,
140+
op->op_sg, op->op_nents,
141+
DMA_TO_DEVICE);
142+
143+
if (rm->rdma.op_active && rm->data.op_notify)
144+
rds_ib_send_unmap_rdma(ic, &rm->rdma, wc_status);
145+
}
146+
142147
/*
143148
* Unmap the resources associated with a struct send_work.
144149
*

net/rds/rdma.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,16 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm,
627627
}
628628
op->op_notifier->n_user_token = args->user_token;
629629
op->op_notifier->n_status = RDS_RDMA_SUCCESS;
630+
631+
/* Enable rmda notification on data operation for composite
632+
* rds messages and make sure notification is enabled only
633+
* for the data operation which follows it so that application
634+
* gets notified only after full message gets delivered.
635+
*/
636+
if (rm->data.op_sg) {
637+
rm->rdma.op_notify = 0;
638+
rm->data.op_notify = !!(args->flags & RDS_RDMA_NOTIFY_ME);
639+
}
630640
}
631641

632642
/* The cookie contains the R_Key of the remote memory region, and

net/rds/rds.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ struct rds_message {
419419
} rdma;
420420
struct rm_data_op {
421421
unsigned int op_active:1;
422+
unsigned int op_notify:1;
422423
unsigned int op_nents;
423424
unsigned int op_count;
424425
unsigned int op_dmasg;

net/rds/send.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,12 +476,14 @@ void rds_rdma_send_complete(struct rds_message *rm, int status)
476476
struct rm_rdma_op *ro;
477477
struct rds_notifier *notifier;
478478
unsigned long flags;
479+
unsigned int notify = 0;
479480

480481
spin_lock_irqsave(&rm->m_rs_lock, flags);
481482

483+
notify = rm->rdma.op_notify | rm->data.op_notify;
482484
ro = &rm->rdma;
483485
if (test_bit(RDS_MSG_ON_SOCK, &rm->m_flags) &&
484-
ro->op_active && ro->op_notify && ro->op_notifier) {
486+
ro->op_active && notify && ro->op_notifier) {
485487
notifier = ro->op_notifier;
486488
rs = rm->m_rs;
487489
sock_hold(rds_rs_to_sk(rs));

0 commit comments

Comments
 (0)