Skip to content

Commit bbdbd9a

Browse files
metze-sambasmfrench
authored andcommitted
smb: client: make use of smbdirect_socket->recv_io.expected
The expected incoming message type can be per connection. Cc: Steve French <[email protected]> Cc: Tom Talpey <[email protected]> Cc: Long Li <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Stefan Metzmacher <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 33dd53a commit bbdbd9a

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

fs/smb/client/smbdirect.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ static bool process_negotiation_response(
383383
info->max_frmr_depth * PAGE_SIZE);
384384
info->max_frmr_depth = sp->max_read_write_size / PAGE_SIZE;
385385

386+
sc->recv_io.expected = SMBDIRECT_EXPECT_DATA_TRANSFER;
386387
return true;
387388
}
388389

@@ -408,7 +409,6 @@ static void smbd_post_send_credits(struct work_struct *work)
408409
if (!response)
409410
break;
410411

411-
response->type = SMBD_TRANSFER_DATA;
412412
response->first_segment = false;
413413
rc = smbd_post_recv(info, response);
414414
if (rc) {
@@ -445,10 +445,11 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
445445
struct smbd_response *response =
446446
container_of(wc->wr_cqe, struct smbd_response, cqe);
447447
struct smbd_connection *info = response->info;
448+
struct smbdirect_socket *sc = &info->socket;
448449
int data_length = 0;
449450

450451
log_rdma_recv(INFO, "response=0x%p type=%d wc status=%d wc opcode %d byte_len=%d pkey_index=%u\n",
451-
response, response->type, wc->status, wc->opcode,
452+
response, sc->recv_io.expected, wc->status, wc->opcode,
452453
wc->byte_len, wc->pkey_index);
453454

454455
if (wc->status != IB_WC_SUCCESS || wc->opcode != IB_WC_RECV) {
@@ -463,9 +464,9 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
463464
response->sge.length,
464465
DMA_FROM_DEVICE);
465466

466-
switch (response->type) {
467+
switch (sc->recv_io.expected) {
467468
/* SMBD negotiation response */
468-
case SMBD_NEGOTIATE_RESP:
469+
case SMBDIRECT_EXPECT_NEGOTIATE_REP:
469470
dump_smbdirect_negotiate_resp(smbd_response_payload(response));
470471
info->full_packet_received = true;
471472
info->negotiate_done =
@@ -475,7 +476,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
475476
return;
476477

477478
/* SMBD data transfer packet */
478-
case SMBD_TRANSFER_DATA:
479+
case SMBDIRECT_EXPECT_DATA_TRANSFER:
479480
data_transfer = smbd_response_payload(response);
480481
data_length = le32_to_cpu(data_transfer->data_length);
481482

@@ -526,13 +527,17 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
526527
put_receive_buffer(info, response);
527528

528529
return;
530+
531+
case SMBDIRECT_EXPECT_NEGOTIATE_REQ:
532+
/* Only server... */
533+
break;
529534
}
530535

531536
/*
532537
* This is an internal error!
533538
*/
534-
log_rdma_recv(ERR, "unexpected response type=%d\n", response->type);
535-
WARN_ON_ONCE(response->type != SMBD_TRANSFER_DATA);
539+
log_rdma_recv(ERR, "unexpected response type=%d\n", sc->recv_io.expected);
540+
WARN_ON_ONCE(sc->recv_io.expected != SMBDIRECT_EXPECT_DATA_TRANSFER);
536541
error:
537542
put_receive_buffer(info, response);
538543
smbd_disconnect_rdma_connection(info);
@@ -1067,10 +1072,11 @@ static int smbd_post_recv(
10671072
/* Perform SMBD negotiate according to [MS-SMBD] 3.1.5.2 */
10681073
static int smbd_negotiate(struct smbd_connection *info)
10691074
{
1075+
struct smbdirect_socket *sc = &info->socket;
10701076
int rc;
10711077
struct smbd_response *response = get_receive_buffer(info);
10721078

1073-
response->type = SMBD_NEGOTIATE_RESP;
1079+
sc->recv_io.expected = SMBDIRECT_EXPECT_NEGOTIATE_REP;
10741080
rc = smbd_post_recv(info, response);
10751081
log_rdma_event(INFO, "smbd_post_recv rc=%d iov.addr=0x%llx iov.length=%u iov.lkey=0x%x\n",
10761082
rc, response->sge.addr,

fs/smb/client/smbdirect.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,6 @@ struct smbd_connection {
156156
unsigned int count_send_empty;
157157
};
158158

159-
enum smbd_message_type {
160-
SMBD_NEGOTIATE_RESP,
161-
SMBD_TRANSFER_DATA,
162-
};
163-
164159
/* Maximum number of SGEs used by smbdirect.c in any send work request */
165160
#define SMBDIRECT_MAX_SEND_SGE 6
166161

@@ -186,8 +181,6 @@ struct smbd_response {
186181
struct ib_cqe cqe;
187182
struct ib_sge sge;
188183

189-
enum smbd_message_type type;
190-
191184
/* Link to receive queue or reassembly queue */
192185
struct list_head list;
193186

0 commit comments

Comments
 (0)