Whamcloud - gitweb
LU-6042 osc: osc_object_ast_clear() LBUG
[fs/lustre-release.git] / lustre / osc / osc_page.c
index 8d6d69d..a1e90e2 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -236,17 +236,17 @@ static int osc_page_is_under_lock(const struct lu_env *env,
                                  const struct cl_page_slice *slice,
                                  struct cl_io *unused, pgoff_t *max_index)
 {
-       struct osc_page *opg = cl2osc_page(slice);
-       struct cl_lock *lock;
-       int             result = -ENODATA;
-       ENTRY;
+       struct osc_page         *opg = cl2osc_page(slice);
+       struct ldlm_lock        *dlmlock;
+       int                     result = -ENODATA;
 
-       *max_index = 0;
-       lock = cl_lock_at_pgoff(env, slice->cpl_obj, osc_index(opg),
-                               NULL, 1, 0);
-       if (lock != NULL) {
-               *max_index = lock->cll_descr.cld_end;
-               cl_lock_put(env, lock);
+       ENTRY;
+       dlmlock = osc_dlmlock_at_pgoff(env, cl2osc(slice->cpl_obj),
+                                      osc_index(opg), 1, 0);
+       if (dlmlock != NULL) {
+               *max_index = cl_index(slice->cpl_obj,
+                                     dlmlock->l_policy_data.l_extent.end);
+               LDLM_LOCK_PUT(dlmlock);
                result = 0;
        }
        RETURN(result);
@@ -359,8 +359,9 @@ static void osc_page_delete(const struct lu_env *env,
        EXIT;
 }
 
-void osc_page_clip(const struct lu_env *env, const struct cl_page_slice *slice,
-                   int from, int to)
+static void osc_page_clip(const struct lu_env *env,
+                         const struct cl_page_slice *slice,
+                         int from, int to)
 {
         struct osc_page       *opg = cl2osc_page(slice);
         struct osc_async_page *oap = &opg->ops_oap;
@@ -564,11 +565,11 @@ void osc_lru_add_batch(struct client_obd *cli, struct list_head *plist)
        }
 
        if (npages > 0) {
-               client_obd_list_lock(&cli->cl_lru_list_lock);
+               spin_lock(&cli->cl_lru_list_lock);
                list_splice_tail(&lru, &cli->cl_lru_list);
                atomic_long_sub(npages, &cli->cl_lru_busy);
                atomic_long_add(npages, &cli->cl_lru_in_list);
-               client_obd_list_unlock(&cli->cl_lru_list_lock);
+               spin_unlock(&cli->cl_lru_list_lock);
 
                /* XXX: May set force to be true for better performance */
                if (osc_cache_too_much(cli))
@@ -590,14 +591,14 @@ static void __osc_lru_del(struct client_obd *cli, struct osc_page *opg)
 static void osc_lru_del(struct client_obd *cli, struct osc_page *opg)
 {
        if (opg->ops_in_lru) {
-               client_obd_list_lock(&cli->cl_lru_list_lock);
+               spin_lock(&cli->cl_lru_list_lock);
                if (!list_empty(&opg->ops_lru)) {
                        __osc_lru_del(cli, opg);
                } else {
                        LASSERT(atomic_long_read(&cli->cl_lru_busy) > 0);
                        atomic_long_dec(&cli->cl_lru_busy);
                }
-               client_obd_list_unlock(&cli->cl_lru_list_lock);
+               spin_unlock(&cli->cl_lru_list_lock);
 
                atomic_long_inc(cli->cl_lru_left);
                /* this is a great place to release more LRU pages if
@@ -619,9 +620,9 @@ static void osc_lru_use(struct client_obd *cli, struct osc_page *opg)
        /* If page is being transfered for the first time,
         * ops_lru should be empty */
        if (opg->ops_in_lru && !list_empty(&opg->ops_lru)) {
-               client_obd_list_lock(&cli->cl_lru_list_lock);
+               spin_lock(&cli->cl_lru_list_lock);
                __osc_lru_del(cli, opg);
-               client_obd_list_unlock(&cli->cl_lru_list_lock);
+               spin_unlock(&cli->cl_lru_list_lock);
                atomic_long_inc(&cli->cl_lru_busy);
        }
 }
@@ -700,7 +701,7 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli,
        pvec = (struct cl_page **)osc_env_info(env)->oti_pvec;
        io = &osc_env_info(env)->oti_io;
 
-       client_obd_list_lock(&cli->cl_lru_list_lock);
+       spin_lock(&cli->cl_lru_list_lock);
        maxscan = min(target << 1, atomic_long_read(&cli->cl_lru_in_list));
        while (!list_empty(&cli->cl_lru_list)) {
                struct cl_page *page;
@@ -722,7 +723,7 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli,
                        struct cl_object *tmp = page->cp_obj;
 
                        cl_object_get(tmp);
-                       client_obd_list_unlock(&cli->cl_lru_list_lock);
+                       spin_unlock(&cli->cl_lru_list_lock);
 
                        if (clobj != NULL) {
                                discard_pagevec(env, io, pvec, index);
@@ -738,7 +739,7 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli,
                        io->ci_ignore_layout = 1;
                        rc = cl_io_init(env, io, CIT_MISC, clobj);
 
-                       client_obd_list_lock(&cli->cl_lru_list_lock);
+                       spin_lock(&cli->cl_lru_list_lock);
 
                        if (rc != 0)
                                break;
@@ -769,17 +770,17 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli,
                /* Don't discard and free the page with cl_lru_list held */
                pvec[index++] = page;
                if (unlikely(index == OTI_PVEC_SIZE)) {
-                       client_obd_list_unlock(&cli->cl_lru_list_lock);
+                       spin_unlock(&cli->cl_lru_list_lock);
                        discard_pagevec(env, io, pvec, index);
                        index = 0;
 
-                       client_obd_list_lock(&cli->cl_lru_list_lock);
+                       spin_lock(&cli->cl_lru_list_lock);
                }
 
                if (++count >= target)
                        break;
        }
-       client_obd_list_unlock(&cli->cl_lru_list_lock);
+       spin_unlock(&cli->cl_lru_list_lock);
 
        if (clobj != NULL) {
                discard_pagevec(env, io, pvec, index);