Skip to content

Commit 6a501bd

Browse files
SantoshShilimkargregkh
authored andcommitted
RDS: RDMA: Fix the composite message user notification
[ Upstream commit 941f8d55f6d613a460a5e080d25a38509f45eb75 ] 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 <venkat.x.venkatsubra@oracle.com> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d4f9744 commit 6a501bd

4 files changed

Lines changed: 29 additions & 11 deletions

File tree

net/rds/ib_send.c

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

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

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

net/rds/rdma.c

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

631641
/* 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
@@ -378,6 +378,7 @@ struct rds_message {
378378
} rdma;
379379
struct rm_data_op {
380380
unsigned int op_active:1;
381+
unsigned int op_notify:1;
381382
unsigned int op_nents;
382383
unsigned int op_count;
383384
unsigned int op_dmasg;

net/rds/send.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,12 +467,14 @@ void rds_rdma_send_complete(struct rds_message *rm, int status)
467467
struct rm_rdma_op *ro;
468468
struct rds_notifier *notifier;
469469
unsigned long flags;
470+
unsigned int notify = 0;
470471

471472
spin_lock_irqsave(&rm->m_rs_lock, flags);
472473

474+
notify = rm->rdma.op_notify | rm->data.op_notify;
473475
ro = &rm->rdma;
474476
if (test_bit(RDS_MSG_ON_SOCK, &rm->m_flags) &&
475-
ro->op_active && ro->op_notify && ro->op_notifier) {
477+
ro->op_active && notify && ro->op_notifier) {
476478
notifier = ro->op_notifier;
477479
rs = rm->m_rs;
478480
sock_hold(rds_rs_to_sk(rs));

0 commit comments

Comments
 (0)