Whamcloud - gitweb
LU-5710 all: second batch of corrected typos and grammar errors
[fs/lustre-release.git] / lustre / osc / osc_page.c
index 8d6d69d..72285ba 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/
@@ -232,26 +232,6 @@ void osc_index2policy(ldlm_policy_data_t *policy, const struct cl_object *obj,
         policy->l_extent.end   = cl_offset(obj, end + 1) - 1;
 }
 
-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;
-
-       *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);
-               result = 0;
-       }
-       RETURN(result);
-}
-
 static const char *osc_list(struct list_head *head)
 {
        return list_empty(head) ? "-" : "+";
@@ -276,7 +256,7 @@ static int osc_page_print(const struct lu_env *env,
 
        return (*printer)(env, cookie, LUSTRE_OSC_NAME"-page@%p %lu: "
                          "1< %#x %d %u %s %s > "
-                         "2< "LPU64" %u %u %#x %#x | %p %p %p > "
+                         "2< "LPD64" %u %u %#x %#x | %p %p %p > "
                          "3< %s %p %d %lu %d > "
                          "4< %d %d %d %lu %s | %s %s %s %s > "
                          "5< %s %s %s %s | %d %s | %d %s %s>\n",
@@ -359,8 +339,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;
@@ -405,7 +386,6 @@ static int osc_page_flush(const struct lu_env *env,
 static const struct cl_page_operations osc_page_ops = {
        .cpo_print         = osc_page_print,
        .cpo_delete        = osc_page_delete,
-       .cpo_is_under_lock = osc_page_is_under_lock,
        .cpo_clip           = osc_page_clip,
        .cpo_cancel         = osc_page_cancel,
        .cpo_flush          = osc_page_flush
@@ -520,7 +500,8 @@ static int osc_cache_too_much(struct client_obd *cli)
        long pages = atomic_long_read(&cli->cl_lru_in_list);
        unsigned long budget;
 
-       budget = cache->ccc_lru_max / atomic_read(&cache->ccc_users);
+       LASSERT(cache != NULL);
+       budget = cache->ccc_lru_max / (atomic_read(&cache->ccc_users) - 2);
 
        /* if it's going to run out LRU slots, we should free some, but not
         * too much to maintain faireness among OSCs. */
@@ -529,8 +510,11 @@ static int osc_cache_too_much(struct client_obd *cli)
                        return lru_shrink_max;
                else if (pages >= budget / 2)
                        return lru_shrink_min;
+#if 0
        } else if (pages >= budget * 2)
                return lru_shrink_min;
+#endif
+       }
        return 0;
 }
 
@@ -564,11 +548,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 +574,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
@@ -616,12 +600,12 @@ static void osc_lru_del(struct client_obd *cli, struct osc_page *opg)
  */
 static void osc_lru_use(struct client_obd *cli, struct osc_page *opg)
 {
-       /* If page is being transfered for the first time,
+       /* If page is being transferred 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 +684,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 +706,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 +722,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 +753,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);
@@ -833,7 +817,7 @@ long osc_lru_reclaim(struct client_obd *cli)
        cache->ccc_lru_shrinkers++;
        list_move_tail(&cli->cl_lru_osc, &cache->ccc_lru);
 
-       max_scans = atomic_read(&cache->ccc_users);
+       max_scans = atomic_read(&cache->ccc_users) - 2;
        while (--max_scans > 0 && !list_empty(&cache->ccc_lru)) {
                cli = list_entry(cache->ccc_lru.next, struct client_obd,
                                 cl_lru_osc);
@@ -924,7 +908,7 @@ out:
 static inline void unstable_page_accounting(struct ptlrpc_bulk_desc *desc,
                                            int factor)
 {
-       obd_count page_count = desc->bd_iov_count;
+       int page_count = desc->bd_iov_count;
        void *zone = NULL;
        int count = 0;
        int i;