summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2025-10-17 15:37:32 +0200
committerSteve French <stfrench@microsoft.com>2026-04-15 21:58:22 -0500
commit8b72c199a9626cc1b53c8d579e9e4c6f23af8908 (patch)
tree74e4f368c57170af4aa70c52cf2735b068e7bfcb
parentedb9e514f0e058a924a169795fb0e34286da9572 (diff)
downloadlwn-8b72c199a9626cc1b53c8d579e9e4c6f23af8908.tar.gz
lwn-8b72c199a9626cc1b53c8d579e9e4c6f23af8908.zip
smb: client: make use of smbdirect_connection_grant_recv_credits()
This already calls atomic_add(new_credits, &sc->recv_io.credits.count), so there's no need to do it in the caller anymore. Cc: Steve French <smfrench@gmail.com> Cc: Tom Talpey <tom@talpey.com> Cc: Long Li <longli@microsoft.com> Cc: Namjae Jeon <linkinjeon@kernel.org> Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Signed-off-by: Stefan Metzmacher <metze@samba.org> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
-rw-r--r--fs/smb/client/smbdirect.c51
1 files changed, 3 insertions, 48 deletions
diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c
index ffdb87d24b47..4cc5dc825ee4 100644
--- a/fs/smb/client/smbdirect.c
+++ b/fs/smb/client/smbdirect.c
@@ -760,51 +760,6 @@ dma_mapping_failed:
}
/*
- * Extend the credits to remote peer
- * This implements [MS-SMBD] 3.1.5.9
- * The idea is that we should extend credits to remote peer as quickly as
- * it's allowed, to maintain data flow. We allocate as much receive
- * buffer as possible, and extend the receive credits to remote peer
- * return value: the new credtis being granted.
- */
-static int manage_credits_prior_sending(struct smbdirect_socket *sc)
-{
- int missing;
- int available;
- int new_credits;
-
- if (atomic_read(&sc->recv_io.credits.count) >= sc->recv_io.credits.target)
- return 0;
-
- missing = (int)sc->recv_io.credits.target - atomic_read(&sc->recv_io.credits.count);
- available = atomic_xchg(&sc->recv_io.credits.available, 0);
- new_credits = (u16)min3(U16_MAX, missing, available);
- if (new_credits <= 0) {
- /*
- * If credits are available, but not granted
- * we need to re-add them again.
- */
- if (available)
- atomic_add(available, &sc->recv_io.credits.available);
- return 0;
- }
-
- if (new_credits < available) {
- /*
- * Readd the remaining available again.
- */
- available -= new_credits;
- atomic_add(available, &sc->recv_io.credits.available);
- }
-
- /*
- * Remember we granted the credits
- */
- atomic_add(new_credits, &sc->recv_io.credits.count);
- return new_credits;
-}
-
-/*
* Check if we need to send a KEEP_ALIVE message
* The idle connection timer triggers a KEEP_ALIVE message when expires
* SMBDIRECT_FLAG_RESPONSE_REQUESTED is set in the message flag to have peer send
@@ -1048,7 +1003,7 @@ static int smbd_post_send_iter(struct smbdirect_socket *sc,
int data_length;
struct smbdirect_send_io *request;
struct smbdirect_data_transfer *packet;
- int new_credits = 0;
+ u16 new_credits = 0;
struct smbdirect_send_batch _batch;
if (!batch) {
@@ -1077,7 +1032,7 @@ static int smbd_post_send_iter(struct smbdirect_socket *sc,
goto err_wait_credit;
}
- new_credits = manage_credits_prior_sending(sc);
+ new_credits = smbdirect_connection_grant_recv_credits(sc);
if (new_credits == 0 &&
atomic_read(&sc->send_io.credits.count) == 0 &&
atomic_read(&sc->recv_io.credits.count) == 0) {
@@ -1094,7 +1049,7 @@ static int smbd_post_send_iter(struct smbdirect_socket *sc,
goto err_wait_credit;
}
- new_credits = manage_credits_prior_sending(sc);
+ new_credits = smbdirect_connection_grant_recv_credits(sc);
}
request = smbdirect_connection_alloc_send_io(sc);