Skip to contentSkip to conversation

cifs: pave way for change to "strictcache" by default

PATCH New Jeff Layton 1 participant 5 messages May 16, 2012 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover cifs: pave way for change to "strictcache" by default

This is the second version of this patchset. The first version of this lays out the rationale for this change and is available here:

    http://permalink.gmane.org/gmane.linux.kernel.cifs/6007

In discussing this, Steve pointed out that fsc is not necessarily mutually exclusive with cache=strict. While I've always tended to think of fsc as a mechanism to cache data across reboots, it can also function as a "swap for pagecache" mechanism as well, allowing you to cache more data locally than you have RAM.

That said, I don't think the intersection of cache=strict and fsc will work properly today. I'm skeptical that the fscache is being invalidated correctly when an oplock is lost and reacquired. That should probably be fixed at some point if we want this to work.

Still, that's good enough reason not to make fsc mutually exclusive with the other cache= options. This patchset then removes fsc from that mutual exclusion and the warnings.

I've left Pavel's Reviewed-by's in place since this patchset is in the same spirit as the previous one. Pavel, let me know if you'd like those removed.

Jeff Layton (4):
cifs: add a cache= option to better describe the different cache
flavors
cifs: add deprecation warnings to strictcache and forcedirectio
cifs: display cache= option in /proc/mounts
cifs: add warning about change in default cache semantics in 3.7

 fs/cifs/cifsfs.c  |   18 ++++++++++---
 fs/cifs/connect.c |   76 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 87 insertions(+), 7 deletions(-)
Signature · 1 line
1.7.7.6

A message that is not in the archive (sent off-list or not yet received): 1337169354-19045-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw

PATCH v2 1/4 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.

---
 fs/cifs/connect.c |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 54 insertions(+), 3 deletions(-)
fs/cifs/connect.c +54 -3
index 5dcc551..cf8fe3e 100644
@@ -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,
@@ -212,6 +212,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" },
@@ -260,6 +261,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);
@@ -1185,6 +1201,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)
 {
@@ -1413,10 +1454,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 "
@@ -1837,6 +1880,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
Signature · 1 line
1.7.7.6
#3 lore raw

PATCH v2 2/4 cifs: add deprecation warnings to strictcache and forcedirectio

In reply to a message not in the archive

Leave them in for 2 releases and remove for 3.7.

---
 fs/cifs/connect.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
fs/cifs/connect.c +6 -0
index cf8fe3e..2bd867f 100644
@@ -1456,10 +1456,16 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
 		case Opt_direct:
 			vol->direct_io = true;
 			vol->strict_io = false;
+			cERROR(1, "The \"directio\" option will be removed in "
+				  "3.7. Please switch to the \"cache=none\" "
+				  "option.");
 			break;
 		case Opt_strictcache:
 			vol->direct_io = false;
 			vol->strict_io = true;
+			cERROR(1, "The \"strictcache\" option will be removed "
+				"in 3.7. Please switch to the \"cache=strict\" "
+				"option.");
 			break;
 		case Opt_noac:
 			printk(KERN_WARNING "CIFS: Mount option noac not "
Signature · 1 line
1.7.7.6
#4 lore raw

PATCH v2 3/4 cifs: display cache= option in /proc/mounts

In reply to a message not in the archive

...and deprecate the display of strictcache and forcedirectio as separate options.

---
 fs/cifs/cifsfs.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)
fs/cifs/cifsfs.c +14 -4
index c45f170..f718d57 100644
@@ -328,6 +328,19 @@ cifs_show_security(struct seq_file *s, struct TCP_Server_Info *server)
 		seq_printf(s, "i");
 }
 
+static void
+cifs_show_cache_flavor(struct seq_file *s, struct cifs_sb_info *cifs_sb)
+{
+	seq_printf(s, ",cache=");
+
+	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)
+		seq_printf(s, "strict");
+	else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
+		seq_printf(s, "none");
+	else
+		seq_printf(s, "loose");
+}
+
 /*
  * cifs_show_options() is for displaying mount options in /proc/mounts.
  * Not all settable options are displayed but most of the important
@@ -342,6 +355,7 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
 	srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr;
 
 	cifs_show_security(s, tcon->ses->server);
+	cifs_show_cache_flavor(s, cifs_sb);
 
 	seq_printf(s, ",unc=%s", tcon->treeName);
 
@@ -407,8 +421,6 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
 		seq_printf(s, ",rwpidforward");
 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL)
 		seq_printf(s, ",forcemand");
-	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
-		seq_printf(s, ",directio");
 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
 		seq_printf(s, ",nouser_xattr");
 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR)
@@ -431,8 +443,6 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
 		seq_printf(s, ",nostrictsync");
 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
 		seq_printf(s, ",noperm");
-	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)
-		seq_printf(s, ",strictcache");
 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPUID)
 		seq_printf(s, ",backupuid=%u", cifs_sb->mnt_backupuid);
 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPGID)
Signature · 1 line
1.7.7.6
#5 lore raw

PATCH v2 4/4 cifs: add warning about change in default cache semantics in 3.7

In reply to a message not in the archive

Add a warning that will be displayed when there is no cache= option specified. We want to ensure that users are aware of the change in defaults coming in 3.7.

---
 fs/cifs/connect.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
fs/cifs/connect.c +13 -0
index 2bd867f..e79df39 100644
@@ -1243,6 +1243,8 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
 	char *string = NULL;
 	char *tmp_end, *value;
 	char delim;
+	bool cache_specified = false;
+	static bool cache_warned = false;
 
 	separator[0] = ',';
 	separator[1] = 0;
@@ -1454,6 +1456,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
 			vol->seal = 1;
 			break;
 		case Opt_direct:
+			cache_specified = true;
 			vol->direct_io = true;
 			vol->strict_io = false;
 			cERROR(1, "The \"directio\" option will be removed in "
@@ -1461,6 +1464,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
 				  "option.");
 			break;
 		case Opt_strictcache:
+			cache_specified = true;
 			vol->direct_io = false;
 			vol->strict_io = true;
 			cERROR(1, "The \"strictcache\" option will be removed "
@@ -1887,6 +1891,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
 				goto cifs_parse_mount_err;
 			break;
 		case Opt_cache:
+			cache_specified = true;
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
@@ -1937,6 +1942,14 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
 		printk(KERN_NOTICE "CIFS: ignoring forcegid mount option "
 				   "specified with no gid= option.\n");
 
+	/* FIXME: remove this block in 3.7 */
+	if (!cache_specified && !cache_warned) {
+		cache_warned = true;
+		printk(KERN_NOTICE "CIFS: no cache= option specified, using "
+				   "\"cache=loose\". This default will change "
+				   "to \"cache=strict\" in 3.7.\n");
+	}
+
 	kfree(mountdata_copy);
 	return 0;
 
Signature · 1 line
1.7.7.6