Whamcloud - gitweb
LU-607 Avoid race between ldlm_pools_shrink and ldlm_namespace_free
authorBobi Jam <bobijam@whamcloud.com>
Tue, 23 Aug 2011 13:23:10 +0000 (21:23 +0800)
committerJohann Lombardi <johann@whamcloud.com>
Fri, 2 Sep 2011 22:16:36 +0000 (18:16 -0400)
ldlm_namespace_free removes namespace from list and free memory
without checking namespace's refcount while ldlm_pools_shrink might
get namespace from the list and start ldlm_pool_shrink() for it.

Bugzila: 24419
Author: Vladimir Saveliev <vladimir.saveliev@oracle.com>
Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: I757204ad119927cacdb73db66f5e40ace50eeea8
Reviewed-on: http://review.whamcloud.com/1273
Tested-by: Hudson
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
lustre/ldlm/ldlm_resource.c

index 62a285e..7a0e895 100644 (file)
@@ -584,6 +584,8 @@ void ldlm_namespace_free_prior(struct ldlm_namespace *ns,
                 return;
         }
 
+        /* Make sure that nobody can find this ns in its list. */
+        ldlm_namespace_unregister(ns, ns->ns_client);
 
         /* Can fail with -EINTR when force == 0 in which case try harder */
         rc = __ldlm_namespace_free(ns, force);
@@ -609,9 +611,6 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns)
                 return;
         }
 
-        /* Make sure that nobody can find this ns in its list. */
-        ldlm_namespace_unregister(ns, ns->ns_client);
-
         /* Fini pool _before_ parent proc dir is removed. This is important
          * as ldlm_pool_fini() removes own proc dir which is child to @dir.
          * Removing it after @dir may cause oops. */