From: Jeff Layton <jlayton(a)redhat.com>
Add a new maybe_start_grace operation that will check to see if a
sibling has requested a grace period and start one if so. Call this
function from the reaper thread.
Note that we only enforce the grace period and do not reload the
recovery db. All of the current node's state is still intact, so we
don't need to initiate any reclaim; only enforce the grace period until
the other node's reclaim is complete.
Change-Id: I85f54907efb220510af0b87baa1798d3f1d7a041
Signed-off-by: Jeff Layton <jlayton(a)redhat.com>
---
src/MainNFSD/nfs_reaper_thread.c | 3 +++
src/SAL/nfs4_recovery.c | 15 +++++++++++++++
src/include/sal_functions.h | 2 ++
3 files changed, 20 insertions(+)
diff --git a/src/MainNFSD/nfs_reaper_thread.c b/src/MainNFSD/nfs_reaper_thread.c
index 918a3b7f4256..07ef670810fd 100644
--- a/src/MainNFSD/nfs_reaper_thread.c
+++ b/src/MainNFSD/nfs_reaper_thread.c
@@ -203,6 +203,9 @@ static void reaper_run(struct fridgethr_context *ctx)
SetNameFunction("reaper");
+ /* see if we need to start a grace period */
+ nfs_maybe_start_grace();
+
/*
* Try to lift the grace period, unless we're shutting down.
* Ordinarily, we'd take the mutex to check this, but this is just a
diff --git a/src/SAL/nfs4_recovery.c b/src/SAL/nfs4_recovery.c
index 120819e621c9..cc4f7cf9facf 100644
--- a/src/SAL/nfs4_recovery.c
+++ b/src/SAL/nfs4_recovery.c
@@ -198,6 +198,21 @@ bool nfs_in_grace(void)
return atomic_fetch_time_t(¤t_grace);
}
+/**
+ * @brief Enter the grace period if another node in the cluster needs it
+ *
+ * Singleton servers generally won't use this operation. Clustered servers
+ * call this function to check whether another node might need a grace period.
+ */
+void nfs_maybe_start_grace(void)
+{
+ if (recovery_backend->maybe_start_grace) {
+ if (nfs_in_grace())
+ return;
+ recovery_backend->maybe_start_grace();
+ }
+}
+
void nfs_try_lift_grace(void)
{
bool in_grace = true;
diff --git a/src/include/sal_functions.h b/src/include/sal_functions.h
index 7e30e51eeabf..2829f574c8e7 100644
--- a/src/include/sal_functions.h
+++ b/src/include/sal_functions.h
@@ -976,6 +976,7 @@ void blocked_lock_polling(struct fridgethr_context *ctx);
void nfs_start_grace(nfs_grace_start_t *gsp);
bool nfs_in_grace(void);
bool simple_try_lift_grace(void);
+void nfs_maybe_start_grace(void);
void nfs_try_lift_grace(void);
void nfs4_add_clid(nfs_client_id_t *);
void nfs4_rm_clid(nfs_client_id_t *);
@@ -1023,6 +1024,7 @@ struct nfs4_recovery_backend {
void (*add_clid)(nfs_client_id_t *);
void (*rm_clid)(nfs_client_id_t *);
void (*add_revoke_fh)(nfs_client_id_t *, nfs_fh4 *);
+ void (*maybe_start_grace)(void);
bool (*try_lift_grace)(void);
};
--
2.17.0