aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-05-16 07:50:15 -0400
committerSteve French <sfrench@us.ibm.com>2012-05-16 21:13:32 -0400
commit15b6a47322940beb74a83ffc1632c1ee1d00f35b (patch)
treea60daa9d2a25f65a232d282da6529d2b8ccd87d0 /fs/cifs
parent4d61cd6ec764368689fab3bd19e78d76c1e6b176 (diff)
cifs: add a cache= option to better describe the different cache flavors
Currently, we have several mount options that control cifs' cache behavior, but those options aren't considered to be mutually exclusive. The result is poorly-defined when someone specifies more than one of these options at mount time. Fix this by adding a new cache= mount option that will supercede "strictcache", and "forcedirectio". That will help make it clear that these options are mutually exclusive. Also, change the legacy options to be mutually exclusive too, to ensure that users don't get surprises. Reviewed-by: Pavel Shilovsky <piastry@etersoft.ru> Signed-off-by: Jeff Layton <jlayton@redhat.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/connect.c57
1 files changed, 54 insertions, 3 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index e0b56d7a19c5..4898759d97cc 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -102,7 +102,7 @@ enum {
102 Opt_srcaddr, Opt_prefixpath, 102 Opt_srcaddr, Opt_prefixpath,
103 Opt_iocharset, Opt_sockopt, 103 Opt_iocharset, Opt_sockopt,
104 Opt_netbiosname, Opt_servern, 104 Opt_netbiosname, Opt_servern,
105 Opt_ver, Opt_sec, 105 Opt_ver, Opt_sec, Opt_cache,
106 106
107 /* Mount options to be ignored */ 107 /* Mount options to be ignored */
108 Opt_ignore, 108 Opt_ignore,
@@ -213,6 +213,7 @@ static const match_table_t cifs_mount_option_tokens = {
213 { Opt_ver, "vers=%s" }, 213 { Opt_ver, "vers=%s" },
214 { Opt_ver, "version=%s" }, 214 { Opt_ver, "version=%s" },
215 { Opt_sec, "sec=%s" }, 215 { Opt_sec, "sec=%s" },
216 { Opt_cache, "cache=%s" },
216 217
217 { Opt_ignore, "cred" }, 218 { Opt_ignore, "cred" },
218 { Opt_ignore, "credentials" }, 219 { Opt_ignore, "credentials" },
@@ -261,6 +262,21 @@ static const match_table_t cifs_secflavor_tokens = {
261 { Opt_sec_err, NULL } 262 { Opt_sec_err, NULL }
262}; 263};
263 264
265/* cache flavors */
266enum {
267 Opt_cache_loose,
268 Opt_cache_strict,
269 Opt_cache_none,
270 Opt_cache_err
271};
272
273static const match_table_t cifs_cacheflavor_tokens = {
274 { Opt_cache_loose, "loose" },
275 { Opt_cache_strict, "strict" },
276 { Opt_cache_none, "none" },
277 { Opt_cache_err, NULL }
278};
279
264static int ip_connect(struct TCP_Server_Info *server); 280static int ip_connect(struct TCP_Server_Info *server);
265static int generic_ip_connect(struct TCP_Server_Info *server); 281static int generic_ip_connect(struct TCP_Server_Info *server);
266static void tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink); 282static void tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink);
@@ -1186,6 +1202,31 @@ static int cifs_parse_security_flavors(char *value,
1186} 1202}
1187 1203
1188static int 1204static int
1205cifs_parse_cache_flavor(char *value, struct smb_vol *vol)
1206{
1207 substring_t args[MAX_OPT_ARGS];
1208
1209 switch (match_token(value, cifs_cacheflavor_tokens, args)) {
1210 case Opt_cache_loose:
1211 vol->direct_io = false;
1212 vol->strict_io = false;
1213 break;
1214 case Opt_cache_strict:
1215 vol->direct_io = false;
1216 vol->strict_io = true;
1217 break;
1218 case Opt_cache_none:
1219 vol->direct_io = true;
1220 vol->strict_io = false;
1221 break;
1222 default:
1223 cERROR(1, "bad cache= option: %s", value);
1224 return 1;
1225 }
1226 return 0;
1227}
1228
1229static int
1189cifs_parse_mount_options(const char *mountdata, const char *devname, 1230cifs_parse_mount_options(const char *mountdata, const char *devname,
1190 struct smb_vol *vol) 1231 struct smb_vol *vol)
1191{ 1232{
@@ -1414,10 +1455,12 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1414 vol->seal = 1; 1455 vol->seal = 1;
1415 break; 1456 break;
1416 case Opt_direct: 1457 case Opt_direct:
1417 vol->direct_io = 1; 1458 vol->direct_io = true;
1459 vol->strict_io = false;
1418 break; 1460 break;
1419 case Opt_strictcache: 1461 case Opt_strictcache:
1420 vol->strict_io = 1; 1462 vol->direct_io = false;
1463 vol->strict_io = true;
1421 break; 1464 break;
1422 case Opt_noac: 1465 case Opt_noac:
1423 printk(KERN_WARNING "CIFS: Mount option noac not " 1466 printk(KERN_WARNING "CIFS: Mount option noac not "
@@ -1838,6 +1881,14 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1838 if (cifs_parse_security_flavors(string, vol) != 0) 1881 if (cifs_parse_security_flavors(string, vol) != 0)
1839 goto cifs_parse_mount_err; 1882 goto cifs_parse_mount_err;
1840 break; 1883 break;
1884 case Opt_cache:
1885 string = match_strdup(args);
1886 if (string == NULL)
1887 goto out_nomem;
1888
1889 if (cifs_parse_cache_flavor(string, vol) != 0)
1890 goto cifs_parse_mount_err;
1891 break;
1841 default: 1892 default:
1842 /* 1893 /*
1843 * An option we don't recognize. Save it off for later 1894 * An option we don't recognize. Save it off for later