Skip to content

Commit 9219f8c

Browse files
metze-sambasmfrench
authored andcommitted
smb: client: limit the range of info->receive_credit_target
This simplifies further changes... 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>
1 parent 1a07031 commit 9219f8c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

fs/smb/client/smbdirect.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ static bool process_negotiation_response(
483483
return false;
484484
}
485485
info->receive_credit_target = le16_to_cpu(packet->credits_requested);
486+
info->receive_credit_target = min_t(u16, info->receive_credit_target, sp->recv_credit_max);
486487

487488
if (packet->credits_granted == 0) {
488489
log_rdma_event(ERR, "error: credits_granted==0\n");
@@ -590,7 +591,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
590591
struct smbdirect_socket_parameters *sp = &sc->parameters;
591592
struct smbd_connection *info =
592593
container_of(sc, struct smbd_connection, socket);
593-
int old_recv_credit_target;
594+
u16 old_recv_credit_target;
594595
u32 data_offset = 0;
595596
u32 data_length = 0;
596597
u32 remaining_data_length = 0;
@@ -668,6 +669,10 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
668669
old_recv_credit_target = info->receive_credit_target;
669670
info->receive_credit_target =
670671
le16_to_cpu(data_transfer->credits_requested);
672+
info->receive_credit_target =
673+
min_t(u16, info->receive_credit_target, sp->recv_credit_max);
674+
info->receive_credit_target =
675+
max_t(u16, info->receive_credit_target, 1);
671676
if (le16_to_cpu(data_transfer->credits_granted)) {
672677
atomic_add(le16_to_cpu(data_transfer->credits_granted),
673678
&sc->send_io.credits.count);

fs/smb/client/smbdirect.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct smbd_connection {
5454
enum keep_alive_status keep_alive_requested;
5555
int protocol;
5656
atomic_t receive_credits;
57-
int receive_credit_target;
57+
u16 receive_credit_target;
5858

5959
/* Memory registrations */
6060
/* Maximum number of RDMA read/write outstanding on this connection */

0 commit comments

Comments
 (0)