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>
This commit is contained in:
Stefan Metzmacher 2025-08-14 15:01:35 +02:00 committed by Steve French
parent 1a07031fdd
commit 9219f8cac2
2 changed files with 7 additions and 2 deletions

View File

@ -483,6 +483,7 @@ static bool process_negotiation_response(
return false;
}
info->receive_credit_target = le16_to_cpu(packet->credits_requested);
info->receive_credit_target = min_t(u16, info->receive_credit_target, sp->recv_credit_max);
if (packet->credits_granted == 0) {
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)
struct smbdirect_socket_parameters *sp = &sc->parameters;
struct smbd_connection *info =
container_of(sc, struct smbd_connection, socket);
int old_recv_credit_target;
u16 old_recv_credit_target;
u32 data_offset = 0;
u32 data_length = 0;
u32 remaining_data_length = 0;
@ -668,6 +669,10 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
old_recv_credit_target = info->receive_credit_target;
info->receive_credit_target =
le16_to_cpu(data_transfer->credits_requested);
info->receive_credit_target =
min_t(u16, info->receive_credit_target, sp->recv_credit_max);
info->receive_credit_target =
max_t(u16, info->receive_credit_target, 1);
if (le16_to_cpu(data_transfer->credits_granted)) {
atomic_add(le16_to_cpu(data_transfer->credits_granted),
&sc->send_io.credits.count);

View File

@ -54,7 +54,7 @@ struct smbd_connection {
enum keep_alive_status keep_alive_requested;
int protocol;
atomic_t receive_credits;
int receive_credit_target;
u16 receive_credit_target;
/* Memory registrations */
/* Maximum number of RDMA read/write outstanding on this connection */