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 3/5] CIFS: Move protocol specific negotiate code to ops struct
Date: Tue, 19 Jun 2012 08:39:21 -0700 [thread overview]
Message-ID: <20120619083921.66a18adc@corrin.poochiereds.net> (raw)
In-Reply-To: <1339223164-9721-4-git-send-email-pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
On Sat, 9 Jun 2012 10:26:02 +0400
Pavel Shilovsky <pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org> wrote:
> Signed-off-by: Pavel Shilovsky <pshilovsky-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
> ---
> fs/cifs/cifsglob.h | 8 ++++++--
> fs/cifs/cifsproto.h | 5 ++---
> fs/cifs/cifssmb.c | 4 ++--
> fs/cifs/connect.c | 21 +++++++++------------
> fs/cifs/sess.c | 2 +-
> fs/cifs/smb1ops.c | 23 +++++++++++++++++++++++
> 6 files changed, 43 insertions(+), 20 deletions(-)
>
> diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
> index 844b77c..669de88 100644
> --- a/fs/cifs/cifsglob.h
> +++ b/fs/cifs/cifsglob.h
> @@ -192,6 +192,10 @@ struct smb_version_operations {
> /* process transaction2 response */
> bool (*check_trans2)(struct mid_q_entry *, struct TCP_Server_Info *,
> char *, int);
> + /* check if we need to negotiate */
> + bool (*need_neg)(struct TCP_Server_Info *);
> + /* negotiate to the server */
> + int (*negotiate)(const int, struct cifs_ses *);
> };
>
> struct smb_version_values {
> @@ -324,7 +328,7 @@ struct TCP_Server_Info {
> struct mutex srv_mutex;
> struct task_struct *tsk;
> char server_GUID[16];
> - char sec_mode;
> + __u16 sec_mode;
> bool session_estab; /* mark when very first sess is established */
> u16 dialect; /* dialect index that server chose */
> enum securityEnum secType;
> @@ -459,7 +463,7 @@ struct cifs_ses {
> char *serverOS; /* name of operating system underlying server */
> char *serverNOS; /* name of network operating system of server */
> char *serverDomain; /* security realm of server */
> - int Suid; /* remote smb uid */
> + __u64 Suid; /* remote smb uid */
> uid_t linux_uid; /* overriding owner of files on the mount */
> uid_t cred_uid; /* owner of credentials */
> int capabilities;
> diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
> index 8c1c7c1..32b569f 100644
> --- a/fs/cifs/cifsproto.h
> +++ b/fs/cifs/cifsproto.h
> @@ -178,11 +178,10 @@ extern void cifs_dfs_release_automount_timer(void);
> void cifs_proc_init(void);
> void cifs_proc_clean(void);
>
> -extern int cifs_negotiate_protocol(unsigned int xid,
> - struct cifs_ses *ses);
> +extern int cifs_negotiate_protocol(const int xid, struct cifs_ses *ses);
> extern int cifs_setup_session(unsigned int xid, struct cifs_ses *ses,
> struct nls_table *nls_info);
> -extern int CIFSSMBNegotiate(unsigned int xid, struct cifs_ses *ses);
> +extern int CIFSSMBNegotiate(const int xid, struct cifs_ses *ses);
>
> extern int CIFSTCon(unsigned int xid, struct cifs_ses *ses,
> const char *tree, struct cifs_tcon *tcon,
> diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
> index 58f1ab5..fbc5628 100644
> --- a/fs/cifs/cifssmb.c
> +++ b/fs/cifs/cifssmb.c
> @@ -372,7 +372,7 @@ static inline void inc_rfc1001_len(void *pSMB, int count)
> }
>
> int
> -CIFSSMBNegotiate(unsigned int xid, struct cifs_ses *ses)
> +CIFSSMBNegotiate(const int xid, struct cifs_ses *ses)
> {
> NEGOTIATE_REQ *pSMB;
> NEGOTIATE_RSP *pSMBr;
> @@ -456,7 +456,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifs_ses *ses)
> rc = -EOPNOTSUPP;
> goto neg_err_exit;
> }
> - server->sec_mode = (__u8)le16_to_cpu(rsp->SecurityMode);
> + server->sec_mode = le16_to_cpu(rsp->SecurityMode);
> server->maxReq = min_t(unsigned int,
> le16_to_cpu(rsp->MaxMpxCount),
> cifs_max_pending);
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index ca0288d..4780342 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -406,7 +406,7 @@ cifs_echo_request(struct work_struct *work)
> * done, which is indicated by maxBuf != 0. Also, no need to ping if
> * we got a response recently
> */
> - if (server->maxBuf == 0 ||
> + if (!server->ops->need_neg || server->ops->need_neg(server) ||
> time_before(jiffies, server->lstrp + SMB_ECHO_INTERVAL - HZ))
> goto requeue_echo;
>
> @@ -3942,24 +3942,22 @@ cifs_umount(struct cifs_sb_info *cifs_sb)
> kfree(cifs_sb);
> }
>
> -int cifs_negotiate_protocol(unsigned int xid, struct cifs_ses *ses)
> +int
> +cifs_negotiate_protocol(const int xid, struct cifs_ses *ses)
> {
> int rc = 0;
> struct TCP_Server_Info *server = ses->server;
>
> + if (!server->ops->need_neg || !server->ops->negotiate)
> + return -ENOSYS;
> +
> /* only send once per connect */
> - if (server->maxBuf != 0)
> + if (!server->ops->need_neg(server))
> return 0;
>
> set_credits(server, 1);
> - rc = CIFSSMBNegotiate(xid, ses);
> - if (rc == -EAGAIN) {
> - /* retry only once on 1st time connection */
> - set_credits(server, 1);
> - rc = CIFSSMBNegotiate(xid, ses);
> - if (rc == -EAGAIN)
> - rc = -EHOSTDOWN;
> - }
> +
> + rc = server->ops->negotiate(xid, ses);
> if (rc == 0) {
> spin_lock(&GlobalMid_Lock);
> if (server->tcpStatus == CifsNeedNegotiate)
> @@ -3967,7 +3965,6 @@ int cifs_negotiate_protocol(unsigned int xid, struct cifs_ses *ses)
> else
> rc = -EHOSTDOWN;
> spin_unlock(&GlobalMid_Lock);
> -
> }
>
> return rc;
> diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
> index 551d0c2..f88fa4d 100644
> --- a/fs/cifs/sess.c
> +++ b/fs/cifs/sess.c
> @@ -898,7 +898,7 @@ ssetup_ntlmssp_authenticate:
> if (action & GUEST_LOGIN)
> cFYI(1, "Guest login"); /* BB mark SesInfo struct? */
> ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */
> - cFYI(1, "UID = %d ", ses->Suid);
> + cFYI(1, "UID = %llu ", ses->Suid);
> /* response can have either 3 or 4 word count - Samba sends 3 */
> /* and lanman response is 3 */
> bytes_remaining = get_bcc(smb_buf);
> diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
> index f4f8394..5bfc26a 100644
> --- a/fs/cifs/smb1ops.c
> +++ b/fs/cifs/smb1ops.c
> @@ -389,6 +389,27 @@ cifs_check_trans2(struct mid_q_entry *mid, struct TCP_Server_Info *server,
> return true;
> }
>
> +static bool
> +cifs_need_neg(struct TCP_Server_Info *server)
> +{
> + return server->maxBuf == 0;
> +}
> +
> +static int
> +cifs_negotiate(const int xid, struct cifs_ses *ses)
> +{
> + int rc;
> + rc = CIFSSMBNegotiate(xid, ses);
> + if (rc == -EAGAIN) {
> + /* retry only once on 1st time connection */
> + set_credits(ses->server, 1);
> + rc = CIFSSMBNegotiate(xid, ses);
> + if (rc == -EAGAIN)
> + rc = -EHOSTDOWN;
> + }
> + return rc;
> +}
> +
> struct smb_version_operations smb1_operations = {
> .send_cancel = send_nt_cancel,
> .compare_fids = cifs_compare_fids,
> @@ -407,6 +428,8 @@ struct smb_version_operations smb1_operations = {
> .dump_detail = cifs_dump_detail,
> .is_oplock_break = is_valid_oplock_break,
> .check_trans2 = cifs_check_trans2,
> + .need_neg = cifs_need_neg,
> + .negotiate = cifs_negotiate,
> };
>
> struct smb_version_values smb1_values = {
Reviewed-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
next prev parent reply other threads:[~2012-06-19 15:39 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
[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 [this message]
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=20120619083921.66a18adc@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