Whamcloud - gitweb
LU-15013 osc: use original cli for osc_lru_reclaim for debug msg
[fs/lustre-release.git] / lustre / osc / osc_page.c
index 065bebe..eb60998 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * Implementation of cl_page for OSC layer.
  *
@@ -216,6 +215,9 @@ static void osc_page_clip(const struct lu_env *env,
        opg->ops_from = from;
        /* argument @to is exclusive, but @ops_to is inclusive */
        opg->ops_to   = to - 1;
+       /* This isn't really necessary for transient pages, but we also don't
+        * call clip on transient pages often, so it's OK.
+        */
        spin_lock(&oap->oap_lock);
        oap->oap_async_flags |= ASYNC_COUNT_STABLE;
        spin_unlock(&oap->oap_lock);
@@ -262,8 +264,7 @@ int osc_page_init(const struct lu_env *env, struct cl_object *obj,
 
        INIT_LIST_HEAD(&opg->ops_lru);
 
-       result = osc_prep_async_page(osc, opg, cl_page->cp_vmpage,
-                                    cl_offset(obj, index));
+       result = osc_prep_async_page(osc, opg, cl_page, cl_offset(obj, index));
        if (result != 0)
                return result;
 
@@ -300,7 +301,7 @@ EXPORT_SYMBOL(osc_page_init);
  * transfer (i.e., transferred synchronously).
  */
 void osc_page_submit(const struct lu_env *env, struct osc_page *opg,
-                    enum cl_req_type crt, int brw_flags)
+                    enum cl_req_type crt, int brw_flags, ktime_t submit_time)
 {
        struct osc_io *oio = osc_env_io(env);
        struct osc_async_page *oap = &opg->ops_oap;
@@ -316,11 +317,11 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg,
        oap->oap_brw_flags = OBD_BRW_SYNC | brw_flags;
 
        if (oio->oi_cap_sys_resource) {
-               oap->oap_brw_flags |= OBD_BRW_NOQUOTA;
-               oap->oap_cmd |= OBD_BRW_NOQUOTA;
+               oap->oap_brw_flags |= OBD_BRW_SYS_RESOURCE;
+               oap->oap_cmd |= OBD_BRW_SYS_RESOURCE;
        }
 
-       opg->ops_submit_time = ktime_get();
+       opg->ops_submit_time = submit_time;
        osc_page_transfer_get(opg, "transfer\0imm");
        osc_page_transfer_add(env, opg, crt);
 }
@@ -597,8 +598,8 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli,
                if (--maxscan < 0)
                        break;
 
-               opg = list_entry(cli->cl_lru_list.next, struct osc_page,
-                                ops_lru);
+               opg = list_first_entry(&cli->cl_lru_list, struct osc_page,
+                                      ops_lru);
                page = opg->ops_cl.cpl_page;
                if (lru_page_busy(cli, page)) {
                        list_move_tail(&opg->ops_lru, &cli->cl_lru_list);
@@ -679,7 +680,7 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli,
        atomic_dec(&cli->cl_lru_shrinkers);
        if (count > 0) {
                atomic_long_add(count, cli->cl_lru_left);
-               wake_up_all(&osc_lru_waitq);
+               wake_up(&osc_lru_waitq);
        }
        RETURN(count > 0 ? count : rc);
 }
@@ -695,6 +696,7 @@ static long osc_lru_reclaim(struct client_obd *cli, unsigned long npages)
 {
        struct lu_env *env;
        struct cl_client_cache *cache = cli->cl_cache;
+       struct client_obd *scan;
        int max_scans;
        __u16 refcheck;
        long rc = 0;
@@ -733,20 +735,20 @@ static long osc_lru_reclaim(struct client_obd *cli, unsigned long npages)
        list_move_tail(&cli->cl_lru_osc, &cache->ccc_lru);
 
        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);
-
+       while (--max_scans > 0 &&
+              (scan = list_first_entry_or_null(&cache->ccc_lru,
+                                                 struct client_obd,
+                                                 cl_lru_osc)) != NULL) {
                CDEBUG(D_CACHE, "%s: cli %p LRU pages: %ld, busy: %ld.\n",
-                       cli_name(cli), cli,
-                       atomic_long_read(&cli->cl_lru_in_list),
-                       atomic_long_read(&cli->cl_lru_busy));
+                      cli_name(scan), scan,
+                      atomic_long_read(&scan->cl_lru_in_list),
+                      atomic_long_read(&scan->cl_lru_busy));
 
-               list_move_tail(&cli->cl_lru_osc, &cache->ccc_lru);
-               if (osc_cache_too_much(cli) > 0) {
+               list_move_tail(&scan->cl_lru_osc, &cache->ccc_lru);
+               if (osc_cache_too_much(scan) > 0) {
                        spin_unlock(&cache->ccc_lru_lock);
 
-                       rc = osc_lru_shrink(env, cli, npages, true);
+                       rc = osc_lru_shrink(env, scan, npages, true);
                        spin_lock(&cache->ccc_lru_lock);
                        if (rc >= npages)
                                break;
@@ -759,7 +761,7 @@ static long osc_lru_reclaim(struct client_obd *cli, unsigned long npages)
 out:
        cl_env_put(env, &refcheck);
        CDEBUG(D_CACHE, "%s: cli %p freed %ld pages.\n",
-               cli_name(cli), cli, rc);
+              cli_name(cli), cli, rc);
        return rc;
 }
 
@@ -890,7 +892,7 @@ again:
 void osc_lru_unreserve(struct client_obd *cli, unsigned long npages)
 {
        atomic_long_add(npages, cli->cl_lru_left);
-       wake_up_all(&osc_lru_waitq);
+       wake_up(&osc_lru_waitq);
 }
 
 /**
@@ -993,7 +995,7 @@ void osc_dec_unstable_pages(struct ptlrpc_request *req)
                                           &cli->cl_cache->ccc_unstable_nr);
        LASSERT(unstable_count >= 0);
        if (unstable_count == 0)
-               wake_up_all(&cli->cl_cache->ccc_unstable_waitq);
+               wake_up(&cli->cl_cache->ccc_unstable_waitq);
 
        if (waitqueue_active(&osc_lru_waitq))
                (void)ptlrpcd_queue_work(cli->cl_lru_work);
@@ -1122,10 +1124,9 @@ unsigned long osc_cache_shrink_scan(struct shrinker *sk,
                return SHRINK_STOP;
 
        spin_lock(&osc_shrink_lock);
-       while (!list_empty(&osc_shrink_list)) {
-               cli = list_entry(osc_shrink_list.next, struct client_obd,
-                                cl_shrink_list);
-
+       while ((cli = list_first_entry_or_null(&osc_shrink_list,
+                                              struct client_obd,
+                                              cl_shrink_list)) != NULL) {
                if (stop_anchor == NULL)
                        stop_anchor = cli;
                else if (cli == stop_anchor)