Home Home > GIT Browse > openSUSE-15.0
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2017-12-23 09:42:01 +1100
committerNeilBrown <neilb@suse.com>2018-04-27 13:10:56 +1000
commitdfbdeb60f7b14063d4c9ac2600ed76f0522ef841 (patch)
treeaa339ddb77e855c898847049980c151912aee8af
parenta0343f18b99d9c2875c439beb35767c110629651 (diff)
NFS: add nostatflush mount option (bsc#1065726).rpm-3.0.101-108.41
-rw-r--r--patches.fixes/0001-NFS-add-nostatflush-mount-option.patch116
-rw-r--r--series.conf1
2 files changed, 117 insertions, 0 deletions
diff --git a/patches.fixes/0001-NFS-add-nostatflush-mount-option.patch b/patches.fixes/0001-NFS-add-nostatflush-mount-option.patch
new file mode 100644
index 0000000000..b2eb6ab08e
--- /dev/null
+++ b/patches.fixes/0001-NFS-add-nostatflush-mount-option.patch
@@ -0,0 +1,116 @@
+From: NeilBrown <neilb@suse.com>
+Date: Thu, 21 Dec 2017 13:43:05 +1100
+Subject: [PATCH] NFS: add nostatflush mount option.
+Patch-mainline: Never, upstream don't agree
+References: bsc#1065726
+
+When an i_op->getattr() call is made on an NFS file
+(typically from a 'stat' family system call), NFS
+will first flush any dirty data to the server.
+
+This ensures that the mtime reported is correct and stable,
+but has a performance penalty. 'stat' is normally thought
+to be a quick operation, and imposing this cost can be
+surprising.
+
+I have seen problems when one process is writing a large
+file and another process performs "ls -l" on the containing
+directory and is blocked for as long as it take to flush
+all the dirty data to the server, which can be minutes.
+
+I have also seen a legacy application which frequently calls
+"fstat" on a file that it is writing to. On a local
+filesystem (and in the Solaris implementation of NFS) this
+fstat call is cheap. On Linux/NFS, the causes a noticeable
+decrease in throughput.
+
+The only circumstances where an application calling 'stat()'
+might get an mtime which is not stable are times when some
+other process is writing to the file and the two processes
+are not using locking to ensure consistency, or when the one
+process is both writing and stating. In neither of these
+cases is it reasonable to expect the mtime to be stable.
+
+In the most common cases where mtime is important
+(e.g. make), no other process has the file open, so there
+will be no dirty data and the mtime will be stable.
+
+Rather than unilaterally changing this behavior of 'stat',
+this patch adds a "nosyncflush" mount option to allow
+sysadmins to have applications which are hurt by the current
+behavior to disable it.
+
+Note that this option should probably *not* be used together
+with "nocto". In that case, mtime could be unstable even
+when no process has the file open.
+
+Signed-off-by: NeilBrown <neilb@suse.com>
+Acked-by: NeilBrown <neilb@suse.com>
+
+---
+ fs/nfs/inode.c | 3 ++-
+ fs/nfs/super.c | 10 ++++++++++
+ include/linux/nfs_mount.h | 1 +
+ 3 files changed, 13 insertions(+), 1 deletion(-)
+
+--- a/fs/nfs/inode.c
++++ b/fs/nfs/inode.c
+@@ -518,7 +518,8 @@ int nfs_getattr(struct vfsmount *mnt, st
+ int err;
+
+ /* Flush out writes to the server in order to update c/mtime. */
+- if (S_ISREG(inode->i_mode)) {
++ if (S_ISREG(inode->i_mode) &&
++ !(NFS_SERVER(inode)->flags & NFS_MOUNT_NOSTATFLUSH)) {
+ err = filemap_write_and_wait(inode->i_mapping);
+ if (err)
+ goto out;
+--- a/fs/nfs/super.c
++++ b/fs/nfs/super.c
+@@ -88,6 +88,7 @@ enum {
+ Opt_sharetransport, Opt_nosharetransport,
+ Opt_resvport, Opt_noresvport,
+ Opt_fscache, Opt_nofscache,
++ Opt_statflush, Opt_nostatflush,
+
+ /* Mount options that take integer arguments */
+ Opt_port,
+@@ -152,6 +153,8 @@ static const match_table_t nfs_mount_opt
+ { Opt_noresvport, "noresvport" },
+ { Opt_fscache, "fsc" },
+ { Opt_nofscache, "nofsc" },
++ { Opt_statflush, "statflush" },
++ { Opt_nostatflush, "nostatflush" },
+
+ { Opt_port, "port=%s" },
+ { Opt_rsize, "rsize=%s" },
+@@ -647,6 +650,7 @@ static void nfs_show_mount_options(struc
+ { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
+ { NFS_MOUNT_NOSHARE_XPRT, ",nosharetransport", ""},
+ { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
++ { NFS_MOUNT_NOSTATFLUSH, ",nostatflush", "" },
+ { 0, NULL, NULL }
+ };
+ const struct proc_nfs_info *nfs_infop;
+@@ -1321,6 +1325,12 @@ static int nfs_parse_mount_options(char
+ goto out_invalid_value;
+ mnt->minorversion = option;
+ break;
++ case Opt_statflush:
++ mnt->flags &= ~NFS_MOUNT_NOSTATFLUSH;
++ break;
++ case Opt_nostatflush:
++ mnt->flags |= NFS_MOUNT_NOSTATFLUSH;
++ break;
+
+ /*
+ * options that take text values
+--- a/include/linux/nfs_mount.h
++++ b/include/linux/nfs_mount.h
+@@ -74,5 +74,6 @@ struct nfs_mount_data {
+ #define NFS_MOUNT_LOCAL_FLOCK 0x100000
+ #define NFS_MOUNT_LOCAL_FCNTL 0x200000
+ #define NFS_MOUNT_NOSHARE_XPRT 0x400000
++#define NFS_MOUNT_NOSTATFLUSH 0x800000
+
+ #endif
diff --git a/series.conf b/series.conf
index 8c27deaaf6..f03bd1e65b 100644
--- a/series.conf
+++ b/series.conf
@@ -6563,6 +6563,7 @@
patches.fixes/0004-NFS-Optimize-fallocate-by-refreshing-mapping-when-ne.patch
patches.fixes/0001-nfs-Fix-ugly-referral-attributes.patch
patches.fixes/0001-NFSv4-fix-getacl-head-length-estimation.patch
+ patches.fixes/0001-NFS-add-nostatflush-mount-option.patch
########################################################
# Netfilter