Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Pavel Shilovsky <pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v5 2/5] CIFS: Extend credit mechanism to process request type
Date: Tue, 19 Jun 2012 15:00:17 -0700	[thread overview]
Message-ID: <20120619150017.73546a39@corrin.poochiereds.net> (raw)
In-Reply-To: <CAKywueQw8YaZ0=3Mv-UNZxur=dg_D59m352Msq+hZjsWEHqr1A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Tue, 19 Jun 2012 23:53:06 +0400
Pavel Shilovsky <pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org> wrote:

> 2012/6/19 Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>:
> > On Sat,  9 Jun 2012 10:26:01 +0400
> > Pavel Shilovsky <pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org> wrote:
> >
> >> Split all requests to echos, oplocks and others - each group uses
> >> its own credit slot. This is indicated by new flags
> >>
> >> CIFS_ECHO_OP and CIFS_OBREAK_OP
> >>
> >> that are not used now for CIFS. This change is required to support
> >> SMB2 protocol because of different processing of these commands.
> >>
> >> Signed-off-by: Pavel Shilovsky <pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
> >> ---
> >>  fs/cifs/cifsglob.h  |   16 +++++++++++---
> >>  fs/cifs/cifsproto.h |    2 +-
> >>  fs/cifs/cifssmb.c   |   21 ++++++++++---------
> >>  fs/cifs/smb1ops.c   |   12 +++++++++-
> >>  fs/cifs/transport.c |   54 +++++++++++++++++++++++++++++---------------------
> >>  5 files changed, 65 insertions(+), 40 deletions(-)
> >>
> >> diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
> >> index 2aac4e5..844b77c 100644
> >> --- a/fs/cifs/cifsglob.h
> >> +++ b/fs/cifs/cifsglob.h
> >> @@ -171,9 +171,11 @@ struct smb_version_operations {
> >>       /* check response: verify signature, map error */
> >>       int (*check_receive)(struct mid_q_entry *, struct TCP_Server_Info *,
> >>                            bool);
> >> -     void (*add_credits)(struct TCP_Server_Info *, const unsigned int);
> >> +     void (*add_credits)(struct TCP_Server_Info *, const unsigned int,
> >> +                         const int);
> >>       void (*set_credits)(struct TCP_Server_Info *, const int);
> >> -     int * (*get_credits_field)(struct TCP_Server_Info *);
> >> +     int * (*get_credits_field)(struct TCP_Server_Info *, const int);
> >> +     unsigned int (*get_credits)(struct mid_q_entry *);
> >>       __u64 (*get_next_mid)(struct TCP_Server_Info *);
> >>       /* data offset from read response message */
> >>       unsigned int (*read_data_offset)(char *);
> >> @@ -392,9 +394,10 @@ has_credits(struct TCP_Server_Info *server, int *credits)
> >>  }
> >>
> >>  static inline void
> >> -add_credits(struct TCP_Server_Info *server, const unsigned int add)
> >> +add_credits(struct TCP_Server_Info *server, const unsigned int add,
> >> +         const int optype)
> >>  {
> >> -     server->ops->add_credits(server, add);
> >> +     server->ops->add_credits(server, add, optype);
> >>  }
> >>
> >>  static inline void
> >> @@ -957,6 +960,11 @@ static inline void free_dfs_info_array(struct dfs_info3_param *param,
> >>  #define   CIFS_LARGE_BUF_OP 0x020    /* large request buffer */
> >>  #define   CIFS_NO_RESP      0x040    /* no response buffer required */
> >>
> >> +/* Type of request operation */
> >> +#define   CIFS_ECHO_OP      0x080    /* echo request */
> >> +#define   CIFS_OBREAK_OP   0x0100    /* oplock break request */
> >> +#define   CIFS_OP_MASK     0x0180    /* mask request type */
> >> +
> >>  /* Security Flags: indicate type of session setup needed */
> >>  #define   CIFSSEC_MAY_SIGN   0x00001
> >>  #define   CIFSSEC_MAY_NTLM   0x00002
> >> diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
> >> index 0a6cbfe..8c1c7c1 100644
> >> --- a/fs/cifs/cifsproto.h
> >> +++ b/fs/cifs/cifsproto.h
> >> @@ -71,7 +71,7 @@ extern void DeleteMidQEntry(struct mid_q_entry *midEntry);
> >>  extern int cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov,
> >>                          unsigned int nvec, mid_receive_t *receive,
> >>                          mid_callback_t *callback, void *cbdata,
> >> -                        bool ignore_pend);
> >> +                        const int flags);
> >>  extern int SendReceive(const unsigned int /* xid */ , struct cifs_ses *,
> >>                       struct smb_hdr * /* input */ ,
> >>                       struct smb_hdr * /* out */ ,
> >> diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
> >> index 5b40073..58f1ab5 100644
> >> --- a/fs/cifs/cifssmb.c
> >> +++ b/fs/cifs/cifssmb.c
> >> @@ -720,7 +720,7 @@ cifs_echo_callback(struct mid_q_entry *mid)
> >>       struct TCP_Server_Info *server = mid->callback_data;
> >>
> >>       DeleteMidQEntry(mid);
> >> -     add_credits(server, 1);
> >> +     add_credits(server, 1, CIFS_ECHO_OP);
> >>  }
> >>
> >>  int
> >> @@ -747,7 +747,7 @@ CIFSSMBEcho(struct TCP_Server_Info *server)
> >>       iov.iov_len = be32_to_cpu(smb->hdr.smb_buf_length) + 4;
> >>
> >>       rc = cifs_call_async(server, &iov, 1, NULL, cifs_echo_callback,
> >> -                          server, true);
> >> +                          server, CIFS_ASYNC_OP | CIFS_ECHO_OP);
> >>       if (rc)
> >>               cFYI(1, "Echo request failed: %d", rc);
> >>
> >> @@ -1563,7 +1563,7 @@ cifs_readv_callback(struct mid_q_entry *mid)
> >>
> >>       queue_work(cifsiod_wq, &rdata->work);
> >>       DeleteMidQEntry(mid);
> >> -     add_credits(server, 1);
> >> +     add_credits(server, 1, 0);
> >>  }
> >>
> >>  /* cifs_async_readv - send an async write, and set up mid to handle result */
> >> @@ -1619,7 +1619,7 @@ cifs_async_readv(struct cifs_readdata *rdata)
> >>       kref_get(&rdata->refcount);
> >>       rc = cifs_call_async(tcon->ses->server, rdata->iov, 1,
> >>                            cifs_readv_receive, cifs_readv_callback,
> >> -                          rdata, false);
> >> +                          rdata, 0);
> >>
> >>       if (rc == 0)
> >>               cifs_stats_inc(&tcon->num_reads);
> >> @@ -2010,7 +2010,7 @@ cifs_writev_callback(struct mid_q_entry *mid)
> >>
> >>       queue_work(cifsiod_wq, &wdata->work);
> >>       DeleteMidQEntry(mid);
> >> -     add_credits(tcon->ses->server, 1);
> >> +     add_credits(tcon->ses->server, 1, 0);
> >>  }
> >>
> >>  /* cifs_async_writev - send an async write, and set up mid to handle result */
> >> @@ -2090,7 +2090,7 @@ cifs_async_writev(struct cifs_writedata *wdata)
> >>
> >>       kref_get(&wdata->refcount);
> >>       rc = cifs_call_async(tcon->ses->server, iov, wdata->nr_pages + 1,
> >> -                          NULL, cifs_writev_callback, wdata, false);
> >> +                          NULL, cifs_writev_callback, wdata, 0);
> >>
> >>       if (rc == 0)
> >>               cifs_stats_inc(&tcon->num_writes);
> >> @@ -2268,7 +2268,7 @@ CIFSSMBLock(const int xid, struct cifs_tcon *tcon,
> >>       LOCK_REQ *pSMB = NULL;
> >>  /*   LOCK_RSP *pSMBr = NULL; */ /* No response data other than rc to parse */
> >>       int bytes_returned;
> >> -     int timeout = 0;
> >> +     int flags = 0;
> >>       __u16 count;
> >>
> >>       cFYI(1, "CIFSSMBLock timeout %d numLock %d", (int)waitFlag, numLock);
> >> @@ -2278,10 +2278,11 @@ CIFSSMBLock(const int xid, struct cifs_tcon *tcon,
> >>               return rc;
> >>
> >>       if (lockType == LOCKING_ANDX_OPLOCK_RELEASE) {
> >> -             timeout = CIFS_ASYNC_OP; /* no response expected */
> >> +             /* no response expected */
> >> +             flags = CIFS_ASYNC_OP | CIFS_OBREAK_OP;
> >>               pSMB->Timeout = 0;
> >>       } else if (waitFlag) {
> >> -             timeout = CIFS_BLOCKING_OP; /* blocking operation, no timeout */
> >> +             flags = CIFS_BLOCKING_OP; /* blocking operation, no timeout */
> >>               pSMB->Timeout = cpu_to_le32(-1);/* blocking - do not time out */
> >>       } else {
> >>               pSMB->Timeout = 0;
> >> @@ -2314,7 +2315,7 @@ CIFSSMBLock(const int xid, struct cifs_tcon *tcon,
> >>                       (struct smb_hdr *) pSMB, &bytes_returned);
> >>               cifs_small_buf_release(pSMB);
> >>       } else {
> >> -             rc = SendReceiveNoRsp(xid, tcon->ses, (char *)pSMB, timeout);
> >> +             rc = SendReceiveNoRsp(xid, tcon->ses, (char *)pSMB, flags);
> >>               /* SMB buffer freed by function above */
> >>       }
> >>       cifs_stats_inc(&tcon->num_locks);
> >> diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
> >> index 28359e7..f4f8394 100644
> >> --- a/fs/cifs/smb1ops.c
> >> +++ b/fs/cifs/smb1ops.c
> >> @@ -101,7 +101,8 @@ cifs_find_mid(struct TCP_Server_Info *server, char *buffer)
> >>  }
> >>
> >>  static void
> >> -cifs_add_credits(struct TCP_Server_Info *server, const unsigned int add)
> >> +cifs_add_credits(struct TCP_Server_Info *server, const unsigned int add,
> >> +              const int optype)
> >>  {
> >>       spin_lock(&server->req_lock);
> >>       server->credits += add;
> >> @@ -120,11 +121,17 @@ cifs_set_credits(struct TCP_Server_Info *server, const int val)
> >>  }
> >>
> >>  static int *
> >> -cifs_get_credits_field(struct TCP_Server_Info *server)
> >> +cifs_get_credits_field(struct TCP_Server_Info *server, const int optype)
> >>  {
> >>       return &server->credits;
> >>  }
> >>
> >> +static unsigned int
> >> +cifs_get_credits(struct mid_q_entry *mid)
> >> +{
> >> +     return 1;
> >> +}
> >> +
> >>  /*
> >>   * Find a free multiplex id (SMB mid). Otherwise there could be
> >>   * mid collisions which might cause problems, demultiplexing the
> >> @@ -390,6 +397,7 @@ struct smb_version_operations smb1_operations = {
> >>       .add_credits = cifs_add_credits,
> >>       .set_credits = cifs_set_credits,
> >>       .get_credits_field = cifs_get_credits_field,
> >> +     .get_credits = cifs_get_credits,
> >>       .get_next_mid = cifs_get_next_mid,
> >>       .read_data_offset = cifs_read_data_offset,
> >>       .read_data_length = cifs_read_data_length,
> >> diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
> >> index 3097ee5..54cd8dd 100644
> >> --- a/fs/cifs/transport.c
> >> +++ b/fs/cifs/transport.c
> >> @@ -254,13 +254,13 @@ 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 optype,
> >> +wait_for_free_credits(struct TCP_Server_Info *server, const int long_op,
> >>                     int *credits)
> >>  {
> >>       int rc;
> >>
> >>       spin_lock(&server->req_lock);
> >> -     if (optype == CIFS_ASYNC_OP) {
> >> +     if (long_op == CIFS_ASYNC_OP) {
> >>               /* oplock breaks must not be held up */
> >>               server->in_flight++;
> >>               *credits -= 1;
> >> @@ -290,7 +290,7 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int optype,
> >>                        */
> >>
> >>                       /* update # of requests on the wire to server */
> >> -                     if (optype != CIFS_BLOCKING_OP) {
> >> +                     if (long_op != CIFS_BLOCKING_OP) {
> >>                               *credits -= 1;
> >>                               server->in_flight++;
> >>                       }
> >
> > Why rename the variable in this above function? "optype" seems like a better name...
> 
> That was done to make variable names the same: 'optype' is used to
> indicate if it is echo, oplock or other operation, 'long_op' is used
> to indicate if we need any special behavior (aysnc, blocking).
> 
> wait_for_free_request function (below) takes both 'optype' and
> 'long_op' and passes 'long_op' to wait_for_free_credits. It is cleaner
> if wait_for_free_credits uses the same name - 'long_op'.
> 
> Of course, 'long_op' may be not so good name at all (I took it from
> the old code) - suggestions are welcome.
> 

Yeah, I think that's the confusion. "long_op" was from when those flags
were supposed to indicate the length of the operation so the code could
adjust the timeout. Maybe a better name is something generic like
"flags" ?

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

  parent reply	other threads:[~2012-06-19 22:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-09  6:25 [PATCH v5 0/5] transport/session code move to ops struct Pavel Shilovsky
     [not found] ` <1339223164-9721-1-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-06-09  6:26   ` [PATCH v5 1/5] CIFS: Move trans2 processing " Pavel Shilovsky
2012-06-09  6:26   ` [PATCH v5 2/5] CIFS: Extend credit mechanism to process request type Pavel Shilovsky
     [not found]     ` <1339223164-9721-3-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-06-19 15:31       ` Jeff Layton
     [not found]         ` <20120619083156.761f8a31-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2012-06-19 19:53           ` Pavel Shilovsky
     [not found]             ` <CAKywueQw8YaZ0=3Mv-UNZxur=dg_D59m352Msq+hZjsWEHqr1A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-19 22:00               ` Jeff Layton [this message]
     [not found]                 ` <20120619150017.73546a39-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2012-06-19 23:57                   ` Steve French
     [not found]                     ` <CAH2r5muXdc708-HtceH02y8TBcoAXmi_qjyay0qHeZdtmoxVZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-20  7:12                       ` Pavel Shilovsky
2012-06-09  6:26   ` [PATCH v5 3/5] CIFS: Move protocol specific negotiate code to ops struct Pavel Shilovsky
     [not found]     ` <1339223164-9721-4-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-06-19 15:39       ` Jeff Layton
2012-06-09  6:26   ` [PATCH v5 4/5] CIFS: Move protocol specific session setup/logoff " Pavel Shilovsky
     [not found]     ` <1339223164-9721-5-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-06-19 15:51       ` Jeff Layton
     [not found]         ` <20120619085159.6bac54fa-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2012-06-19 19:21           ` Pavel Shilovsky
     [not found]             ` <CAKywueSt2b5jYMNnnuGK+r_FPXifATBFfPGq9OeyycK8Y=sgGQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-19 19:31               ` Steve French
2012-06-09  6:26   ` [PATCH v5 5/5] CIFS: Move protocol specific tcon/tdis " Pavel Shilovsky
     [not found]     ` <1339223164-9721-6-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-06-19 15:59       ` Jeff Layton
     [not found]         ` <20120619085940.337536ed-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2012-06-19 16:15           ` Steve French

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=20120619150017.73546a39@corrin.poochiereds.net \
    --to=jlayton-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=pshilovsky-eUNUBHrolfbYtjvyW6yDsg@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox