fs/cifs: let smb2_new_read_req() split rdma channel info
authorStefan Metzmacher <metze@samba.org>
Tue, 8 Oct 2019 06:42:42 +0000 (08:42 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Oct 2022 22:58:58 +0000 (00:58 +0200)
For a single smbd_buffer_descriptor_v1 smb2_read_plain_req
provides enough space, but that will change in future.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
fs/cifs/cifsglob.h
fs/cifs/smb2pdu.c
fs/cifs/smbdirect.c
fs/cifs/smbdirect.h

index a3d1dfbc962364de285ae1c0a07c185403e6f0c4..b1cd3dcec93e556960c9e7b5934ffb5a3f96718d 100644 (file)
@@ -25,6 +25,7 @@
 #include <uapi/linux/cifs/cifs_mount.h>
 #include "../smbfs_common/smb2pdu.h"
 #include "smb2pdu.h"
+#include "smbdirect.h"
 
 #define SMB_PATH_MAX 260
 #define CIFS_PORT 445
@@ -1450,10 +1451,11 @@ struct cifs_readdata {
        int (*copy_into_pages)(struct TCP_Server_Info *server,
                                struct cifs_readdata *rdata,
                                struct iov_iter *iter);
-       struct kvec                     iov[2];
+       struct kvec                     iov[3];
        struct TCP_Server_Info          *server;
 #ifdef CONFIG_CIFS_SMB_DIRECT
        struct smbd_mr                  *mr;
+       struct smbd_buffer_descriptor_v1 smbd_v1;
 #endif
        bool                            using_rdma;
        unsigned int                    pagesz;
index 52f2f6a10ccdff1959bd4b5d5394230f09fb5d65..bce67ab7d4b9ab6e2c4aad0c0b2e8aae4e49f9bf 100644 (file)
@@ -4032,7 +4032,7 @@ smb2_new_read_req(struct kvec *iov, unsigned int *_num_iov,
        unsigned int total_len;
        unsigned int num_iov = 0;
 
-       BUG_ON(*_num_iov < 2);
+       BUG_ON(*_num_iov < 3);
        *_num_iov = 0;
 
        if (server == NULL)
@@ -4086,19 +4086,26 @@ smb2_new_read_req(struct kvec *iov, unsigned int *_num_iov,
                        cpu_to_le16(offsetof(struct smb2_read_req, Buffer));
                req->ReadChannelInfoLength =
                        cpu_to_le16(sizeof(struct smbd_buffer_descriptor_v1));
-               v1 = (struct smbd_buffer_descriptor_v1 *) &req->Buffer[0];
+               v1 = &rdata->smbd_v1;
                v1->offset = cpu_to_le64(rdata->mr->mr->iova);
                v1->token = cpu_to_le32(rdata->mr->mr->rkey);
                v1->length = cpu_to_le32(rdata->mr->mr->length);
 
+               total_len -= 1;
+               iov[1].iov_base = v1;
+               iov[1].iov_len = sizeof(*v1);
+               num_iov += 1;
+
                rdata->using_rdma = true;
-               total_len += sizeof(*v1) - 1;
        }
 #endif
        iov[0].iov_base = req;
        iov[0].iov_len = total_len;
        num_iov += 1;
 
+       if (num_iov > 1)
+               total_len += iov[1].iov_len;
+
        if (request_type & CHAINED_REQUEST) {
                if (!(request_type & END_OF_CHAIN)) {
                        unsigned int next_cmd;
@@ -4296,7 +4303,7 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
        int resp_buftype, rc;
        struct smb2_read_req *req = NULL;
        struct smb2_read_rsp *rsp = NULL;
-       struct kvec iov[2];
+       struct kvec iov[3];
        struct kvec rsp_iov;
        int flags = CIFS_LOG_ERROR;
        struct cifs_ses *ses = io_parms->tcon->ses;
index 5fbbec22bcc8ba4d33441cd7a256b483ec23e995..38000ef014964d7d437430f5874a2e2137777208 100644 (file)
@@ -6,6 +6,7 @@
  */
 #include <linux/module.h>
 #include <linux/highmem.h>
+#include "cifsglob.h"
 #include "smbdirect.h"
 #include "cifs_debug.h"
 #include "cifsproto.h"
index a87fca82a7963c56f3514256c0dda2f334bc6e7b..de530ee4b7bf3d7233790faa4845a3c315020585 100644 (file)
@@ -7,6 +7,9 @@
 #ifndef _SMBDIRECT_H
 #define _SMBDIRECT_H
 
+struct TCP_Server_Info;
+struct smb_rqst;
+
 #ifdef CONFIG_CIFS_SMB_DIRECT
 #define cifs_rdma_enabled(server)      ((server)->rdma)