Whamcloud - gitweb
LU-3963 libcfs: remove last cfs wrappers for cpu node handling
[fs/lustre-release.git] / lustre / lov / lov_lock.c
index 00d372d..1d1d980 100644 (file)
@@ -122,7 +122,7 @@ static void lov_sublock_adopt(const struct lu_env *env, struct lov_lock *lck,
         lck->lls_sub[idx].sub_lock = lsl;
         lck->lls_nr_filled++;
         LASSERT(lck->lls_nr_filled <= lck->lls_nr);
-        cfs_list_add_tail(&link->lll_list, &lsl->lss_parents);
+       list_add_tail(&link->lll_list, &lsl->lss_parents);
         link->lll_idx = idx;
         link->lll_super = lck;
         cl_lock_get(parent);
@@ -205,7 +205,7 @@ static int lov_sublock_lock(const struct lu_env *env,
         int                 result = 0;
         ENTRY;
 
-        LASSERT(cfs_list_empty(&closure->clc_list));
+       LASSERT(list_empty(&closure->clc_list));
 
         sublock = lls->sub_lock;
         child = sublock->lss_cl.cls_lock;
@@ -270,7 +270,7 @@ static int lov_subresult(int result, int rc)
         ENTRY;
 
        LASSERTF(result <= 0 || result == CLO_REPEAT || result == CLO_WAIT,
-                "result = %d", result);
+                "result = %d\n", result);
        LASSERTF(rc <= 0 || rc == CLO_REPEAT || rc == CLO_WAIT,
                 "rc = %d\n", rc);
         CLASSERT(CLO_WAIT < CLO_REPEAT);
@@ -318,8 +318,9 @@ static int lov_lock_sub_init(const struct lu_env *env,
                  * XXX for wide striping smarter algorithm is desirable,
                  * breaking out of the loop, early.
                  */
-               if (lov_stripe_intersects(loo->lo_lsm, i,
-                                          file_start, file_end, &start, &end))
+               if (likely(r0->lo_sub[i] != NULL) &&
+                   lov_stripe_intersects(loo->lo_lsm, i,
+                                         file_start, file_end, &start, &end))
                         nr++;
         }
         LASSERT(nr > 0);
@@ -336,8 +337,9 @@ static int lov_lock_sub_init(const struct lu_env *env,
          * top-lock.
          */
         for (i = 0, nr = 0; i < r0->lo_nr; ++i) {
-               if (lov_stripe_intersects(loo->lo_lsm, i,
-                                          file_start, file_end, &start, &end)) {
+               if (likely(r0->lo_sub[i] != NULL) &&
+                   lov_stripe_intersects(loo->lo_lsm, i,
+                                         file_start, file_end, &start, &end)) {
                         struct cl_lock_descr *descr;
 
                         descr = &lck->lls_sub[nr].sub_descr;
@@ -689,6 +691,7 @@ static int lov_lock_unuse(const struct lu_env *env,
                                lov_sublock_release(env, lck, i, 0, 0);
                                break;
                        default:
+                               cl_lock_cancel(subenv->lse_env, sublock);
                                lov_sublock_release(env, lck, i, 1, 0);
                                break;
                        }
@@ -745,6 +748,7 @@ static void lov_lock_cancel(const struct lu_env *env,
                                 lov_sublock_release(env, lck, i, 0, 0);
                                 break;
                         default:
+                               cl_lock_cancel(subenv->lse_env, sublock);
                                 lov_sublock_release(env, lck, i, 1, 0);
                                 break;
                         }
@@ -948,10 +952,25 @@ static int lov_lock_stripe_is_matching(const struct lu_env *env,
          */
         start = cl_offset(&lov->lo_cl, descr->cld_start);
         end   = cl_offset(&lov->lo_cl, descr->cld_end + 1) - 1;
-        result = end - start <= lsm->lsm_stripe_size &&
-                 stripe == lov_stripe_number(lsm, start) &&
-                 stripe == lov_stripe_number(lsm, end);
-        if (result) {
+
+       result = 0;
+       /* glimpse should work on the object with LOV EA hole. */
+       if ((end - start <= lsm->lsm_stripe_size) ||
+           (descr->cld_end == CL_PAGE_EOF &&
+            unlikely(lov->lo_lsm->lsm_pattern & LOV_PATTERN_F_HOLE))) {
+               int idx;
+
+               idx = lov_stripe_number(lsm, start);
+               if (idx == stripe ||
+                   unlikely(lov_r0(lov)->lo_sub[idx] == NULL)) {
+                       idx = lov_stripe_number(lsm, end);
+                       if (idx == stripe ||
+                           unlikely(lov_r0(lov)->lo_sub[idx] == NULL))
+                               result = 1;
+               }
+       }
+
+       if (result != 0) {
                 struct cl_lock_descr *subd = &lov_env_info(env)->lti_ldescr;
                 obd_off sub_start;
                 obd_off sub_end;
@@ -1045,7 +1064,7 @@ void lov_lock_unlink(const struct lu_env *env,
         LASSERT(cl_lock_is_mutexed(sub->lss_cl.cls_lock));
         ENTRY;
 
-        cfs_list_del_init(&link->lll_list);
+       list_del_init(&link->lll_list);
         LASSERT(lck->lls_sub[link->lll_idx].sub_lock == sub);
         /* yank this sub-lock from parent's array */
         lck->lls_sub[link->lll_idx].sub_lock = NULL;
@@ -1066,7 +1085,7 @@ struct lov_lock_link *lov_lock_link_find(const struct lu_env *env,
         LASSERT(cl_lock_is_mutexed(sub->lss_cl.cls_lock));
         ENTRY;
 
-        cfs_list_for_each_entry(scan, &sub->lss_parents, lll_list) {
+       list_for_each_entry(scan, &sub->lss_parents, lll_list) {
                 if (scan->lll_super == lck)
                         RETURN(scan);
         }
@@ -1221,7 +1240,7 @@ static struct cl_lock_closure *lov_closure_get(const struct lu_env *env,
         struct cl_lock_closure *closure;
 
         closure = &lov_env_info(env)->lti_closure;
-        LASSERT(cfs_list_empty(&closure->clc_list));
+       LASSERT(list_empty(&closure->clc_list));
         cl_lock_closure_init(env, closure, parent, 1);
         return closure;
 }