Whamcloud - gitweb
LU-8918 obdclass: hoist locking in lu_context_exit() 17/24217/2
authorJohn L. Hammond <john.hammond@intel.com>
Tue, 6 Dec 2016 23:09:06 +0000 (17:09 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 16 Mar 2017 21:38:56 +0000 (21:38 +0000)
Hoist lu_keys_guard locking out of the for loop in lu_context_exit().

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: I2f79a1321a48d8a459b4f83a7996ca2ae9a8e4bb
Reviewed-on: https://review.whamcloud.com/24217
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/obdclass/lu_object.c

index 2f0fb3e..b633d26 100644 (file)
@@ -1795,10 +1795,11 @@ void lu_context_exit(struct lu_context *ctx)
         LINVRNT(ctx->lc_state == LCS_ENTERED);
         ctx->lc_state = LCS_LEFT;
         if (ctx->lc_tags & LCT_HAS_EXIT && ctx->lc_value != NULL) {
+               /* could race with key quiescency */
+               if (ctx->lc_tags & LCT_REMEMBER)
+                       read_lock(&lu_keys_guard);
+
                 for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) {
-                       /* could race with key quiescency */
-                       if (ctx->lc_tags & LCT_REMEMBER)
-                               read_lock(&lu_keys_guard);
                        if (ctx->lc_value[i] != NULL) {
                                struct lu_context_key *key;
 
@@ -1808,9 +1809,10 @@ void lu_context_exit(struct lu_context *ctx)
                                        key->lct_exit(ctx,
                                                      key, ctx->lc_value[i]);
                        }
-                       if (ctx->lc_tags & LCT_REMEMBER)
-                               read_unlock(&lu_keys_guard);
                 }
+
+               if (ctx->lc_tags & LCT_REMEMBER)
+                       read_unlock(&lu_keys_guard);
         }
 }
 EXPORT_SYMBOL(lu_context_exit);