The error paths of smbdirect_connection_send_single_iter() give back the send, local and batch credits without waking up the waiters on sc->send_io.{credits,lcredits,bcredits}.wait_queue, so other senders and the immediate send work can sleep while credits are available, until something else wakes them up. It also gives back the batch credit of a batch of the caller and clears batch->credit, so smbdirect_connection_send_batch_abort() doesn't see it and doesn't wake up the waiters either, and the credit can be used for another PDU while the aborted one is still in the batch. Wake up the waiters, like smbdirect_connection_send_batch_abort() does, and leave the batch credit of a batch of the caller to smbdirect_connection_send_batch_abort() or smbdirect_connection_send_batch_flush(). Fixes: 54abc694ebb8 ("smb: smbdirect: introduce smbdirect_connection_send_iter() and related functions") Cc: stable@vger.kernel.org Cc: Namjae Jeon Cc: Paulo Alcantara Cc: Tom Talpey Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Reported-by: Sashiko Closes: https://sashiko.dev/#/bug/linux-a2180487-c0d3-4f9a-92d7-208e032dd966 Reviewed-by: Paulo Alcantara Signed-off-by: Stefan Metzmacher --- fs/smb/smbdirect/connection.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/smb/smbdirect/connection.c b/fs/smb/smbdirect/connection.c index 0e5bf32d70a6..475ec88c238b 100644 --- a/fs/smb/smbdirect/connection.c +++ b/fs/smb/smbdirect/connection.c @@ -1371,11 +1371,21 @@ int smbdirect_connection_send_single_iter(struct smbdirect_socket *sc, flush_failed: alloc_failed: atomic_inc(&sc->send_io.credits.count); + wake_up(&sc->send_io.credits.wait_queue); credit_failed: atomic_inc(&sc->send_io.lcredits.count); + wake_up(&sc->send_io.lcredits.wait_queue); lcredit_failed: - atomic_add(batch->credit, &sc->send_io.bcredits.count); - batch->credit = 0; + /* + * The batch credit of a batch of the caller is given back by + * smbdirect_connection_send_batch_abort() or + * smbdirect_connection_send_batch_flush(). + */ + if (batch == &_batch && batch->credit) { + atomic_add(batch->credit, &sc->send_io.bcredits.count); + batch->credit = 0; + wake_up(&sc->send_io.bcredits.wait_queue); + } bcredit_failed: return ret; } -- 2.43.0