diff mbox series

[2/6] cifs: pass flags down into wait_for_free_credits()

Message ID 20190308025823.24382-3-lsahlber@redhat.com (mailing list archive)
State New, archived
Headers show
Series cifs: simplify handling of credits for compounds | expand

Commit Message

Ronnie Sahlberg March 8, 2019, 2:58 a.m. UTC
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/transport.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

Comments

Pavel Shilovsky March 9, 2019, 12:54 a.m. UTC | #1
чт, 7 мар. 2019 г. в 19:35, Ronnie Sahlberg <lsahlber@redhat.com>:
>
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
>  fs/cifs/transport.c | 30 ++++++++++++++----------------
>  1 file changed, 14 insertions(+), 16 deletions(-)
>
> diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
> index 5c4becefde4b..8887db2cd582 100644
> --- a/fs/cifs/transport.c
> +++ b/fs/cifs/transport.c
> @@ -477,15 +477,24 @@ smb_send(struct TCP_Server_Info *server, struct smb_hdr *smb_buffer,
>  }
>
>  static int
> -wait_for_free_credits(struct TCP_Server_Info *server, const int timeout,
> -                     int *credits, unsigned int *instance)
> +wait_for_free_credits(struct TCP_Server_Info *server, const int flags,
> +                     unsigned int *instance)
>  {
>         int rc;
> +       int *credits;
> +       int optype;
> +
> +       optype = flags & CIFS_OP_MASK;
>
>         *instance = 0;
>
> +       credits = server->ops->get_credits_field(server, optype);
> +       /* Since an echo is already inflight, no need to wait to send another */
> +       if (*credits <= 0 && optype == CIFS_ECHO_OP)
> +               return -EAGAIN;
> +
>         spin_lock(&server->req_lock);
> -       if (timeout == CIFS_ASYNC_OP) {
> +       if ((flags & CIFS_TIMEOUT_MASK) == CIFS_ASYNC_OP) {
>                 /* oplock breaks must not be held up */
>                 server->in_flight++;
>                 *credits -= 1;
> @@ -516,7 +525,7 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int timeout,
>                          */
>
>                         /* update # of requests on the wire to server */
> -                       if (timeout != CIFS_BLOCKING_OP) {
> +                       if ((flags & CIFS_TIMEOUT_MASK) != CIFS_BLOCKING_OP) {
>                                 *credits -= 1;
>                                 server->in_flight++;
>                                 *instance = server->reconnect_instance;
> @@ -532,18 +541,7 @@ static int
>  wait_for_free_request(struct TCP_Server_Info *server, const int flags,
>                       unsigned int *instance)
>  {
> -       int *val;
> -       int timeout, optype;
> -
> -       timeout = flags & CIFS_TIMEOUT_MASK;
> -       optype = flags & CIFS_OP_MASK;
> -
> -       val = server->ops->get_credits_field(server, optype);
> -       /* Since an echo is already inflight, no need to wait to send another */
> -       if (*val <= 0 && optype == CIFS_ECHO_OP)
> -               return -EAGAIN;
> -
> -       return wait_for_free_credits(server, timeout, val, instance);
> +       return wait_for_free_credits(server, flags, instance);
>  }
>
>  int
> --
> 2.13.6
>

Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
--
Best regards,
Pavel Shilovsky
diff mbox series

Patch

diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 5c4becefde4b..8887db2cd582 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -477,15 +477,24 @@  smb_send(struct TCP_Server_Info *server, struct smb_hdr *smb_buffer,
 }
 
 static int
-wait_for_free_credits(struct TCP_Server_Info *server, const int timeout,
-		      int *credits, unsigned int *instance)
+wait_for_free_credits(struct TCP_Server_Info *server, const int flags,
+		      unsigned int *instance)
 {
 	int rc;
+	int *credits;
+	int optype;
+
+	optype = flags & CIFS_OP_MASK;
 
 	*instance = 0;
 
+	credits = server->ops->get_credits_field(server, optype);
+	/* Since an echo is already inflight, no need to wait to send another */
+	if (*credits <= 0 && optype == CIFS_ECHO_OP)
+		return -EAGAIN;
+
 	spin_lock(&server->req_lock);
-	if (timeout == CIFS_ASYNC_OP) {
+	if ((flags & CIFS_TIMEOUT_MASK) == CIFS_ASYNC_OP) {
 		/* oplock breaks must not be held up */
 		server->in_flight++;
 		*credits -= 1;
@@ -516,7 +525,7 @@  wait_for_free_credits(struct TCP_Server_Info *server, const int timeout,
 			 */
 
 			/* update # of requests on the wire to server */
-			if (timeout != CIFS_BLOCKING_OP) {
+			if ((flags & CIFS_TIMEOUT_MASK) != CIFS_BLOCKING_OP) {
 				*credits -= 1;
 				server->in_flight++;
 				*instance = server->reconnect_instance;
@@ -532,18 +541,7 @@  static int
 wait_for_free_request(struct TCP_Server_Info *server, const int flags,
 		      unsigned int *instance)
 {
-	int *val;
-	int timeout, optype;
-
-	timeout = flags & CIFS_TIMEOUT_MASK;
-	optype = flags & CIFS_OP_MASK;
-
-	val = server->ops->get_credits_field(server, optype);
-	/* Since an echo is already inflight, no need to wait to send another */
-	if (*val <= 0 && optype == CIFS_ECHO_OP)
-		return -EAGAIN;
-
-	return wait_for_free_credits(server, timeout, val, instance);
+	return wait_for_free_credits(server, flags, instance);
 }
 
 int