Whamcloud - gitweb
b=22598 diagnostic patch for lock cancel callback error processing
[fs/lustre-release.git] / lustre / lov / lov_object.c
index 8ef1413..7b1c458 100644 (file)
  *   Author: Nikita Danilov <nikita.danilov@sun.com>
  */
 
-/** \addtogroup lov lov @{ */
-
 #define DEBUG_SUBSYSTEM S_LOV
 
 #include "lov_cl_internal.h"
 
+/** \addtogroup lov
+ *  @{
+ */
+
 /*****************************************************************************
  *
  * Layout operations.
@@ -207,6 +209,7 @@ static int lov_init_raid0(const struct lu_env *env,
         if (r0->lo_sub != NULL) {
                 result = 0;
                 subconf->coc_inode = conf->coc_inode;
+                cfs_spin_lock_init(&r0->lo_sub_lock);
                 /*
                  * Create stripe cl_objects.
                  */
@@ -245,9 +248,11 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov,
         cfs_waitlink_t          *waiter;
 
         r0  = &lov->u.raid0;
-        sub = lovsub2cl(los);
         LASSERT(r0->lo_sub[idx] == los);
 
+        sub  = lovsub2cl(los);
+        site = sub->co_lu.lo_dev->ld_site;
+
         cl_object_kill(env, sub);
         /* release a reference to the sub-object and ... */
         lu_object_ref_del(&sub->co_lu, "lov-parent", lov);
@@ -257,15 +262,23 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov,
          * ->lo_sub[] slot in lovsub_object_fini() */
         if (r0->lo_sub[idx] == los) {
                 waiter = &lov_env_info(env)->lti_waiter;
-                site   = sub->co_lu.lo_dev->ld_site;
                 cfs_waitlink_init(waiter);
                 cfs_waitq_add(&site->ls_marche_funebre, waiter);
-                set_current_state(CFS_TASK_UNINT);
-
-                while (r0->lo_sub[idx] == los)
+                cfs_set_current_state(CFS_TASK_UNINT);
+                while (1) {
                         /* this wait-queue is signaled at the end of
                          * lu_object_free(). */
-                        cfs_waitq_wait(waiter, CFS_TASK_UNINT);
+                        cfs_set_current_state(CFS_TASK_UNINT);
+                        cfs_spin_lock(&r0->lo_sub_lock);
+                        if (r0->lo_sub[idx] == los) {
+                                cfs_spin_unlock(&r0->lo_sub_lock);
+                                cfs_waitq_wait(waiter, CFS_TASK_UNINT);
+                        } else {
+                                cfs_spin_unlock(&r0->lo_sub_lock);
+                                cfs_set_current_state(CFS_TASK_RUNNING);
+                                break;
+                        }
+                }
                 cfs_waitq_del(&site->ls_marche_funebre, waiter);
         }
         LASSERT(r0->lo_sub[idx] == NULL);
@@ -445,10 +458,10 @@ const static struct lov_layout_operations lov_dispatch[] = {
                                                                         \
         __lock &= __obj->lo_owner != cfs_current();                     \
         if (__lock)                                                     \
-                down_read(&__obj->lo_type_guard);                       \
+                cfs_down_read(&__obj->lo_type_guard);                   \
         __result = LOV_2DISPATCH_NOLOCK(obj, op, __VA_ARGS__);          \
         if (__lock)                                                     \
-                up_read(&__obj->lo_type_guard);                         \
+                cfs_up_read(&__obj->lo_type_guard);                     \
         __result;                                                       \
 })
 
@@ -464,12 +477,12 @@ do {                                                                    \
         enum lov_layout_type                    __llt;                  \
                                                                         \
         if (__obj->lo_owner != cfs_current())                           \
-                down_read(&__obj->lo_type_guard);                       \
+                cfs_down_read(&__obj->lo_type_guard);                   \
         __llt = __obj->lo_type;                                         \
         LASSERT(0 <= __llt && __llt < ARRAY_SIZE(lov_dispatch));        \
         lov_dispatch[__llt].op(__VA_ARGS__);                            \
         if (__obj->lo_owner != cfs_current())                           \
-                up_read(&__obj->lo_type_guard);                         \
+                cfs_up_read(&__obj->lo_type_guard);                     \
 } while (0)
 
 static int lov_layout_change(const struct lu_env *env,
@@ -506,7 +519,7 @@ static int lov_layout_change(const struct lu_env *env,
                 cl_env_reexit(cookie);
 
                 old_ops->llo_fini(env, obj, &obj->u);
-                LASSERT(list_empty(&hdr->coh_locks));
+                LASSERT(cfs_list_empty(&hdr->coh_locks));
                 LASSERT(hdr->coh_tree.rnode == NULL);
                 LASSERT(hdr->coh_pages == 0);
 
@@ -534,7 +547,7 @@ int lov_object_init(const struct lu_env *env, struct lu_object *obj,
         int result;
 
         ENTRY;
-        init_rwsem(&lov->lo_type_guard);
+        cfs_init_rwsem(&lov->lo_type_guard);
 
         /* no locking is necessary, as object is being created */
         lov->lo_type = cconf->u.coc_md->lsm != NULL ? LLT_RAID0 : LLT_EMPTY;
@@ -558,7 +571,7 @@ static int lov_conf_set(const struct lu_env *env, struct cl_object *obj,
          * Currently only LLT_EMPTY -> LLT_RAID0 transition is supported.
          */
         LASSERT(lov->lo_owner != cfs_current());
-        down_write(&lov->lo_type_guard);
+        cfs_down_write(&lov->lo_type_guard);
         LASSERT(lov->lo_owner == NULL);
         lov->lo_owner = cfs_current();
         if (lov->lo_type == LLT_EMPTY && conf->u.coc_md->lsm != NULL)
@@ -566,7 +579,7 @@ static int lov_conf_set(const struct lu_env *env, struct cl_object *obj,
         else
                 result = -EOPNOTSUPP;
         lov->lo_owner = NULL;
-        up_write(&lov->lo_type_guard);
+        cfs_up_write(&lov->lo_type_guard);
         RETURN(result);
 }
 
@@ -674,7 +687,7 @@ static const struct lu_object_operations lov_lu_obj_ops = {
 };
 
 struct lu_object *lov_object_alloc(const struct lu_env *env,
-                                   const struct lu_object_header *_,
+                                   const struct lu_object_header *unused,
                                    struct lu_device *dev)
 {
         struct lov_object *lov;