diff mbox series

[RFC,5/6] nfsd: statfs() every known subvolume upon start

Message ID 20220217131531.2890-6-richard@nod.at (mailing list archive)
State New, archived
Headers show
Series nfs-utils: Improving NFS re-exports | expand

Commit Message

Richard Weinberger Feb. 17, 2022, 1:15 p.m. UTC
This will trigger an automount of a subvolume and existing
file handles will continue to work.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 utils/nfsd/Makefile.am |  6 ++++++
 utils/nfsd/nfsd.c      | 10 ++++++++++
 2 files changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/utils/nfsd/Makefile.am b/utils/nfsd/Makefile.am
index 8acc9a04..3acc8354 100644
--- a/utils/nfsd/Makefile.am
+++ b/utils/nfsd/Makefile.am
@@ -11,6 +11,12 @@  noinst_HEADERS = nfssvc.h
 nfsd_SOURCES = nfsd.c nfssvc.c
 nfsd_LDADD = ../../support/nfs/libnfs.la $(LIBTIRPC)
 
+if CONFIG_REEXPORT
+nfsd_LDADD += ../../support/reexport/libreexport.a $(LIBSQLITE) $(LIBPTHREAD) -lrt
+endif
+
+nfsd_CPPFLAGS = -I$(top_srcdir)/support/reexport
+
 MAINTAINERCLEANFILES = Makefile.in
 
 #######################################################################
diff --git a/utils/nfsd/nfsd.c b/utils/nfsd/nfsd.c
index b0741718..b5175f7a 100644
--- a/utils/nfsd/nfsd.c
+++ b/utils/nfsd/nfsd.c
@@ -29,6 +29,7 @@ 
 #include "nfssvc.h"
 #include "xlog.h"
 #include "xcommon.h"
+#include "reexport.h"
 
 #ifndef NFSD_NPROC
 #define NFSD_NPROC 8
@@ -347,6 +348,15 @@  main(int argc, char **argv)
 		exit(1);
 	}
 
+	/*
+	 * Make sure that uncovered NFS subvolumes are present such that
+	 * existing file handles continue working.
+	 */
+	if (reexpdb_init() == 0) {
+		reexpdb_uncover_subvolumes(NULL);
+		reexpdb_destroy();
+	}
+
 	/* make sure nfsdfs is mounted if it's available */
 	nfssvc_mount_nfsdfs(progname);