2023-04-18 09:38:21

by Richard Weinberger

[permalink] [raw]
Subject: [PATCH 4/8] export: Uncover NFS subvolume after reboot

When a re-exporting NFS server reboots, none of the subvolumes are present.
This is because the NFS client code will mount only upon first access.
So, when we see an NFS handle with an yet unknown fsidnum, lookup in
the reexport database for it.
If one is found, stat the path to trigger the mount.
That way stale NFS handles are avoided after a reboot.

Signed-off-by: Richard Weinberger <[email protected]>
---
support/export/cache.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/support/export/cache.c b/support/export/cache.c
index 42a694d0..19bbba55 100644
--- a/support/export/cache.c
+++ b/support/export/cache.c
@@ -778,6 +778,7 @@ static void nfsd_fh(int f)
int dev_missing = 0;
char buf[RPC_CHAN_BUF_SIZE], *bp;
int blen;
+ int did_uncover = 0;

blen = cache_read(f, buf, sizeof(buf));
if (blen <= 0 || buf[blen-1] != '\n') return;
@@ -815,6 +816,11 @@ static void nfsd_fh(int f)
for (exp = exportlist[i].p_head; exp; exp = next_exp) {
char *path;

+ if (!did_uncover && parsed.fsidnum && parsed.fsidtype == FSID_NUM && exp->m_export.e_reexport != REEXP_NONE) {
+ reexpdb_uncover_subvolume(parsed.fsidnum);
+ did_uncover = 1;
+ }
+
if (exp->m_export.e_flags & NFSEXP_CROSSMOUNT) {
static nfs_export *prev = NULL;
static void *mnt = NULL;
--
2.31.1