smb: client: let recv_done() cleanup before notifying the callers.

We should call put_receive_buffer() before waking up the callers.

For the internal error case of response->type being unexpected,
we now also call smbd_disconnect_rdma_connection() instead
of not waking up the callers at all.

Note that the SMBD_TRANSFER_DATA case still has problems,
which will be addressed in the next commit in order to make
it easier to review this one.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Fixes: f198186aa9 ("CIFS: SMBD: Establish SMB Direct connection")
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
Stefan Metzmacher 2025-08-04 14:10:15 +02:00 committed by Steve French
parent 047682c370
commit bdd7afc6dc

View File

@ -454,7 +454,6 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
if (wc->status != IB_WC_SUCCESS || wc->opcode != IB_WC_RECV) { if (wc->status != IB_WC_SUCCESS || wc->opcode != IB_WC_RECV) {
log_rdma_recv(INFO, "wc->status=%d opcode=%d\n", log_rdma_recv(INFO, "wc->status=%d opcode=%d\n",
wc->status, wc->opcode); wc->status, wc->opcode);
smbd_disconnect_rdma_connection(info);
goto error; goto error;
} }
@ -471,8 +470,9 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
info->full_packet_received = true; info->full_packet_received = true;
info->negotiate_done = info->negotiate_done =
process_negotiation_response(response, wc->byte_len); process_negotiation_response(response, wc->byte_len);
put_receive_buffer(info, response);
complete(&info->negotiate_completion); complete(&info->negotiate_completion);
break; return;
/* SMBD data transfer packet */ /* SMBD data transfer packet */
case SMBD_TRANSFER_DATA: case SMBD_TRANSFER_DATA:
@ -529,14 +529,16 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
} }
return; return;
default:
log_rdma_recv(ERR,
"unexpected response type=%d\n", response->type);
} }
/*
* This is an internal error!
*/
log_rdma_recv(ERR, "unexpected response type=%d\n", response->type);
WARN_ON_ONCE(response->type != SMBD_TRANSFER_DATA);
error: error:
put_receive_buffer(info, response); put_receive_buffer(info, response);
smbd_disconnect_rdma_connection(info);
} }
static struct rdma_cm_id *smbd_create_id( static struct rdma_cm_id *smbd_create_id(