]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - support/nfs/rmtab.c
nfs-utils: don't fdatasync the rmtab
[nfs-utils.git] / support / nfs / rmtab.c
index b7be6ba6b0a86ae7353872d30c907026be27f0a6..a28abf343898791b415336d36ef67c4977063d5f 100644 (file)
@@ -6,7 +6,9 @@
  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  */
 
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <sys/fcntl.h>
 #include <stdlib.h>
@@ -115,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);
        }
 }