aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/connect.c
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 20:13:32 -0500
commit15b6a47322940beb74a83ffc1632c1ee1d00f35b (patch)
treea60daa9d2a25f65a232d282da6529d2b8ccd87d0 /fs/cifs/connect.c
parentcifs: add a deprecation warning to CIFS_IOC_CHECKUMOUNT ioctl (diff)
downloadlinux-dev-15b6a47322940beb74a83ffc1632c1ee1d00f35b.tar.xz
linux-dev-15b6a47322940beb74a83ffc1632c1ee1d00f35b.zip
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/connect.c')
-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 {
Opt_srcaddr, Opt_prefixpath,
Opt_iocharset, Opt_sockopt,
Opt_netbiosname, Opt_servern,
- Opt_ver, Opt_sec,
+ Opt_ver, Opt_sec, Opt_cache,
/* Mount options to be ignored */
Opt_ignore,
@@ -213,6 +213,7 @@ static const match_table_t cifs_mount_option_tokens = {
{ Opt_ver, "vers=%s" },
{ Opt_ver, "version=%s" },
{ Opt_sec, "sec=%s" },
+ { Opt_cache, "cache=%s" },
{ Opt_ignore, "cred" },
{ Opt_ignore, "credentials" },
@@ -261,6 +262,21 @@ static const match_table_t cifs_secflavor_tokens = {
{ Opt_sec_err, NULL }
};
+/* cache flavors */
+enum {
+ Opt_cache_loose,
+ Opt_cache_strict,
+ Opt_cache_none,
+ Opt_cache_err
+};
+
+static const match_table_t cifs_cacheflavor_tokens = {
+ { Opt_cache_loose, "loose" },
+ { Opt_cache_strict, "strict" },
+ { Opt_cache_none, "none" },
+ { Opt_cache_err, NULL }
+};
+
static int ip_connect(struct TCP_Server_Info *server);
static int generic_ip_connect(struct TCP_Server_Info *server);
static 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,
}
static int
+cifs_parse_cache_flavor(char *value, struct smb_vol *vol)
+{
+ substring_t args[MAX_OPT_ARGS];
+
+ switch (match_token(value, cifs_cacheflavor_tokens, args)) {
+ case Opt_cache_loose:
+ vol->direct_io = false;
+ vol->strict_io = false;
+ break;
+ case Opt_cache_strict:
+ vol->direct_io = false;
+ vol->strict_io = true;
+ break;
+ case Opt_cache_none:
+ vol->direct_io = true;
+ vol->strict_io = false;
+ break;
+ default:
+ cERROR(1, "bad cache= option: %s", value);
+ return 1;
+ }
+ return 0;
+}
+
+static int
cifs_parse_mount_options(const char *mountdata, const char *devname,
struct smb_vol *vol)
{
@@ -1414,10 +1455,12 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
vol->seal = 1;
break;
case Opt_direct:
- vol->direct_io = 1;
+ vol->direct_io = true;
+ vol->strict_io = false;
break;
case Opt_strictcache:
- vol->strict_io = 1;
+ vol->direct_io = false;
+ vol->strict_io = true;
break;
case Opt_noac:
printk(KERN_WARNING "CIFS: Mount option noac not "
@@ -1838,6 +1881,14 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
if (cifs_parse_security_flavors(string, vol) != 0)
goto cifs_parse_mount_err;
break;
+ case Opt_cache:
+ string = match_strdup(args);
+ if (string == NULL)
+ goto out_nomem;
+
+ if (cifs_parse_cache_flavor(string, vol) != 0)
+ goto cifs_parse_mount_err;
+ break;
default:
/*
* An option we don't recognize. Save it off for later