Skip to contentSkip to conversation

ksmbd: fix outstanding credits related bugs

PATCH Superseded Hyunchul Lee 2 participants 4 messages May 17, 2022 – May 20, 2022

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ksmbd: fix outstanding credits related bugs

outstanding credits must be initialized to 0,
because it means the sum of credits consumed by
in-flight requests.
And outstanding credits must be compared with
total credits in smb2_validate_credit_charge(),
because total credits are the sum of credits
granted by ksmbd.

This patch fix the following error,
while frametest with Windows clients:

Limits exceeding the maximum allowable outstanding requests, given : 128, pending : 8065

---
 fs/ksmbd/connection.c | 2 +-
 fs/ksmbd/smb2misc.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/ksmbd/connection.c +1 -1
index 7db87771884a..e8f476c5f189 100644
@@ -62,7 +62,7 @@ struct ksmbd_conn *ksmbd_conn_alloc(void)
 	atomic_set(&conn->req_running, 0);
 	atomic_set(&conn->r_count, 0);
 	conn->total_credits = 1;
-	conn->outstanding_credits = 1;
+	conn->outstanding_credits = 0;
 
 	init_waitqueue_head(&conn->req_running_q);
 	INIT_LIST_HEAD(&conn->conns_list);
fs/ksmbd/smb2misc.c +1 -1
index 4a9460153b59..f8f456377a51 100644
@@ -338,7 +338,7 @@ static int smb2_validate_credit_charge(struct ksmbd_conn *conn,
 		ret = 1;
 	}
 
-	if ((u64)conn->outstanding_credits + credit_charge > conn->vals->max_credits) {
+	if ((u64)conn->outstanding_credits + credit_charge > conn->total_credits) {
 		ksmbd_debug(SMB, "Limits exceeding the maximum allowable outstanding requests, given : %u, pending : %u\n",
 			    credit_charge, conn->outstanding_credits);
 		ret = 1;
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 ksmbd: smbd: fix connection dropped issue

When there are bursty connection requests, RDMA connection event handler is deferred and Negotiation requests are received even if connection status is NEW.

To handle it, set the status to CONNECTED if Negotiation requests are received.

---
 fs/ksmbd/transport_rdma.c | 1 +
 1 file changed, 1 insertion(+)
fs/ksmbd/transport_rdma.c +1 -0
index 0741fd129d16..e91acc2746bc 100644
@@ -576,6 +576,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
 		}
 		t->negotiation_requested = true;
 		t->full_packet_received = true;
+		t->status = SMB_DIRECT_CS_CONNECTED;
 		enqueue_reassembly(t, recvmsg, 0);
 		wake_up_interruptible(&t->wait_status);
 		break;
Signature · 1 line
2.25.1
maintainer Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] ksmbd: smbd: fix connection dropped issue

2022-05-18 6:46 GMT+09:00, Hyunchul Lee <[email protected]>:

Quoted 11 lines

When there are bursty connection requests, RDMA connection event handler is deferred and Negotiation requests are received even if connection status is NEW.

To handle it, set the status to CONNECTED if Negotiation requests are received.

Thanks!

maintainer
#3 lore raw
In reply to Hyunchul Lee

2022-05-18 6:46 GMT+09:00, Hyunchul Lee <[email protected]>:

Quoted 11 lines

outstanding credits must be initialized to 0,
because it means the sum of credits consumed by
in-flight requests.
And outstanding credits must be compared with
total credits in smb2_validate_credit_charge(),
because total credits are the sum of credits
granted by ksmbd.

This patch fix the following error,
while frametest with Windows clients:

Quoted 6 lines

Limits exceeding the maximum allowable outstanding requests, given : 128, pending : 8065

Please add Fixes and stable tags.

Thanks.