Skip to content

Commit 1080ef7

Browse files
Steve Frenchpiastry
Steve French
authored andcommitted
CIFS: Introduce SMB2 mounts as vers=2.1
As with Linux nfs client, which uses "nfsvers=" or "vers=" to indicate which protocol to use for mount, specifying "vers=2.1" will force an SMB2 mount. When vers is not specified CIFS is used "vers=1" We can eventually autonegotiate down from SMB2 to CIFS when SMB2 is stable enough to make it the default, but this is for the future. At that time we could also implement a "maxprotocol" mount option as smbclient and Samba have today, but that would be premature until SMB2 is stable. Intially the SMB2 Kconfig option will depend on "BROKEN" until the merge is complete, and then be "EXPERIMENTAL" When it is no longer experimental we can consider changing the default protocol to attempt first. Signed-off-by: Pavel Shilovsky <[email protected]> Signed-off-by: Jeff Layton <[email protected]> Acked-by: Shirish Pargaonkar <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 675f36f commit 1080ef7

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

fs/cifs/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ cifs-$(CONFIG_CIFS_UPCALL) += cifs_spnego.o
1515
cifs-$(CONFIG_CIFS_DFS_UPCALL) += dns_resolve.o cifs_dfs_ref.o
1616

1717
cifs-$(CONFIG_CIFS_FSCACHE) += fscache.o cache.o
18+
19+
cifs-$(CONFIG_CIFS_SMB2) += smb2ops.o

fs/cifs/cifsglob.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ struct cifs_cred {
152152

153153
enum smb_version {
154154
Smb_1 = 1,
155+
Smb_21,
155156
};
156157

157158
struct mid_q_entry;
@@ -1122,4 +1123,7 @@ extern struct workqueue_struct *cifsiod_wq;
11221123
#define SMB1_VERSION_STRING "1.0"
11231124
extern struct smb_version_operations smb1_operations;
11241125
extern struct smb_version_values smb1_values;
1126+
#define SMB21_VERSION_STRING "2.1"
1127+
extern struct smb_version_operations smb21_operations;
1128+
extern struct smb_version_values smb21_values;
11251129
#endif /* _CIFS_GLOB_H */

fs/cifs/connect.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* fs/cifs/connect.c
33
*
4-
* Copyright (C) International Business Machines Corp., 2002,2009
4+
* Copyright (C) International Business Machines Corp., 2002,2011
55
* Author(s): Steve French ([email protected])
66
*
77
* This library is free software; you can redistribute it and/or modify
@@ -278,6 +278,7 @@ static const match_table_t cifs_cacheflavor_tokens = {
278278

279279
static const match_table_t cifs_smb_version_tokens = {
280280
{ Smb_1, SMB1_VERSION_STRING },
281+
{ Smb_21, SMB21_VERSION_STRING },
281282
};
282283

283284
static int ip_connect(struct TCP_Server_Info *server);
@@ -1221,6 +1222,12 @@ cifs_parse_smb_version(char *value, struct smb_vol *vol)
12211222
vol->ops = &smb1_operations;
12221223
vol->vals = &smb1_values;
12231224
break;
1225+
#ifdef CONFIG_CIFS_SMB2
1226+
case Smb_21:
1227+
vol->ops = &smb21_operations;
1228+
vol->vals = &smb21_values;
1229+
break;
1230+
#endif
12241231
default:
12251232
cERROR(1, "Unknown vers= option specified: %s", value);
12261233
return 1;

fs/cifs/smb2ops.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* SMB2 version specific operations
3+
*
4+
* Copyright (c) 2012, Jeff Layton <[email protected]>
5+
*
6+
* This library is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License v2 as published
8+
* by the Free Software Foundation.
9+
*
10+
* This library is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13+
* the GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this library; if not, write to the Free Software
17+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18+
*/
19+
20+
#include "cifsglob.h"
21+
22+
struct smb_version_operations smb21_operations = {
23+
};
24+
25+
struct smb_version_values smb21_values = {
26+
.version_string = SMB21_VERSION_STRING,
27+
};

0 commit comments

Comments
 (0)