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

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