Skip to content

Commit 68335cb

Browse files
metze-sambasmfrench
authored andcommitted
smb: smbdirect: introduce smbdirect_socket.send_io.lcredits.*
This will be used to implement a logic in order to make sure we don't overflow the send submission queue for ib_post_send(). We will initialize the local credits with the fixed sp->send_credit_target value, which matches the reserved slots in the submission queue for ib_post_send(). We will be a local credit first and then wait for a remote credit, if we managed to get both we are allowed to post an IB_WR_SEND[_WITH_INV]. The local credit is given back to the pool when we get the local ib_post_send() completion, while remote credits are granted by the peer. From reading the git history of the linux smbdirect implementations in client and server) it was seen that a peer granted more credits than we requested. I guess that only happened because of bugs in our implementation which was active as client and server. I guess Windows won't do that. So the local credits make sure we only use the amount of credits we asked for. The client already has some logic for this based on smbdirect_socket.send_io.pending.count, but that counts in the order direction and makes it complex it share common logic for various credits classes. That logic will be replaced soon. Cc: Steve French <[email protected]> Cc: Tom Talpey <[email protected]> Cc: Long Li <[email protected]> Cc: Namjae Jeon <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Stefan Metzmacher <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 0bd73ae commit 68335cb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

fs/smb/common/smbdirect/smbdirect_socket.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,15 @@ struct smbdirect_socket {
142142
} mem;
143143

144144
/*
145-
* The credit state for the send side
145+
* The local credit state for ib_post_send()
146+
*/
147+
struct {
148+
atomic_t count;
149+
wait_queue_head_t wait_queue;
150+
} lcredits;
151+
152+
/*
153+
* The remote credit state for the send side
146154
*/
147155
struct {
148156
atomic_t count;
@@ -337,6 +345,9 @@ static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)
337345
INIT_DELAYED_WORK(&sc->idle.timer_work, __smbdirect_socket_disabled_work);
338346
disable_delayed_work_sync(&sc->idle.timer_work);
339347

348+
atomic_set(&sc->send_io.lcredits.count, 0);
349+
init_waitqueue_head(&sc->send_io.lcredits.wait_queue);
350+
340351
atomic_set(&sc->send_io.credits.count, 0);
341352
init_waitqueue_head(&sc->send_io.credits.wait_queue);
342353

0 commit comments

Comments
 (0)