Skip to content

Commit 2f20f07

Browse files
Ronnie Sahlbergsmfrench
authored andcommitted
cifs: move cache mount options to fs_context.ch
Helps to shrink connect.c and make it more readable by moving mount related code to fs_context.c and fs_context.h Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <stfrench@microsoft.com> Reviewed-by: Aurelien Aptel <aaptel@suse.com>
1 parent 5c6e5aa commit 2f20f07

3 files changed

Lines changed: 63 additions & 62 deletions

File tree

fs/cifs/connect.c

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -280,25 +280,6 @@ static const match_table_t cifs_mount_option_tokens = {
280280
{ Opt_err, NULL }
281281
};
282282

283-
/* cache flavors */
284-
enum {
285-
Opt_cache_loose,
286-
Opt_cache_strict,
287-
Opt_cache_none,
288-
Opt_cache_ro,
289-
Opt_cache_rw,
290-
Opt_cache_err
291-
};
292-
293-
static const match_table_t cifs_cacheflavor_tokens = {
294-
{ Opt_cache_loose, "loose" },
295-
{ Opt_cache_strict, "strict" },
296-
{ Opt_cache_none, "none" },
297-
{ Opt_cache_ro, "ro" },
298-
{ Opt_cache_rw, "singleclient" },
299-
{ Opt_cache_err, NULL }
300-
};
301-
302283
static const match_table_t cifs_smb_version_tokens = {
303284
{ Smb_1, SMB1_VERSION_STRING },
304285
{ Smb_20, SMB20_VERSION_STRING},
@@ -1346,49 +1327,6 @@ static int get_option_gid(substring_t args[], kgid_t *result)
13461327
return 0;
13471328
}
13481329

1349-
static int
1350-
cifs_parse_cache_flavor(char *value, struct smb_vol *vol)
1351-
{
1352-
substring_t args[MAX_OPT_ARGS];
1353-
1354-
switch (match_token(value, cifs_cacheflavor_tokens, args)) {
1355-
case Opt_cache_loose:
1356-
vol->direct_io = false;
1357-
vol->strict_io = false;
1358-
vol->cache_ro = false;
1359-
vol->cache_rw = false;
1360-
break;
1361-
case Opt_cache_strict:
1362-
vol->direct_io = false;
1363-
vol->strict_io = true;
1364-
vol->cache_ro = false;
1365-
vol->cache_rw = false;
1366-
break;
1367-
case Opt_cache_none:
1368-
vol->direct_io = true;
1369-
vol->strict_io = false;
1370-
vol->cache_ro = false;
1371-
vol->cache_rw = false;
1372-
break;
1373-
case Opt_cache_ro:
1374-
vol->direct_io = false;
1375-
vol->strict_io = false;
1376-
vol->cache_ro = true;
1377-
vol->cache_rw = false;
1378-
break;
1379-
case Opt_cache_rw:
1380-
vol->direct_io = false;
1381-
vol->strict_io = false;
1382-
vol->cache_ro = false;
1383-
vol->cache_rw = true;
1384-
break;
1385-
default:
1386-
cifs_dbg(VFS, "bad cache= option: %s\n", value);
1387-
return 1;
1388-
}
1389-
return 0;
1390-
}
1391-
13921330
static int
13931331
cifs_parse_smb_version(char *value, struct smb_vol *vol, bool is_smb3)
13941332
{

fs/cifs/fs_context.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,55 @@ int cifs_parse_security_flavors(char *value, struct smb_vol *vol)
8282

8383
return 0;
8484
}
85+
86+
static const match_table_t cifs_cacheflavor_tokens = {
87+
{ Opt_cache_loose, "loose" },
88+
{ Opt_cache_strict, "strict" },
89+
{ Opt_cache_none, "none" },
90+
{ Opt_cache_ro, "ro" },
91+
{ Opt_cache_rw, "singleclient" },
92+
{ Opt_cache_err, NULL }
93+
};
94+
95+
int
96+
cifs_parse_cache_flavor(char *value, struct smb_vol *vol)
97+
{
98+
substring_t args[MAX_OPT_ARGS];
99+
100+
switch (match_token(value, cifs_cacheflavor_tokens, args)) {
101+
case Opt_cache_loose:
102+
vol->direct_io = false;
103+
vol->strict_io = false;
104+
vol->cache_ro = false;
105+
vol->cache_rw = false;
106+
break;
107+
case Opt_cache_strict:
108+
vol->direct_io = false;
109+
vol->strict_io = true;
110+
vol->cache_ro = false;
111+
vol->cache_rw = false;
112+
break;
113+
case Opt_cache_none:
114+
vol->direct_io = true;
115+
vol->strict_io = false;
116+
vol->cache_ro = false;
117+
vol->cache_rw = false;
118+
break;
119+
case Opt_cache_ro:
120+
vol->direct_io = false;
121+
vol->strict_io = false;
122+
vol->cache_ro = true;
123+
vol->cache_rw = false;
124+
break;
125+
case Opt_cache_rw:
126+
vol->direct_io = false;
127+
vol->strict_io = false;
128+
vol->cache_ro = false;
129+
vol->cache_rw = true;
130+
break;
131+
default:
132+
cifs_dbg(VFS, "bad cache= option: %s\n", value);
133+
return 1;
134+
}
135+
return 0;
136+
}

fs/cifs/fs_context.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212
#include <linux/parser.h>
1313
#include "cifsglob.h"
1414

15+
enum {
16+
Opt_cache_loose,
17+
Opt_cache_strict,
18+
Opt_cache_none,
19+
Opt_cache_ro,
20+
Opt_cache_rw,
21+
Opt_cache_err
22+
};
23+
24+
int cifs_parse_cache_flavor(char *value, struct smb_vol *vol);
25+
1526
enum cifs_sec_param {
1627
Opt_sec_krb5,
1728
Opt_sec_krb5i,

0 commit comments

Comments
 (0)