Whamcloud - gitweb
b=22520 set the thread to be uninterrupt before add to waitq
authorWang Di <Tom.Wang@sun.com>
Thu, 22 Apr 2010 19:15:24 +0000 (12:15 -0700)
committerRobert Read <robert.read@oracle.com>
Thu, 22 Apr 2010 19:15:24 +0000 (12:15 -0700)
In lov_subobject_kill, if the thread needs to wait the object being
freed, it should set the thread to be uninterrupt, otherwise, the thread
might spin there.

i=Eric.mei
i=Robert

lustre/lov/lov_cl_internal.h
lustre/lov/lov_object.c
lustre/lov/lovsub_object.c

index 21b0ff4..76cd5e4 100644 (file)
@@ -223,6 +223,10 @@ struct lov_object {
                          */
                         struct lovsub_object **lo_sub;
                         /**
                          */
                         struct lovsub_object **lo_sub;
                         /**
+                         * protect lo_sub
+                         */
+                        cfs_spinlock_t         lo_sub_lock;
+                        /**
                          * When this is true, lov_object::lo_attr contains
                          * valid up to date attributes for a top-level
                          * object. This field is reset to 0 when attributes of
                          * When this is true, lov_object::lo_attr contains
                          * valid up to date attributes for a top-level
                          * object. This field is reset to 0 when attributes of
index 079be23..7b1c458 100644 (file)
@@ -209,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;
         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.
                  */
                 /*
                  * Create stripe cl_objects.
                  */
@@ -264,11 +265,20 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov,
                 cfs_waitlink_init(waiter);
                 cfs_waitq_add(&site->ls_marche_funebre, waiter);
                 cfs_set_current_state(CFS_TASK_UNINT);
                 cfs_waitlink_init(waiter);
                 cfs_waitq_add(&site->ls_marche_funebre, waiter);
                 cfs_set_current_state(CFS_TASK_UNINT);
-
-                while (r0->lo_sub[idx] == los)
+                while (1) {
                         /* this wait-queue is signaled at the end of
                          * lu_object_free(). */
                         /* 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);
                 cfs_waitq_del(&site->ls_marche_funebre, waiter);
         }
         LASSERT(r0->lo_sub[idx] == NULL);
index 3774df9..d1057f3 100644 (file)
@@ -85,7 +85,9 @@ static void lovsub_object_free(const struct lu_env *env, struct lu_object *obj)
         if (lov) {
                 LASSERT(lov->lo_type == LLT_RAID0);
                 LASSERT(lov->u.raid0.lo_sub[los->lso_index] == los);
         if (lov) {
                 LASSERT(lov->lo_type == LLT_RAID0);
                 LASSERT(lov->u.raid0.lo_sub[los->lso_index] == los);
+                cfs_spin_lock(&lov->u.raid0.lo_sub_lock);
                 lov->u.raid0.lo_sub[los->lso_index] = NULL;
                 lov->u.raid0.lo_sub[los->lso_index] = NULL;
+                cfs_spin_unlock(&lov->u.raid0.lo_sub_lock);
         }
 
         lu_object_fini(obj);
         }
 
         lu_object_fini(obj);