@@ -196,12 +196,31 @@ bool nfs_in_grace(void)
return atomic_fetch_time_t(¤t_grace);
}
+/**
+ * @brief Determine whether we can lift the grace period
+ *
+ * @retval true if so
+ * @retval false if not
+ *
+ * In a clustered environment, we must take care not to lift the grace period
+ * until it's no longer needed cluster-wide. Try to lift the grace period, and
+ * return true or false depending on whether it succeeded.
+ *
+ * In the case of a single host, we always assume that the grace period can
+ * be lifted.
+ */
+bool simple_try_lift_grace(void)
+{
+ return true;
+}
+
void nfs_try_lift_grace(void)
{
bool in_grace = true;
int32_t rc_count = 0;
time_t current = atomic_fetch_time_t(¤t_grace);
+ /* Already lifted? Just return */
if (!current)
return;
@@ -223,9 +242,11 @@ void nfs_try_lift_grace(void)
* try to do it.
*/
if (!in_grace) {
- PTHREAD_MUTEX_lock(&grace_mutex);
- nfs_lift_grace_locked(current);
- PTHREAD_MUTEX_unlock(&grace_mutex);
+ if (recovery_backend->try_lift_grace()) {
+ PTHREAD_MUTEX_lock(&grace_mutex);
+ nfs_lift_grace_locked(current);
+ PTHREAD_MUTEX_unlock(&grace_mutex);
+ }
}
}
@@ -784,6 +784,7 @@ struct nfs4_recovery_backend fs_backend = {
.add_clid = fs_add_clid,
.rm_clid = fs_rm_clid,
.add_revoke_fh = fs_add_revoke_fh,
+ .try_lift_grace = simple_try_lift_grace,
};
void fs_backend_init(struct nfs4_recovery_backend **backend)
@@ -377,6 +377,7 @@ static struct nfs4_recovery_backend fs_ng_backend = {
.add_clid = fs_add_clid,
.rm_clid = fs_rm_clid,
.add_revoke_fh = fs_add_revoke_fh,
+ .try_lift_grace = simple_try_lift_grace,
};
void fs_ng_backend_init(struct nfs4_recovery_backend **backend)
@@ -601,6 +601,7 @@ struct nfs4_recovery_backend rados_kv_backend = {
.add_clid = rados_kv_add_clid,
.rm_clid = rados_kv_rm_clid,
.add_revoke_fh = rados_kv_add_revoke_fh,
+ .try_lift_grace = simple_try_lift_grace,
};
void rados_kv_backend_init(struct nfs4_recovery_backend **backend)
@@ -318,6 +318,7 @@ struct nfs4_recovery_backend rados_ng_backend = {
.add_clid = rados_ng_add_clid,
.rm_clid = rados_ng_rm_clid,
.add_revoke_fh = rados_ng_add_revoke_fh,
+ .try_lift_grace = simple_try_lift_grace,
};
void rados_ng_backend_init(struct nfs4_recovery_backend **backend)
@@ -967,6 +967,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_try_lift_grace(void);
void nfs4_add_clid(nfs_client_id_t *);
void nfs4_rm_clid(nfs_client_id_t *);
@@ -1012,6 +1013,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 *);
+ bool (*try_lift_grace)(void);
};
void fs_backend_init(struct nfs4_recovery_backend **);