]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: client: make use of smbdirect_socket_parameters.max_frmr_depth
authorStefan Metzmacher <metze@samba.org>
Thu, 21 Aug 2025 22:32:34 +0000 (00:32 +0200)
committerSteve French <stfrench@microsoft.com>
Sun, 28 Sep 2025 23:29:50 +0000 (18:29 -0500)
This make it easier to have common code later.

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
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cifs_debug.c
fs/smb/client/file.c
fs/smb/client/smbdirect.c
fs/smb/client/smbdirect.h

index 9c9f15871c239573152a8c288049995de52f0b69..72d1ae56290fe0d081808716cd1866aa40c3d6be 100644 (file)
@@ -501,7 +501,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
                seq_printf(m, "\nMR responder_resources: %u "
                        "max_frmr_depth: %u mr_type: 0x%x",
                        sp->responder_resources,
-                       server->smbd_conn->max_frmr_depth,
+                       sp->max_frmr_depth,
                        server->smbd_conn->mr_type);
                seq_printf(m, "\nMR mr_ready_count: %u mr_used_count: %u",
                        atomic_read(&server->smbd_conn->mr_ready_count),
index cb907e18cc3589ea59adc7b10bf4e540352895dd..a5ed742afa007a9f8b250f3c5c73a06f302df2b2 100644 (file)
@@ -97,8 +97,12 @@ retry:
                              cifs_trace_rw_credits_write_prepare);
 
 #ifdef CONFIG_CIFS_SMB_DIRECT
-       if (server->smbd_conn)
-               stream->sreq_max_segs = server->smbd_conn->max_frmr_depth;
+       if (server->smbd_conn) {
+               const struct smbdirect_socket_parameters *sp =
+                       smbd_get_parameters(server->smbd_conn);
+
+               stream->sreq_max_segs = sp->max_frmr_depth;
+       }
 #endif
 }
 
@@ -187,8 +191,12 @@ static int cifs_prepare_read(struct netfs_io_subrequest *subreq)
                              cifs_trace_rw_credits_read_submit);
 
 #ifdef CONFIG_CIFS_SMB_DIRECT
-       if (server->smbd_conn)
-               rreq->io_streams[0].sreq_max_segs = server->smbd_conn->max_frmr_depth;
+       if (server->smbd_conn) {
+               const struct smbdirect_socket_parameters *sp =
+                       smbd_get_parameters(server->smbd_conn);
+
+               rreq->io_streams[0].sreq_max_segs = sp->max_frmr_depth;
+       }
 #endif
        return 0;
 }
index 138d8837a123159823591e5fef6e447afd610f9b..f85c14261c59471618381b5647450a0b5114723c 100644 (file)
@@ -472,8 +472,6 @@ static bool process_negotiation_response(
                struct smbdirect_recv_io *response, int packet_length)
 {
        struct smbdirect_socket *sc = response->socket;
-       struct smbd_connection *info =
-               container_of(sc, struct smbd_connection, socket);
        struct smbdirect_socket_parameters *sp = &sc->parameters;
        struct smbdirect_negotiate_resp *packet = smbdirect_recv_io_payload(response);
 
@@ -529,8 +527,8 @@ static bool process_negotiation_response(
 
        sp->max_read_write_size = min_t(u32,
                        le32_to_cpu(packet->max_readwrite_size),
-                       info->max_frmr_depth * PAGE_SIZE);
-       info->max_frmr_depth = sp->max_read_write_size / PAGE_SIZE;
+                       sp->max_frmr_depth * PAGE_SIZE);
+       sp->max_frmr_depth = sp->max_read_write_size / PAGE_SIZE;
 
        sc->recv_io.expected = SMBDIRECT_EXPECT_DATA_TRANSFER;
        return true;
@@ -837,6 +835,7 @@ static int smbd_ia_open(
                struct sockaddr *dstaddr, int port)
 {
        struct smbdirect_socket *sc = &info->socket;
+       struct smbdirect_socket_parameters *sp = &sc->parameters;
        int rc;
 
        WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_CREATED);
@@ -857,8 +856,8 @@ static int smbd_ia_open(
                rc = -EPROTONOSUPPORT;
                goto out2;
        }
-       info->max_frmr_depth = min_t(int,
-               smbd_max_frmr_depth,
+       sp->max_frmr_depth = min_t(u32,
+               sp->max_frmr_depth,
                sc->ib.dev->attrs.max_fast_reg_page_list_len);
        info->mr_type = IB_MR_TYPE_MEM_REG;
        if (sc->ib.dev->attrs.kernel_cap_flags & IBK_SG_GAPS_REG)
@@ -1770,6 +1769,7 @@ static struct smbd_connection *_smbd_get_connection(
        sp->max_send_size = smbd_max_send_size;
        sp->max_fragmented_recv_size = smbd_max_fragmented_recv_size;
        sp->max_recv_size = smbd_max_receive_size;
+       sp->max_frmr_depth = smbd_max_frmr_depth;
        sp->keepalive_interval_msec = smbd_keep_alive_interval * 1000;
        sp->keepalive_timeout_msec = KEEPALIVE_RECV_TIMEOUT * 1000;
 
@@ -2255,6 +2255,7 @@ static void smbd_mr_recovery_work(struct work_struct *work)
        struct smbd_connection *info =
                container_of(work, struct smbd_connection, mr_recovery_work);
        struct smbdirect_socket *sc = &info->socket;
+       struct smbdirect_socket_parameters *sp = &sc->parameters;
        struct smbdirect_mr_io *smbdirect_mr;
        int rc;
 
@@ -2273,11 +2274,11 @@ static void smbd_mr_recovery_work(struct work_struct *work)
 
                        smbdirect_mr->mr = ib_alloc_mr(
                                sc->ib.pd, info->mr_type,
-                               info->max_frmr_depth);
+                               sp->max_frmr_depth);
                        if (IS_ERR(smbdirect_mr->mr)) {
                                log_rdma_mr(ERR, "ib_alloc_mr failed mr_type=%x max_frmr_depth=%x\n",
                                            info->mr_type,
-                                           info->max_frmr_depth);
+                                           sp->max_frmr_depth);
                                smbd_disconnect_rdma_connection(info);
                                continue;
                        }
@@ -2348,13 +2349,13 @@ static int allocate_mr_list(struct smbd_connection *info)
                if (!smbdirect_mr)
                        goto cleanup_entries;
                smbdirect_mr->mr = ib_alloc_mr(sc->ib.pd, info->mr_type,
-                                       info->max_frmr_depth);
+                                       sp->max_frmr_depth);
                if (IS_ERR(smbdirect_mr->mr)) {
                        log_rdma_mr(ERR, "ib_alloc_mr failed mr_type=%x max_frmr_depth=%x\n",
-                                   info->mr_type, info->max_frmr_depth);
+                                   info->mr_type, sp->max_frmr_depth);
                        goto out;
                }
-               smbdirect_mr->sgt.sgl = kcalloc(info->max_frmr_depth,
+               smbdirect_mr->sgt.sgl = kcalloc(sp->max_frmr_depth,
                                                sizeof(struct scatterlist),
                                                GFP_KERNEL);
                if (!smbdirect_mr->sgt.sgl) {
@@ -2459,15 +2460,16 @@ struct smbdirect_mr_io *smbd_register_mr(struct smbd_connection *info,
                                 bool writing, bool need_invalidate)
 {
        struct smbdirect_socket *sc = &info->socket;
+       struct smbdirect_socket_parameters *sp = &sc->parameters;
        struct smbdirect_mr_io *smbdirect_mr;
        int rc, num_pages;
        enum dma_data_direction dir;
        struct ib_reg_wr *reg_wr;
 
-       num_pages = iov_iter_npages(iter, info->max_frmr_depth + 1);
-       if (num_pages > info->max_frmr_depth) {
+       num_pages = iov_iter_npages(iter, sp->max_frmr_depth + 1);
+       if (num_pages > sp->max_frmr_depth) {
                log_rdma_mr(ERR, "num_pages=%d max_frmr_depth=%d\n",
-                       num_pages, info->max_frmr_depth);
+                       num_pages, sp->max_frmr_depth);
                WARN_ON_ONCE(1);
                return NULL;
        }
@@ -2485,8 +2487,8 @@ struct smbdirect_mr_io *smbd_register_mr(struct smbd_connection *info,
        smbdirect_mr->sgt.orig_nents = 0;
 
        log_rdma_mr(INFO, "num_pages=0x%x count=0x%zx depth=%u\n",
-                   num_pages, iov_iter_count(iter), info->max_frmr_depth);
-       smbd_iter_to_mr(info, iter, &smbdirect_mr->sgt, info->max_frmr_depth);
+                   num_pages, iov_iter_count(iter), sp->max_frmr_depth);
+       smbd_iter_to_mr(info, iter, &smbdirect_mr->sgt, sp->max_frmr_depth);
 
        rc = ib_dma_map_sg(sc->ib.dev, smbdirect_mr->sgt.sgl,
                           smbdirect_mr->sgt.nents, dir);
index 83e726967b2f83ffb97fc498596fbfc70bc48fe4..c88ba6e11dd146aaebbce03024811ca326284c1e 100644 (file)
@@ -41,8 +41,6 @@ struct smbd_connection {
 
 
        /* Memory registrations */
-       /* Maximum number of pages in a single RDMA write/read on this connection */
-       int max_frmr_depth;
        enum ib_mr_type mr_type;
        struct list_head mr_list;
        spinlock_t mr_list_lock;