Skip to contentSkip to conversation

CIFS: Wait for credits if at least one request is in flight

PATCH In review Pavel Shilovsky 3 participants 3 messages Feb 2, 2021 – Feb 3, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 CIFS: Wait for credits if at least one request is in flight

Currently we try to guess if a compound request is going to succeed waiting for credits or not based on the number of requests in flight. This approach doesn't work correctly all the time because there may be only one request in flight which is going to bring multiple credits satisfying the compound request.

Change the behavior to fail a request only if there are no requests in flight at all and proceed waiting for credits otherwise.

---
 fs/cifs/transport.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
fs/cifs/transport.c +15 -3
index 4ffbf8f965814..eab7940bfebef 100644
@@ -659,10 +659,22 @@ wait_for_compound_request(struct TCP_Server_Info *server, int num,
 	spin_lock(&server->req_lock);
 	if (*credits < num) {
 		/*
-		 * Return immediately if not too many requests in flight since
-		 * we will likely be stuck on waiting for credits.
+		 * If the server is tight on resources or just gives us less
+		 * credits for other reasons (e.g. requests are coming out of
+		 * order and the server delays granting more credits until it
+		 * processes a missing mid) and we exhausted most available
+		 * credits there may be situations when we try to send
+		 * a compound request but we don't have enough credits. At this
+		 * point the client needs to decide if it should wait for
+		 * additional credits or fail the request. If at least one
+		 * request is in flight there is a high probability that the
+		 * server will return enough credits to satisfy this compound
+		 * request.
+		 *
+		 * Return immediately if no requests in flight since we will be
+		 * stuck on waiting for credits.
 		 */
-		if (server->in_flight < num - *credits) {
+		if (server->in_flight == 0) {
 			spin_unlock(&server->req_lock);
 			return -ENOTSUPP;
 		}
Signature · 1 line
2.25.1
reviewer Reviewed-by on v2 1/1
#1 lore raw

Updated comment looks good!

Quoted 46 lines · Pavel Shilovsky

Currently we try to guess if a compound request is going to succeed waiting for credits or not based on the number of requests in flight. This approach doesn't work correctly all the time because there may be only one request in flight which is going to bring multiple credits satisfying the compound request.

Change the behavior to fail a request only if there are no requests in flight at all and proceed waiting for credits otherwise.

---
  fs/cifs/transport.c | 18 +++++++++++++++---
  1 file changed, 15 insertions(+), 3 deletions(-)
fs/cifs/transport.c +15 -3
index 4ffbf8f965814..eab7940bfebef 100644
@@ -659,10 +659,22 @@ wait_for_compound_request(struct TCP_Server_Info *server, int num,
  	spin_lock(&server->req_lock);
  	if (*credits < num) {
  		/*
-		 * Return immediately if not too many requests in flight since
-		 * we will likely be stuck on waiting for credits.
+		 * If the server is tight on resources or just gives us less
+		 * credits for other reasons (e.g. requests are coming out of
+		 * order and the server delays granting more credits until it
+		 * processes a missing mid) and we exhausted most available
+		 * credits there may be situations when we try to send
+		 * a compound request but we don't have enough credits. At this
+		 * point the client needs to decide if it should wait for
+		 * additional credits or fail the request. If at least one
+		 * request is in flight there is a high probability that the
+		 * server will return enough credits to satisfy this compound
+		 * request.
+		 *
+		 * Return immediately if no requests in flight since we will be
+		 * stuck on waiting for credits.
  		 */
-		if (server->in_flight < num - *credits) {
+		if (server->in_flight == 0) {
  			spin_unlock(&server->req_lock);
  			return -ENOTSUPP;
  		}
#2 lore raw

updated patch (had minor merge conflict) and added the two reviewed-by and tentatively merged into cifs-2.6.git

Quoted 52 lines · Tom Talpey

Updated comment looks good!

Quoted 46 lines · Pavel Shilovsky

Currently we try to guess if a compound request is going to succeed waiting for credits or not based on the number of requests in flight. This approach doesn't work correctly all the time because there may be only one request in flight which is going to bring multiple credits satisfying the compound request.

Change the behavior to fail a request only if there are no requests in flight at all and proceed waiting for credits otherwise.

---
  fs/cifs/transport.c | 18 +++++++++++++++---
  1 file changed, 15 insertions(+), 3 deletions(-)
fs/cifs/transport.c +15 -3
index 4ffbf8f965814..eab7940bfebef 100644
@@ -659,10 +659,22 @@ wait_for_compound_request(struct TCP_Server_Info *server, int num,
      spin_lock(&server->req_lock);
      if (*credits < num) {
              /*
-              * Return immediately if not too many requests in flight since
-              * we will likely be stuck on waiting for credits.
+              * If the server is tight on resources or just gives us less
+              * credits for other reasons (e.g. requests are coming out of
+              * order and the server delays granting more credits until it
+              * processes a missing mid) and we exhausted most available
+              * credits there may be situations when we try to send
+              * a compound request but we don't have enough credits. At this
+              * point the client needs to decide if it should wait for
+              * additional credits or fail the request. If at least one
+              * request is in flight there is a high probability that the
+              * server will return enough credits to satisfy this compound
+              * request.
+              *
+              * Return immediately if no requests in flight since we will be
+              * stuck on waiting for credits.
               */
-             if (server->in_flight < num - *credits) {
+             if (server->in_flight == 0) {
                      spin_unlock(&server->req_lock);
                      return -ENOTSUPP;
              }
Signature · 3 lines
Thanks,

Steve