Blame SOURCES/nfs-utils-1.3.0-exportfs-noreaddirplus.patch

64c563
commit 4017afe28d640c535109576bd149bc7e0345f075
64c563
Author: Rajesh Ghanekar <rajesh_ghanekar@symantec.com>
64c563
Date:   Wed Aug 20 14:00:59 2014 -0400
64c563
64c563
    nfs-utils: Allow turning off nfsv3 readdir_plus
64c563
    
64c563
    One of our customer's application only needs file names, not file
64c563
    attributes. With directories having 10K+ inodes (assuming buffer cache
64c563
    has directory blocks cached having file names, but inode cache is
64c563
    limited and hence need eviction of older cached inodes), older inodes
64c563
    are evicted periodically. So if they keep on doing readdir(2) from NSF
64c563
    client on multiple directories, some directory's files are periodically
64c563
    removed from inode cache and hence new readdir(2) on same directory
64c563
    requires disk access to bring back inodes again to inode cache.
64c563
    
64c563
    As READDIRPLUS request fetches attributes also, doing getattr on each
64c563
    file on server, it causes unnecessary disk accesses. If READDIRPLUS on
64c563
    NFS client is returned with -ENOTSUPP, NFS client uses READDIR request
64c563
    which just gets the names of the files in a directory, not attributes,
64c563
    hence avoiding disk accesses on server.
64c563
    
64c563
    There's already a corresponding client-side mount option, but an export
64c563
    option reduces the need for configuration across multiple clients.
64c563
    
64c563
    This flag affects NFSv3 only.  If it turns out it's needed for NFSv4 as
64c563
    well then we may have to figure out how to extend the behavior to NFSv4,
64c563
    but it's not currently obvious how to do that.
64c563
    
64c563
    Signed-off-by: Rajesh Ghanekar <rajesh_ghanekar@symantec.com>
64c563
    Signed-off-by: Steve Dickson <steved@redhat.com>
64c563
64c563
diff --git a/support/include/nfs/export.h b/support/include/nfs/export.h
64c563
index 1547a87..2f59e6a 100644
64c563
--- a/support/include/nfs/export.h
64c563
+++ b/support/include/nfs/export.h
64c563
@@ -17,7 +17,8 @@
64c563
 #define NFSEXP_ALLSQUASH	0x0008
64c563
 #define NFSEXP_ASYNC		0x0010
64c563
 #define NFSEXP_GATHERED_WRITES	0x0020
64c563
-/* 40, 80, 100 unused */
64c563
+#define NFSEXP_NOREADDIRPLUS	0x0040
64c563
+/* 80, 100 unused */
64c563
 #define NFSEXP_NOHIDE		0x0200
64c563
 #define NFSEXP_NOSUBTREECHECK	0x0400
64c563
 #define NFSEXP_NOAUTHNLM	0x0800
64c563
diff --git a/support/nfs/exports.c b/support/nfs/exports.c
64c563
index 819d6c4..eb782b9 100644
64c563
--- a/support/nfs/exports.c
64c563
+++ b/support/nfs/exports.c
64c563
@@ -273,6 +273,8 @@ putexportent(struct exportent *ep)
64c563
 		"in" : "");
64c563
 	fprintf(fp, "%sacl,", (ep->e_flags & NFSEXP_NOACL)?
64c563
 		"no_" : "");
64c563
+	if (ep->e_flags & NFSEXP_NOREADDIRPLUS)
64c563
+		fprintf(fp, "nordirplus,");
64c563
 	if (ep->e_flags & NFSEXP_FSID) {
64c563
 		fprintf(fp, "fsid=%d,", ep->e_fsid);
64c563
 	}
64c563
@@ -539,6 +541,8 @@ parseopts(char *cp, struct exportent *ep, int warn, int *had_subtree_opt_ptr)
64c563
 			clearflags(NFSEXP_ASYNC, active, ep);
64c563
 		else if (!strcmp(opt, "async"))
64c563
 			setflags(NFSEXP_ASYNC, active, ep);
64c563
+		else if (!strcmp(opt, "nordirplus"))
64c563
+			setflags(NFSEXP_NOREADDIRPLUS, active, ep);
64c563
 		else if (!strcmp(opt, "nohide"))
64c563
 			setflags(NFSEXP_NOHIDE, active, ep);
64c563
 		else if (!strcmp(opt, "hide"))
64c563
diff --git a/utils/exportfs/exports.man b/utils/exportfs/exports.man
64c563
index e8b29df..3d974d9 100644
64c563
--- a/utils/exportfs/exports.man
64c563
+++ b/utils/exportfs/exports.man
64c563
@@ -360,6 +360,11 @@ supported so the same configuration can be made to work on old and new
64c563
 kernels alike.
64c563
 
64c563
 .TP
64c563
+.IR nordirplus
64c563
+This option will disable READDIRPLUS request handling.  When set,
64c563
+READDIRPLUS requests from NFS clients return NFS3ERR_NOTSUPP, and
64c563
+clients fall back on READDIR.  This option affects only NFSv3 clients.
64c563
+.TP
64c563
 .IR refer= path@host[+host][:path@host[+host]]
64c563
 A client referencing the export point will be directed to choose from
64c563
 the given list an alternative location for the filesystem.