Skip to content

Commit defb3c0

Browse files
metze-sambasmfrench
authored andcommitted
smb: client: let recv_done() queue a refill when the peer is low on credits
In captures I saw that Windows was granting 191 credits in a batch when its peer posted a lot of messages. We are asking for a credit target of 255 and 191 is 252*3/4. So we also use that logic in order to fill the recv buffers available to the peer. Fixes: 02548c4 ("smb: client: queue post_recv_credits_work also if the peer raises the credit target") 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> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 9911b1e commit defb3c0

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

fs/smb/client/smbdirect.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
663663
container_of(wc->wr_cqe, struct smbdirect_recv_io, cqe);
664664
struct smbdirect_socket *sc = response->socket;
665665
struct smbdirect_socket_parameters *sp = &sc->parameters;
666+
int current_recv_credits;
666667
u16 old_recv_credit_target;
667668
u32 data_offset = 0;
668669
u32 data_length = 0;
@@ -747,7 +748,8 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
747748
}
748749

749750
atomic_dec(&sc->recv_io.posted.count);
750-
atomic_dec(&sc->recv_io.credits.count);
751+
current_recv_credits = atomic_dec_return(&sc->recv_io.credits.count);
752+
751753
old_recv_credit_target = sc->recv_io.credits.target;
752754
sc->recv_io.credits.target =
753755
le16_to_cpu(data_transfer->credits_requested);
@@ -783,7 +785,8 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
783785
* reassembly queue and wake up the reading thread
784786
*/
785787
if (data_length) {
786-
if (sc->recv_io.credits.target > old_recv_credit_target)
788+
if (current_recv_credits <= (sc->recv_io.credits.target / 4) ||
789+
sc->recv_io.credits.target > old_recv_credit_target)
787790
queue_work(sc->workqueue, &sc->recv_io.posted.refill_work);
788791

789792
enqueue_reassembly(sc, response, data_length);

0 commit comments

Comments
 (0)