Skip to content

Commit 8e94268

Browse files
metze-sambasmfrench
authored andcommitted
smb: smbdirect: introduce smbdirect_socket.send_io.bcredits.*
It turns out that our code will corrupt the stream of reassabled data transfer messages when we trigger an immendiate (empty) send. In order to fix this we'll have a single 'batch' credit per connection. And code getting that credit is free to use as much messages until remaining_length reaches 0, then the batch credit it given back and the next logical send can happen. Cc: <stable@vger.kernel.org> # 6.18.x 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>
1 parent 6e3c505 commit 8e94268

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

fs/smb/common/smbdirect/smbdirect_socket.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,17 @@ struct smbdirect_socket {
162162
mempool_t *pool;
163163
} mem;
164164

165+
/*
166+
* This is a coordination for smbdirect_send_batch.
167+
*
168+
* There's only one possible credit, which means
169+
* only one instance is running at a time.
170+
*/
171+
struct {
172+
atomic_t count;
173+
wait_queue_head_t wait_queue;
174+
} bcredits;
175+
165176
/*
166177
* The local credit state for ib_post_send()
167178
*/
@@ -371,6 +382,9 @@ static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)
371382
INIT_DELAYED_WORK(&sc->idle.timer_work, __smbdirect_socket_disabled_work);
372383
disable_delayed_work_sync(&sc->idle.timer_work);
373384

385+
atomic_set(&sc->send_io.bcredits.count, 0);
386+
init_waitqueue_head(&sc->send_io.bcredits.wait_queue);
387+
374388
atomic_set(&sc->send_io.lcredits.count, 0);
375389
init_waitqueue_head(&sc->send_io.lcredits.wait_queue);
376390

@@ -485,6 +499,8 @@ struct smbdirect_send_batch {
485499
*/
486500
bool need_invalidate_rkey;
487501
u32 remote_key;
502+
503+
int credit;
488504
};
489505

490506
struct smbdirect_recv_io {

0 commit comments

Comments
 (0)