Whamcloud - gitweb
LU-5108 osc: Performance tune for LRU
[fs/lustre-release.git] / lustre / osc / osc_io.c
index 043a6de..23ef9f4 100644 (file)
@@ -360,8 +360,8 @@ static int osc_io_rw_iter_init(const struct lu_env *env,
        struct osc_object *osc = cl2osc(ios->cis_obj);
        struct client_obd *cli = osc_cli(osc);
        unsigned long c;
-       unsigned long npages;
        unsigned long max_pages;
+       unsigned long npages;
        ENTRY;
 
        if (cl_io_is_append(io))
@@ -376,7 +376,7 @@ static int osc_io_rw_iter_init(const struct lu_env *env,
                npages = max_pages;
 
        c = atomic_long_read(cli->cl_lru_left);
-       if (c < npages && osc_lru_reclaim(cli) > 0)
+       if (c < npages && osc_lru_reclaim(cli, npages) > 0)
                c = atomic_long_read(cli->cl_lru_left);
        while (c >= npages) {
                if (c == atomic_long_cmpxchg(cli->cl_lru_left, c, c - npages)) {
@@ -385,6 +385,15 @@ static int osc_io_rw_iter_init(const struct lu_env *env,
                }
                c = atomic_long_read(cli->cl_lru_left);
        }
+       if (atomic_long_read(cli->cl_lru_left) < max_pages) {
+               /* If there aren't enough pages in the per-OSC LRU then
+                * wake up the LRU thread to try and clear out space, so
+                * we don't block if pages are being dirtied quickly. */
+               CDEBUG(D_CACHE, "%s: queue LRU, left: %lu/%ld.\n",
+                      cli_name(cli), atomic_long_read(cli->cl_lru_left),
+                      max_pages);
+               (void)ptlrpcd_queue_work(cli->cl_lru_work);
+       }
 
        RETURN(0);
 }