mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-14 14:42:34 -04:00
smb: server: make use of struct smbdirect_rw_io
This will allow us to create functions in the common smbdirect code to be used by the server in future. Cc: Namjae Jeon <linkinjeon@kernel.org> Cc: Steve French <smfrench@gmail.com> Cc: Tom Talpey <tom@talpey.com> Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Signed-off-by: Stefan Metzmacher <metze@samba.org> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
committed by
Steve French
parent
95475d8886
commit
780ccb0fb6
@@ -113,17 +113,6 @@ struct smb_direct_transport {
|
||||
|
||||
static const struct ksmbd_transport_ops ksmbd_smb_direct_transport_ops;
|
||||
|
||||
struct smb_direct_rdma_rw_msg {
|
||||
struct smb_direct_transport *t;
|
||||
struct ib_cqe cqe;
|
||||
int status;
|
||||
struct completion *completion;
|
||||
struct list_head list;
|
||||
struct rdma_rw_ctx rw_ctx;
|
||||
struct sg_table sgt;
|
||||
struct scatterlist sg_list[];
|
||||
};
|
||||
|
||||
void init_smbd_max_io_size(unsigned int sz)
|
||||
{
|
||||
sz = clamp_val(sz, SMBD_MIN_IOSIZE, SMBD_MAX_IOSIZE);
|
||||
@@ -1340,12 +1329,12 @@ static int smb_direct_writev(struct ksmbd_transport *t,
|
||||
}
|
||||
|
||||
static void smb_direct_free_rdma_rw_msg(struct smb_direct_transport *t,
|
||||
struct smb_direct_rdma_rw_msg *msg,
|
||||
struct smbdirect_rw_io *msg,
|
||||
enum dma_data_direction dir)
|
||||
{
|
||||
struct smbdirect_socket *sc = &t->socket;
|
||||
|
||||
rdma_rw_ctx_destroy(&msg->rw_ctx, sc->ib.qp, sc->ib.qp->port,
|
||||
rdma_rw_ctx_destroy(&msg->rdma_ctx, sc->ib.qp, sc->ib.qp->port,
|
||||
msg->sgt.sgl, msg->sgt.nents, dir);
|
||||
sg_free_table_chained(&msg->sgt, SG_CHUNK_SIZE);
|
||||
kfree(msg);
|
||||
@@ -1354,12 +1343,14 @@ static void smb_direct_free_rdma_rw_msg(struct smb_direct_transport *t,
|
||||
static void read_write_done(struct ib_cq *cq, struct ib_wc *wc,
|
||||
enum dma_data_direction dir)
|
||||
{
|
||||
struct smb_direct_rdma_rw_msg *msg = container_of(wc->wr_cqe,
|
||||
struct smb_direct_rdma_rw_msg, cqe);
|
||||
struct smb_direct_transport *t = msg->t;
|
||||
struct smbdirect_rw_io *msg =
|
||||
container_of(wc->wr_cqe, struct smbdirect_rw_io, cqe);
|
||||
struct smbdirect_socket *sc = msg->socket;
|
||||
struct smb_direct_transport *t =
|
||||
container_of(sc, struct smb_direct_transport, socket);
|
||||
|
||||
if (wc->status != IB_WC_SUCCESS) {
|
||||
msg->status = -EIO;
|
||||
msg->error = -EIO;
|
||||
pr_err("read/write error. opcode = %d, status = %s(%d)\n",
|
||||
wc->opcode, ib_wc_status_msg(wc->status), wc->status);
|
||||
if (wc->status != IB_WC_WR_FLUSH_ERR)
|
||||
@@ -1387,7 +1378,7 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t,
|
||||
{
|
||||
struct smbdirect_socket *sc = &t->socket;
|
||||
struct smbdirect_socket_parameters *sp = &sc->parameters;
|
||||
struct smb_direct_rdma_rw_msg *msg, *next_msg;
|
||||
struct smbdirect_rw_io *msg, *next_msg;
|
||||
int i, ret;
|
||||
DECLARE_COMPLETION_ONSTACK(completion);
|
||||
struct ib_send_wr *first_wr;
|
||||
@@ -1444,7 +1435,7 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t,
|
||||
|
||||
desc_buf_len = le32_to_cpu(desc[i].length);
|
||||
|
||||
msg->t = t;
|
||||
msg->socket = sc;
|
||||
msg->cqe.done = is_read ? read_done : write_done;
|
||||
msg->completion = &completion;
|
||||
|
||||
@@ -1466,7 +1457,7 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t,
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = rdma_rw_ctx_init(&msg->rw_ctx, sc->ib.qp, sc->ib.qp->port,
|
||||
ret = rdma_rw_ctx_init(&msg->rdma_ctx, sc->ib.qp, sc->ib.qp->port,
|
||||
msg->sgt.sgl,
|
||||
get_buf_page_count(desc_buf, desc_buf_len),
|
||||
0,
|
||||
@@ -1487,7 +1478,7 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t,
|
||||
/* concatenate work requests of rdma_rw_ctxs */
|
||||
first_wr = NULL;
|
||||
list_for_each_entry_reverse(msg, &msg_list, list) {
|
||||
first_wr = rdma_rw_ctx_wrs(&msg->rw_ctx, sc->ib.qp, sc->ib.qp->port,
|
||||
first_wr = rdma_rw_ctx_wrs(&msg->rdma_ctx, sc->ib.qp, sc->ib.qp->port,
|
||||
&msg->cqe, first_wr);
|
||||
}
|
||||
|
||||
@@ -1497,9 +1488,9 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t,
|
||||
goto out;
|
||||
}
|
||||
|
||||
msg = list_last_entry(&msg_list, struct smb_direct_rdma_rw_msg, list);
|
||||
msg = list_last_entry(&msg_list, struct smbdirect_rw_io, list);
|
||||
wait_for_completion(&completion);
|
||||
ret = msg->status;
|
||||
ret = msg->error;
|
||||
out:
|
||||
list_for_each_entry_safe(msg, next_msg, &msg_list, list) {
|
||||
list_del(&msg->list);
|
||||
|
||||
Reference in New Issue
Block a user