Whamcloud - gitweb
LU-8287 nodemap: don't stop config lock when target stops 54/20954/21
authorKit Westneat <kit.westneat@gmail.com>
Mon, 11 Jul 2016 15:17:21 +0000 (11:17 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 11 Aug 2016 05:49:27 +0000 (05:49 +0000)
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 <kit.westneat@gmail.com>
Change-Id: Ibe32f82a6e1a08a011e3d1ede213a2a403befeb8
Reviewed-on: http://review.whamcloud.com/20954
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mgc/mgc_request.c
lustre/ptlrpc/nodemap_handler.c
lustre/ptlrpc/nodemap_internal.h
lustre/ptlrpc/nodemap_member.c

index 450ca24..b263c4b 100644 (file)
@@ -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);
index a416c90..2086246 100644 (file)
@@ -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);
 }
 
index f447eef..4eec107 100644 (file)
@@ -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,
index 5070807..275aaae 100644 (file)
@@ -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;