Skip to content

Commit 977ea06

Browse files
metze-sambasmfrench
authored andcommitted
smb: client: make use of struct smbdirect_send_io
The server will also use this soon, so that we can split out common helper functions in future. 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 92ac696 commit 977ea06

File tree

2 files changed

+23
-38
lines changed

2 files changed

+23
-38
lines changed

fs/smb/client/smbdirect.c

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ smbd_qp_async_error_upcall(struct ib_event *event, void *context)
255255
}
256256
}
257257

258-
static inline void *smbd_request_payload(struct smbd_request *request)
258+
static inline void *smbdirect_send_io_payload(struct smbdirect_send_io *request)
259259
{
260260
return (void *)request->packet;
261261
}
@@ -269,12 +269,13 @@ static inline void *smbdirect_recv_io_payload(struct smbdirect_recv_io *response
269269
static void send_done(struct ib_cq *cq, struct ib_wc *wc)
270270
{
271271
int i;
272-
struct smbd_request *request =
273-
container_of(wc->wr_cqe, struct smbd_request, cqe);
274-
struct smbd_connection *info = request->info;
275-
struct smbdirect_socket *sc = &info->socket;
272+
struct smbdirect_send_io *request =
273+
container_of(wc->wr_cqe, struct smbdirect_send_io, cqe);
274+
struct smbdirect_socket *sc = request->socket;
275+
struct smbd_connection *info =
276+
container_of(sc, struct smbd_connection, socket);
276277

277-
log_rdma_send(INFO, "smbd_request 0x%p completed wc->status=%d\n",
278+
log_rdma_send(INFO, "smbdirect_send_io 0x%p completed wc->status=%d\n",
278279
request, wc->status);
279280

280281
for (i = 0; i < request->num_sge; i++)
@@ -291,12 +292,12 @@ static void send_done(struct ib_cq *cq, struct ib_wc *wc)
291292
return;
292293
}
293294

294-
if (atomic_dec_and_test(&request->info->send_pending))
295-
wake_up(&request->info->wait_send_pending);
295+
if (atomic_dec_and_test(&info->send_pending))
296+
wake_up(&info->wait_send_pending);
296297

297-
wake_up(&request->info->wait_post_send);
298+
wake_up(&info->wait_post_send);
298299

299-
mempool_free(request, request->info->request_mempool);
300+
mempool_free(request, info->request_mempool);
300301
}
301302

302303
static void dump_smbdirect_negotiate_resp(struct smbdirect_negotiate_resp *resp)
@@ -688,16 +689,16 @@ static int smbd_post_send_negotiate_req(struct smbd_connection *info)
688689
struct smbdirect_socket_parameters *sp = &sc->parameters;
689690
struct ib_send_wr send_wr;
690691
int rc = -ENOMEM;
691-
struct smbd_request *request;
692+
struct smbdirect_send_io *request;
692693
struct smbdirect_negotiate_req *packet;
693694

694695
request = mempool_alloc(info->request_mempool, GFP_KERNEL);
695696
if (!request)
696697
return rc;
697698

698-
request->info = info;
699+
request->socket = sc;
699700

700-
packet = smbd_request_payload(request);
701+
packet = smbdirect_send_io_payload(request);
701702
packet->min_version = cpu_to_le16(SMBDIRECT_V1);
702703
packet->max_version = cpu_to_le16(SMBDIRECT_V1);
703704
packet->reserved = 0;
@@ -794,7 +795,7 @@ static int manage_keep_alive_before_sending(struct smbd_connection *info)
794795

795796
/* Post the send request */
796797
static int smbd_post_send(struct smbd_connection *info,
797-
struct smbd_request *request)
798+
struct smbdirect_send_io *request)
798799
{
799800
struct smbdirect_socket *sc = &info->socket;
800801
struct smbdirect_socket_parameters *sp = &sc->parameters;
@@ -843,7 +844,7 @@ static int smbd_post_send_iter(struct smbd_connection *info,
843844
int i, rc;
844845
int header_length;
845846
int data_length;
846-
struct smbd_request *request;
847+
struct smbdirect_send_io *request;
847848
struct smbdirect_data_transfer *packet;
848849
int new_credits = 0;
849850

@@ -888,14 +889,14 @@ static int smbd_post_send_iter(struct smbd_connection *info,
888889
goto err_alloc;
889890
}
890891

891-
request->info = info;
892+
request->socket = sc;
892893
memset(request->sge, 0, sizeof(request->sge));
893894

894895
/* Fill in the data payload to find out how much data we can add */
895896
if (iter) {
896897
struct smb_extract_to_rdma extract = {
897898
.nr_sge = 1,
898-
.max_sge = SMBDIRECT_MAX_SEND_SGE,
899+
.max_sge = SMBDIRECT_SEND_IO_MAX_SGE,
899900
.sge = request->sge,
900901
.device = sc->ib.dev,
901902
.local_dma_lkey = sc->ib.pd->local_dma_lkey,
@@ -917,7 +918,7 @@ static int smbd_post_send_iter(struct smbd_connection *info,
917918
}
918919

919920
/* Fill in the packet header */
920-
packet = smbd_request_payload(request);
921+
packet = smbdirect_send_io_payload(request);
921922
packet->credits_requested = cpu_to_le16(sp->send_credit_target);
922923

923924
new_credits = manage_credits_prior_sending(info);
@@ -1447,11 +1448,11 @@ static int allocate_caches_and_workqueue(struct smbd_connection *info)
14471448
if (WARN_ON_ONCE(sp->max_recv_size < sizeof(struct smbdirect_data_transfer)))
14481449
return -ENOMEM;
14491450

1450-
scnprintf(name, MAX_NAME_LEN, "smbd_request_%p", info);
1451+
scnprintf(name, MAX_NAME_LEN, "smbdirect_send_io_%p", info);
14511452
info->request_cache =
14521453
kmem_cache_create(
14531454
name,
1454-
sizeof(struct smbd_request) +
1455+
sizeof(struct smbdirect_send_io) +
14551456
sizeof(struct smbdirect_data_transfer),
14561457
0, SLAB_HWCACHE_ALIGN, NULL);
14571458
if (!info->request_cache)
@@ -1562,7 +1563,7 @@ static struct smbd_connection *_smbd_get_connection(
15621563
sp->max_recv_size = smbd_max_receive_size;
15631564
sp->keepalive_interval_msec = smbd_keep_alive_interval * 1000;
15641565

1565-
if (sc->ib.dev->attrs.max_send_sge < SMBDIRECT_MAX_SEND_SGE ||
1566+
if (sc->ib.dev->attrs.max_send_sge < SMBDIRECT_SEND_IO_MAX_SGE ||
15661567
sc->ib.dev->attrs.max_recv_sge < SMBDIRECT_RECV_IO_MAX_SGE) {
15671568
log_rdma_event(ERR,
15681569
"device %.*s max_send_sge/max_recv_sge = %d/%d too small\n",
@@ -1594,7 +1595,7 @@ static struct smbd_connection *_smbd_get_connection(
15941595
qp_attr.qp_context = info;
15951596
qp_attr.cap.max_send_wr = sp->send_credit_target;
15961597
qp_attr.cap.max_recv_wr = sp->recv_credit_max;
1597-
qp_attr.cap.max_send_sge = SMBDIRECT_MAX_SEND_SGE;
1598+
qp_attr.cap.max_send_sge = SMBDIRECT_SEND_IO_MAX_SGE;
15981599
qp_attr.cap.max_recv_sge = SMBDIRECT_RECV_IO_MAX_SGE;
15991600
qp_attr.cap.max_inline_data = 0;
16001601
qp_attr.sq_sig_type = IB_SIGNAL_REQ_WR;

fs/smb/client/smbdirect.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,22 +123,6 @@ struct smbd_connection {
123123
unsigned int count_send_empty;
124124
};
125125

126-
/* Maximum number of SGEs used by smbdirect.c in any send work request */
127-
#define SMBDIRECT_MAX_SEND_SGE 6
128-
129-
/* The context for a SMBD request */
130-
struct smbd_request {
131-
struct smbd_connection *info;
132-
struct ib_cqe cqe;
133-
134-
/* the SGE entries for this work request */
135-
struct ib_sge sge[SMBDIRECT_MAX_SEND_SGE];
136-
int num_sge;
137-
138-
/* SMBD packet header follows this structure */
139-
u8 packet[];
140-
};
141-
142126
/* Create a SMBDirect session */
143127
struct smbd_connection *smbd_get_connection(
144128
struct TCP_Server_Info *server, struct sockaddr *dstaddr);

0 commit comments

Comments
 (0)