diff mbox

[nfs-ganesha,RFC,v2,08/13] SAL: add a way to check for grace period being enforced cluster-wide

Message ID 20180503185803.25417-9-jlayton@kernel.org (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Layton May 3, 2018, 6:57 p.m. UTC
From: Jeff Layton <jlayton@redhat.com>

Add a new recovery backend operation to tell whether the grace period
is being fully enforced. Singleton backends that don't define this
operation will just have nfs_grace_enforcing() return true.

Change-Id: I8020723238396efe0949f29e1906c58b0a5e26c9
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 src/SAL/nfs4_recovery.c     | 14 ++++++++++++++
 src/include/sal_functions.h |  1 +
 2 files changed, 15 insertions(+)
diff mbox

Patch

diff --git a/src/SAL/nfs4_recovery.c b/src/SAL/nfs4_recovery.c
index debc6cab1bdb..400d8b528d26 100644
--- a/src/SAL/nfs4_recovery.c
+++ b/src/SAL/nfs4_recovery.c
@@ -227,6 +227,20 @@  void nfs_maybe_start_grace(void)
 	}
 }
 
+/**
+ * @brief Are all hosts in cluster enforcing the grace period?
+ *
+ * Singleton servers always return true here since the only grace period that
+ * matters is the local one. Clustered backends should check to make sure that
+ * the whole cluster is in grace.
+ */
+bool nfs_grace_enforcing(void)
+{
+	if (recovery_backend->grace_enforcing)
+		return recovery_backend->grace_enforcing();
+	return true;
+}
+
 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 ac01a6eba497..96a4eb40a50b 100644
--- a/src/include/sal_functions.h
+++ b/src/include/sal_functions.h
@@ -1027,6 +1027,7 @@  struct nfs4_recovery_backend {
 	void (*maybe_start_grace)(void);
 	bool (*try_lift_grace)(void);
 	void (*set_enforcing)(void);
+	bool (*grace_enforcing)(void);
 };
 
 void fs_backend_init(struct nfs4_recovery_backend **);