]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
nfs-utils: don't fdatasync the rmtab
authorBen Myers <bpm@sgi.com>
Fri, 12 Feb 2010 19:02:21 +0000 (14:02 -0500)
committerSteve Dickson <steved@redhat.com>
Fri, 12 Feb 2010 19:21:04 +0000 (14:21 -0500)
If we're using the new caching interface the rmtab will be ignored by
exportfs so there is no need to fdatasync. This improves mountd performance.

Signed-off-by: Steve Dickson <steved@redhat.com>
support/nfs/cacheio.c
support/nfs/rmtab.c

index 6a6ed5ac7f093a590e621895a03f2c9e3729683e..bdf5d849b1baa353d1939cc84b3a486d93354173 100644 (file)
@@ -285,9 +285,8 @@ int readline(int fd, char **buf, int *lenp)
 int
 check_new_cache(void)
 {
-       struct stat stb;
-       return  (stat("/proc/fs/nfs/filehandle", &stb) == 0) ||
-               (stat("/proc/fs/nfsd/filehandle", &stb) == 0);
+       return  (access("/proc/fs/nfs/filehandle", F_OK) == 0) ||
+               (access("/proc/fs/nfsd/filehandle", F_OK) == 0);
 }      
 
 
index 4cbd28591270a184b68e7ecedddc4828080814bb..a28abf343898791b415336d36ef67c4977063d5f 100644 (file)
@@ -117,11 +117,24 @@ void
 fendrmtabent(FILE *fp)
 {
        if (fp) {
-               /* If it was written to, we really want
-                * to flush to disk before returning
-                */
-               fflush(fp);
-               fdatasync(fileno(fp));
+               static int have_new_cache = -1;
+               if (have_new_cache == -1) /* check only once */
+                       have_new_cache = check_new_cache();
+
+               if (!have_new_cache) {
+                       /*
+                        * If we are using the old caching interface: exportfs
+                        * uses the rmtab to determine what should be exported,
+                        * so it is important that it be up-to-date.
+                        *
+                        * If we are using the new caching interface: the rmtab
+                        * is ignored by exportfs and the fdatasync only serves
+                        * to slow us down.
+                        */
+                       fflush(fp);
+                       fdatasync(fileno(fp));
+               }
+
                fclose(fp);
        }
 }