From 45ce1044cd7b94621e1161cd23c600f8e1c18317 Mon Sep 17 00:00:00 2001 From: Kit Westneat Date: Mon, 11 Jul 2016 11:17:21 -0400 Subject: [PATCH] LU-8287 nodemap: don't stop config lock when target stops Target config log locks keep a reference to the global nodemap config lock to ensure that it exists while the target is up. When a target is unmounted, the cld_stopping flag on the config lock is set. The nodemap lock, however, should not have its flag set as other targets may still be active. The nodemap config lock is cleaned up when the final target config lock is cleaned up. This also changes nodemap so it revokes locks only when enabled. Signed-off-by: Kit Westneat Change-Id: Ibe32f82a6e1a08a011e3d1ede213a2a403befeb8 Reviewed-on: http://review.whamcloud.com/20954 Reviewed-by: John L. Hammond Reviewed-by: James Simmons Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/mgc/mgc_request.c | 7 ++----- lustre/ptlrpc/nodemap_handler.c | 14 ++++++++++++-- lustre/ptlrpc/nodemap_internal.h | 1 + lustre/ptlrpc/nodemap_member.c | 21 ++++++++++++++++----- 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 450ca24..b263c4b 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -485,12 +485,9 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) config_log_put(cld_params); } - if (cld_nodemap) { - mutex_lock(&cld_nodemap->cld_lock); - cld_nodemap->cld_stopping = 1; - mutex_unlock(&cld_nodemap->cld_lock); + /* don't set cld_stopping on nm lock as other targets may be active */ + if (cld_nodemap) config_log_put(cld_nodemap); - } /* drop the ref from the find */ config_log_put(cld); diff --git a/lustre/ptlrpc/nodemap_handler.c b/lustre/ptlrpc/nodemap_handler.c index a416c90..2086246 100644 --- a/lustre/ptlrpc/nodemap_handler.c +++ b/lustre/ptlrpc/nodemap_handler.c @@ -1415,6 +1415,7 @@ void nodemap_config_set_active(struct nodemap_config *config) struct nodemap_config *old_config = active_config; struct lu_nodemap *nodemap; struct lu_nodemap *tmp; + bool revoke_locks; LIST_HEAD(nodemap_list_head); ENTRY; @@ -1445,6 +1446,14 @@ void nodemap_config_set_active(struct nodemap_config *config) } } + /* + * We only need to revoke locks if old nodemap was active, and new + * config is now nodemap inactive. nodemap_config_dealloc will + * reclassify exports, triggering a lock revoke if and only if new + * nodemap is active. + */ + revoke_locks = !config->nmc_nodemap_is_active && nodemap_active; + /* if new config is inactive, deactivate live config before switching */ if (!config->nmc_nodemap_is_active) nodemap_active = false; @@ -1457,7 +1466,8 @@ void nodemap_config_set_active(struct nodemap_config *config) if (old_config != NULL) nodemap_config_dealloc(old_config); - nm_member_revoke_all(); + if (revoke_locks) + nm_member_revoke_all(); EXIT; } @@ -1519,7 +1529,7 @@ void nm_member_revoke_all(void) /* revoke_locks sleeps, so can't call in cfs hash cb */ list_for_each_entry_safe(nodemap, tmp, &nodemap_list_head, nm_list) - nm_member_revoke_locks(nodemap); + nm_member_revoke_locks_always(nodemap); mutex_unlock(&active_config_lock); } diff --git a/lustre/ptlrpc/nodemap_internal.h b/lustre/ptlrpc/nodemap_internal.h index f447eef..4eec107 100644 --- a/lustre/ptlrpc/nodemap_internal.h +++ b/lustre/ptlrpc/nodemap_internal.h @@ -156,6 +156,7 @@ void nm_member_delete_list(struct lu_nodemap *nodemap); struct lu_nodemap *nodemap_classify_nid(lnet_nid_t nid); void nm_member_reclassify_nodemap(struct lu_nodemap *nodemap); void nm_member_revoke_locks(struct lu_nodemap *nodemap); +void nm_member_revoke_locks_always(struct lu_nodemap *nodemap); void nm_member_revoke_all(void); int nodemap_add_idmap_helper(struct lu_nodemap *nodemap, diff --git a/lustre/ptlrpc/nodemap_member.c b/lustre/ptlrpc/nodemap_member.c index 5070807..275aaae 100644 --- a/lustre/ptlrpc/nodemap_member.c +++ b/lustre/ptlrpc/nodemap_member.c @@ -213,7 +213,9 @@ void nm_member_reclassify_nodemap(struct lu_nodemap *nodemap) list_add(&exp->exp_target_data.ted_nodemap_member, &new_nodemap->nm_member_list); mutex_unlock(&new_nodemap->nm_member_list_lock); - nm_member_exp_revoke(exp); + + if (nodemap_active) + nm_member_exp_revoke(exp); } else { nodemap_putref(new_nodemap); } @@ -224,15 +226,24 @@ void nm_member_reclassify_nodemap(struct lu_nodemap *nodemap) } /** - * Revoke the locks for member exports. Changing the idmap is - * akin to deleting the security context. If the locks are not - * canceled, the client could cache permissions that are no - * longer correct with the map. + * Revoke the locks for member exports if nodemap system is active. + * + * Changing the idmap is akin to deleting the security context. If the locks + * are not canceled, the client could cache permissions that are no longer + * correct with the map. * * \param nodemap nodemap that has been altered */ void nm_member_revoke_locks(struct lu_nodemap *nodemap) { + if (!nodemap_active) + return; + + nm_member_revoke_locks_always(nodemap); +} + +void nm_member_revoke_locks_always(struct lu_nodemap *nodemap) +{ struct obd_export *exp; struct obd_export *tmp; -- 1.8.3.1