linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Shilovsky <piastryyy@gmail.com>
To: Ronnie Sahlberg <lsahlber@redhat.com>
Cc: linux-cifs <linux-cifs@vger.kernel.org>,
	Steve French <smfrench@gmail.com>,
	Pavel Shilovsky <pshilov@microsoft.com>
Subject: Re: [PATCH 3/6] cifs: wait_for_free_credits() make it possible to wait for >=1 credits
Date: Fri, 8 Mar 2019 16:54:34 -0800	[thread overview]
Message-ID: <CAKywueTgMupDPkPkeUXa6281o3mWANeGrzfswyXH8LaAk8W5SQ@mail.gmail.com> (raw)
In-Reply-To: <20190308025823.24382-4-lsahlber@redhat.com>

чт, 7 мар. 2019 г. в 19:35, Ronnie Sahlberg <lsahlber@redhat.com>:
>
> Change wait_for_free_credits() to allow waiting for >=1 credits instead of just
> a single credit.
>
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
>  fs/cifs/cifsglob.h  |  4 ++--
>  fs/cifs/smb2ops.c   |  2 +-
>  fs/cifs/transport.c | 14 +++++++-------
>  3 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
> index 31c63e7437fd..bc2bb14b2180 100644
> --- a/fs/cifs/cifsglob.h
> +++ b/fs/cifs/cifsglob.h
> @@ -734,13 +734,13 @@ in_flight(struct TCP_Server_Info *server)
>  }
>
>  static inline bool
> -has_credits(struct TCP_Server_Info *server, int *credits)
> +has_credits(struct TCP_Server_Info *server, int *credits, int num_credits)
>  {
>         int num;
>         spin_lock(&server->req_lock);
>         num = *credits;
>         spin_unlock(&server->req_lock);
> -       return num > 0;
> +       return num >= num_credits;
>  }
>
>  static inline void
> diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
> index 1243407c9546..15bc7953b7a6 100644
> --- a/fs/cifs/smb2ops.c
> +++ b/fs/cifs/smb2ops.c
> @@ -185,7 +185,7 @@ smb2_wait_mtu_credits(struct TCP_Server_Info *server, unsigned int size,
>                         spin_unlock(&server->req_lock);
>                         cifs_num_waiters_inc(server);
>                         rc = wait_event_killable(server->request_q,
> -                                       has_credits(server, &server->credits));
> +                               has_credits(server, &server->credits, 1));
>                         cifs_num_waiters_dec(server);
>                         if (rc)
>                                 return rc;
> diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
> index 8887db2cd582..baf15194aa3d 100644
> --- a/fs/cifs/transport.c
> +++ b/fs/cifs/transport.c
> @@ -477,8 +477,8 @@ 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 flags,
> -                     unsigned int *instance)
> +wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits,
> +                     const int flags, unsigned int *instance)
>  {
>         int rc;
>         int *credits;
> @@ -504,11 +504,11 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int flags,
>         }
>
>         while (1) {
> -               if (*credits <= 0) {
> +               if (*credits < num_credits) {
>                         spin_unlock(&server->req_lock);
>                         cifs_num_waiters_inc(server);
>                         rc = wait_event_killable(server->request_q,
> -                                                has_credits(server, credits));
> +                               has_credits(server, credits, num_credits));
>                         cifs_num_waiters_dec(server);
>                         if (rc)
>                                 return rc;
> @@ -526,8 +526,8 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int flags,
>
>                         /* update # of requests on the wire to server */
>                         if ((flags & CIFS_TIMEOUT_MASK) != CIFS_BLOCKING_OP) {
> -                               *credits -= 1;
> -                               server->in_flight++;
> +                               *credits -= num_credits;
> +                               server->in_flight += num_credits;
>                                 *instance = server->reconnect_instance;
>                         }
>                         spin_unlock(&server->req_lock);
> @@ -541,7 +541,7 @@ static int
>  wait_for_free_request(struct TCP_Server_Info *server, const int flags,
>                       unsigned int *instance)
>  {
> -       return wait_for_free_credits(server, flags, instance);
> +       return wait_for_free_credits(server, 1, flags, instance);
>  }
>
>  int
> --
> 2.13.6
>

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

  reply	other threads:[~2019-03-09  0:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-08  2:58 [PATCH 0/6] cifs: simplify handling of credits for compounds Ronnie Sahlberg
2019-03-08  2:58 ` [PATCH 1/6] cifs: change wait_for_free_request() to take flags as argument Ronnie Sahlberg
2019-03-09  0:53   ` Pavel Shilovsky
2019-03-08  2:58 ` [PATCH 2/6] cifs: pass flags down into wait_for_free_credits() Ronnie Sahlberg
2019-03-09  0:54   ` Pavel Shilovsky
2019-03-08  2:58 ` [PATCH 3/6] cifs: wait_for_free_credits() make it possible to wait for >=1 credits Ronnie Sahlberg
2019-03-09  0:54   ` Pavel Shilovsky [this message]
2019-03-08  2:58 ` [PATCH 4/6] cifs: prevent starvation in wait_for_free_credits for multi-credit requests Ronnie Sahlberg
2019-03-09  0:55   ` Pavel Shilovsky
2019-03-08  2:58 ` [PATCH 5/6] cifs: add a timeout argument to wait_for_free_credits Ronnie Sahlberg
2019-03-09  0:58   ` Pavel Shilovsky
     [not found]     ` <CAH2r5ms3METKgX9sMet44r0RKdVAEe_x=vuB_6JZobJn95x4_Q@mail.gmail.com>
2019-03-09  1:06       ` Pavel Shilovsky
2019-03-10  2:21     ` Steve French
2019-03-08  2:58 ` [PATCH 6/6] cifs: simplify how we handle credits in compond_send_recv() Ronnie Sahlberg
2019-03-09  0:53   ` Pavel Shilovsky
2019-03-09 22:04     ` Steve French
  -- strict thread matches above, loose matches on Subject: below --
2019-03-06  4:15 [PATCH 0/6] cifs: simplify handling of credits for compounds Ronnie Sahlberg
2019-03-06  4:15 ` [PATCH 3/6] cifs: wait_for_free_credits() make it possible to wait for >=1 credits Ronnie Sahlberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKywueTgMupDPkPkeUXa6281o3mWANeGrzfswyXH8LaAk8W5SQ@mail.gmail.com \
    --to=piastryyy@gmail.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=lsahlber@redhat.com \
    --cc=pshilov@microsoft.com \
    --cc=smfrench@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).