All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Pavel Shilovsky <piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2 05/11] CIFS: Prepare credits code for a slot reservation
Date: Mon, 19 Mar 2012 15:27:02 -0400	[thread overview]
Message-ID: <20120319152702.3eee1608@redhat.com> (raw)
In-Reply-To: <1331910574-998-6-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>

On Fri, 16 Mar 2012 18:09:28 +0300
Pavel Shilovsky <piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org> wrote:

> that is essential for CIFS/SMB/SMB2 oplock breaks and SMB2 echos.
> 
> Signed-off-by: Pavel Shilovsky <piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
> ---
>  fs/cifs/cifsglob.h  |   14 ++++++++++++--
>  fs/cifs/transport.c |   22 ++++++++++++++--------
>  2 files changed, 26 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
> index d55de96..2309a67 100644
> --- a/fs/cifs/cifsglob.h
> +++ b/fs/cifs/cifsglob.h
> @@ -315,12 +315,22 @@ in_flight(struct TCP_Server_Info *server)
>  	return num;
>  }
>  
> +static inline int*
> +get_credits_field(struct TCP_Server_Info *server)
> +{
> +	/*
> +	 * This will change to switch statement when we reserve slots for echos
> +	 * and oplock breaks.
> +	 */
> +	return &server->credits;
> +}
> +
>  static inline bool
> -has_credits(struct TCP_Server_Info *server)
> +has_credits(struct TCP_Server_Info *server, int *credits)

Why are you passing "credits" by reference here? Might as well pass by
value...

>  {
>  	int num;
>  	spin_lock(&server->req_lock);
> -	num = server->credits;
> +	num = *credits;
>  	spin_unlock(&server->req_lock);
>  	return num > 0;
>  }
> diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
> index 11787cc..20dc7ba 100644
> --- a/fs/cifs/transport.c
> +++ b/fs/cifs/transport.c
> @@ -255,26 +255,26 @@ smb_send(struct TCP_Server_Info *server, struct smb_hdr *smb_buffer,
>  }
>  
>  static int
> -wait_for_free_request(struct TCP_Server_Info *server, const int long_op)
> +wait_for_free_credits(struct TCP_Server_Info *server, const int optype,
> +		      int *credits)
>  {
>  	int rc;
>  
>  	spin_lock(&server->req_lock);
> -
> -	if (long_op == CIFS_ASYNC_OP) {
> +	if (optype == CIFS_ASYNC_OP) {
>  		/* oplock breaks must not be held up */
>  		server->in_flight++;
> -		server->credits--;
> +		*credits -= 1;
>  		spin_unlock(&server->req_lock);
>  		return 0;
>  	}
>  
>  	while (1) {
> -		if (server->credits <= 0) {
> +		if (*credits <= 0) {
>  			spin_unlock(&server->req_lock);
>  			cifs_num_waiters_inc(server);
>  			rc = wait_event_killable(server->request_q,
> -						 has_credits(server));
> +						 has_credits(server, credits));
>  			cifs_num_waiters_dec(server);
>  			if (rc)
>  				return rc;
> @@ -291,8 +291,8 @@ wait_for_free_request(struct TCP_Server_Info *server, const int long_op)
>  			 */
>  
>  			/* update # of requests on the wire to server */
> -			if (long_op != CIFS_BLOCKING_OP) {
> -				server->credits--;
> +			if (optype != CIFS_BLOCKING_OP) {
> +				*credits -= 1;
>  				server->in_flight++;
>  			}
>  			spin_unlock(&server->req_lock);
> @@ -302,6 +302,12 @@ wait_for_free_request(struct TCP_Server_Info *server, const int long_op)
>  	return 0;
>  }
>  
> +static int
> +wait_for_free_request(struct TCP_Server_Info *server, const int optype)
> +{
> +	return wait_for_free_credits(server, optype, get_credits_field(server));
> +}
> +
>  static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf,
>  			struct mid_q_entry **ppmidQ)
>  {


Other than that nit, this looks fine...

Reviewed-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

  parent reply	other threads:[~2012-03-19 19:27 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-16 15:09 [PATCH v2 00/11] Prepare transport code for future SMB2 usage Pavel Shilovsky
     [not found] ` <1331910574-998-1-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2012-03-16 15:09   ` [PATCH v2 01/11] CIFS: Respect negotiated MaxMpxCount Pavel Shilovsky
     [not found]     ` <1331910574-998-2-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2012-03-17 11:12       ` Jeff Layton
     [not found]         ` <20120317071201.7f28683b-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2012-03-17 14:53           ` Pavel Shilovsky
     [not found]             ` <CAKywueTDsGhcHiGM_uX6V0dnY3m_W4kD2qcb+JWRq=UVnBnvPw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-17 15:20               ` Steve French
     [not found]                 ` <CAH2r5msMKiEyS2-ak2+tQoRFommSHRcCNwp-J+XtgovmSae7-A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-18 10:33                   ` Jeff Layton
2012-03-18 10:50                   ` Jeff Layton
     [not found]                     ` <20120318065059.62592afb-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2012-03-18 18:23                       ` Pavel Shilovsky
     [not found]                         ` <CAKywueSrGVvwqHbTK3sNLsHDx3vR6U0Ca712ZXKNTnjnOgPGDA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-19 15:04                           ` Jeff Layton
     [not found]                             ` <20120319110437.635ea546-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2012-03-19 19:04                               ` Pavel Shilovsky
     [not found]                                 ` <CAKywueR2mWNKxNDhhj_0i0TfiPz3nmvVBXbxGMZ+Lrbgts3cDQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-19 19:32                                   ` Steve French
     [not found]                                     ` <CAH2r5mvhTYPxvDRFCpQ0ULmDn2TNQ80ODbnvTmgFurptYukR1Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-19 19:39                                       ` Jeff Layton
2012-03-16 15:09   ` [PATCH v2 02/11] CIFS: Simplify inFlight logic Pavel Shilovsky
     [not found]     ` <1331910574-998-3-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2012-03-17 11:07       ` Jeff Layton
2012-03-16 15:09   ` [PATCH v2 03/11] CIFS: Introduce credit-based flow control Pavel Shilovsky
     [not found]     ` <1331910574-998-4-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2012-03-17 10:32       ` Jeff Layton
     [not found]         ` <20120317063258.77618c0e-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2012-03-17 14:56           ` Pavel Shilovsky
2012-03-16 15:09   ` [PATCH v2 04/11] CIFS: Make wait_for_free_request killable Pavel Shilovsky
     [not found]     ` <1331910574-998-5-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2012-03-17 11:13       ` Jeff Layton
2012-03-16 15:09   ` [PATCH v2 05/11] CIFS: Prepare credits code for a slot reservation Pavel Shilovsky
     [not found]     ` <1331910574-998-6-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2012-03-19 19:27       ` Jeff Layton [this message]
     [not found]         ` <20120319152702.3eee1608-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-03-20  7:03           ` Pavel Shilovsky
2012-03-16 15:09   ` [PATCH v2 06/11] CIFS: Delete echo_retries module parm Pavel Shilovsky
     [not found]     ` <1331910574-998-7-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2012-03-18 10:30       ` Jeff Layton
2012-03-16 15:09   ` [PATCH v2 07/11] CIFS: Separate protocol-specific code from transport routines Pavel Shilovsky
     [not found]     ` <1331910574-998-8-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2012-03-19 19:31       ` Jeff Layton
2012-03-16 15:09   ` [PATCH v2 08/11] CIFS: Separate protocol-specific code from demultiplex code Pavel Shilovsky
     [not found]     ` <1331910574-998-9-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2012-03-19 19:41       ` Jeff Layton
     [not found]         ` <20120319154150.03713caf-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-03-20  7:29           ` Pavel Shilovsky
     [not found]             ` <CAKywueTxicF658ys1yBzC_95qw0v8R+6pxuhZ_zc+aRKyRLFdw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-20 10:22               ` Jeff Layton
2012-03-16 15:09   ` [PATCH v2 09/11] CIFS: Separate protocol-specific code from cifs_readv_receive code Pavel Shilovsky
     [not found]     ` <1331910574-998-10-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2012-03-19 20:17       ` Jeff Layton
     [not found]         ` <20120319161728.1f8cec40-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-03-20  7:33           ` Pavel Shilovsky
     [not found]             ` <CAKywueSvsb+BP7ktb0QEgL3WmrO8j42bicvd-WjWNro6qGRc7w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-20 10:24               ` Jeff Layton
     [not found]                 ` <20120320062414.554a033c-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2012-03-20 10:54                   ` Pavel Shilovsky
2012-03-16 15:09   ` [PATCH v2 10/11] CIFS: Expand CurrentMid field Pavel Shilovsky
     [not found]     ` <1331910574-998-11-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2012-03-19 20:24       ` Jeff Layton
     [not found]         ` <20120319162410.42b95f13-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-03-19 20:48           ` Steve French
     [not found]             ` <CAH2r5mujZook3O2Ojvu+vjx5Y5uYuormbtbDW69iOLEf1XVQgg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-20  7:37               ` Pavel Shilovsky
     [not found]                 ` <CAKywueTpa6Hmz7oQ=8S1ViRU9ky7wqhKN+f=eaWrJY1457X86w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-20 10:28                   ` Jeff Layton
     [not found]                     ` <20120320062843.1cd218ed-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2012-03-20 22:21                       ` Steve French
2012-03-16 15:09   ` [PATCH v2 11/11] CIFS: Change mid_q_entry structure fields Pavel Shilovsky
     [not found]     ` <1331910574-998-12-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2012-03-19 20:28       ` Jeff Layton

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=20120319152702.3eee1608@redhat.com \
    --to=jlayton-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.