Skip to content

Commit 164cacd

Browse files
metze-sambasmfrench
authored andcommitted
smb: server: correct value for smb_direct_max_fragmented_recv_size
We should make it clear that we use this strange value instead of hiding it in same code flow. Note this value is mainly ignored currently, as we do the calculation again with the negotiated max_recv_size in smb_direct_prepare(). So this is only a cosmetic change in order to avoid confusion. In future we may change the logic and adjust the number of recv buffers instead of the max_fragmented_recv_size. Acked-by: 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> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 4a93d1e commit 164cacd

1 file changed

Lines changed: 40 additions & 2 deletions

File tree

fs/smb/server/transport_rdma.c

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,23 @@ static int smb_direct_send_credit_target = 255;
7070
/* The maximum single message size can be sent to remote peer */
7171
static int smb_direct_max_send_size = 1364;
7272

73-
/* The maximum fragmented upper-layer payload receive size supported */
74-
static int smb_direct_max_fragmented_recv_size = 1024 * 1024;
73+
/*
74+
* The maximum fragmented upper-layer payload receive size supported
75+
*
76+
* Assume max_payload_per_credit is
77+
* smb_direct_receive_credit_max - 24 = 1340
78+
*
79+
* The maximum number would be
80+
* smb_direct_receive_credit_max * max_payload_per_credit
81+
*
82+
* 1340 * 255 = 341700 (0x536C4)
83+
*
84+
* The minimum value from the spec is 131072 (0x20000)
85+
*
86+
* For now we use the logic we used before:
87+
* (1364 * 255) / 2 = 173910 (0x2A756)
88+
*/
89+
static int smb_direct_max_fragmented_recv_size = (1364 * 255) / 2;
7590

7691
/* The maximum single-message size which can be received */
7792
static int smb_direct_max_receive_size = 1364;
@@ -2531,6 +2546,29 @@ static int smb_direct_prepare(struct ksmbd_transport *t)
25312546
le32_to_cpu(req->max_receive_size));
25322547
sp->max_fragmented_send_size =
25332548
le32_to_cpu(req->max_fragmented_size);
2549+
/*
2550+
* The maximum fragmented upper-layer payload receive size supported
2551+
*
2552+
* Assume max_payload_per_credit is
2553+
* smb_direct_receive_credit_max - 24 = 1340
2554+
*
2555+
* The maximum number would be
2556+
* smb_direct_receive_credit_max * max_payload_per_credit
2557+
*
2558+
* 1340 * 255 = 341700 (0x536C4)
2559+
*
2560+
* The minimum value from the spec is 131072 (0x20000)
2561+
*
2562+
* For now we use the logic we used before:
2563+
* (1364 * 255) / 2 = 173910 (0x2A756)
2564+
*
2565+
* We need to adjust this here in case the peer
2566+
* lowered sp->max_recv_size.
2567+
*
2568+
* TODO: instead of adjusting max_fragmented_recv_size
2569+
* we should adjust the number of available buffers,
2570+
* but for now we keep the current logic.
2571+
*/
25342572
sp->max_fragmented_recv_size =
25352573
(sp->recv_credit_max * sp->max_recv_size) / 2;
25362574
sc->recv_io.credits.target = le16_to_cpu(req->credits_requested);

0 commit comments

Comments
 (0)