Whamcloud - gitweb
LU-10239 osc: limit chunk number of write submit
[fs/lustre-release.git] / lustre / osc / osc_cache.c
index f94f053..4660212 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2016, Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
  *
  */
 /*
@@ -699,7 +699,7 @@ restart:
                pgoff_t ext_chk_end   = ext->oe_end   >> ppc_bits;
 
                LASSERT(sanity_check_nolock(ext) == 0);
-               if (chunk > ext_chk_end + 1)
+               if (chunk > ext_chk_end + 1 || chunk < ext_chk_start)
                        break;
 
                /* if covering by different locks, no chance to match */
@@ -976,6 +976,7 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index,
        struct client_obd     *cli = osc_cli(obj);
        struct osc_async_page *oap;
        struct osc_async_page *tmp;
+       struct pagevec        *pvec;
        int                    pages_in_chunk = 0;
        int                    ppc_bits    = cli->cl_chunkbits -
                                             PAGE_SHIFT;
@@ -1000,6 +1001,8 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index,
        io  = osc_env_thread_io(env);
        io->ci_obj = cl_object_top(osc2cl(obj));
        io->ci_ignore_layout = 1;
+       pvec = &osc_env_info(env)->oti_pagevec;
+       ll_pagevec_init(pvec, 0);
        rc = cl_io_init(env, io, CIT_MISC, io->ci_obj);
        if (rc < 0)
                GOTO(out, rc);
@@ -1037,11 +1040,13 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index,
                }
 
                lu_ref_del(&page->cp_reference, "truncate", current);
-               cl_page_put(env, page);
+               cl_pagevec_put(env, page, pvec);
 
                --ext->oe_nr_pages;
                ++nr_pages;
        }
+       pagevec_release(pvec);
+
        EASSERTF(ergo(ext->oe_start >= trunc_index + !!partial,
                      ext->oe_nr_pages == 0),
                ext, "trunc_index %lu, partial %d\n", trunc_index, partial);
@@ -1286,7 +1291,7 @@ static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap,
        ENTRY;
        result = cl_page_make_ready(env, page, CRT_WRITE);
        if (result == 0)
-               opg->ops_submit_time = cfs_time_current();
+               opg->ops_submit_time = ktime_get();
        RETURN(result);
 }
 
@@ -1342,7 +1347,7 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap,
        /* Clear opg->ops_transfer_pinned before VM lock is released. */
        opg->ops_transfer_pinned = 0;
 
-       opg->ops_submit_time = 0;
+       opg->ops_submit_time = ktime_set(0, 0);
        srvlock = oap->oap_brw_flags & OBD_BRW_SRVLOCK;
 
        /* statistic */
@@ -1986,36 +1991,6 @@ static int try_to_add_extent_for_io(struct client_obd *cli,
        RETURN(1);
 }
 
-static inline unsigned osc_max_write_chunks(const struct client_obd *cli)
-{
-       /*
-        * LU-8135:
-        *
-        * The maximum size of a single transaction is about 64MB in ZFS.
-        * #define DMU_MAX_ACCESS (64 * 1024 * 1024)
-        *
-        * Since ZFS is a copy-on-write file system, a single dirty page in
-        * a chunk will result in the rewrite of the whole chunk, therefore
-        * an RPC shouldn't be allowed to contain too many chunks otherwise
-        * it will make transaction size much bigger than 64MB, especially
-        * with big block size for ZFS.
-        *
-        * This piece of code is to make sure that OSC won't send write RPCs
-        * with too many chunks. The maximum chunk size that an RPC can cover
-        * is set to PTLRPC_MAX_BRW_SIZE, which is defined to 16MB. Ideally
-        * OST should tell the client what the biggest transaction size is,
-        * but it's good enough for now.
-        *
-        * This limitation doesn't apply to ldiskfs, which allows as many
-        * chunks in one RPC as we want. However, it won't have any benefits
-        * to have too many discontiguous pages in one RPC.
-        *
-        * An osc_extent won't cover over a RPC size, so the chunks in an
-        * osc_extent won't bigger than PTLRPC_MAX_BRW_SIZE >> chunkbits.
-        */
-       return PTLRPC_MAX_BRW_SIZE >> cli->cl_chunkbits;
-}
-
 /**
  * In order to prevent multiple ptlrpcd from breaking contiguous extents,
  * get_write_extent() takes all appropriate extents in atomic.
@@ -3142,6 +3117,7 @@ int osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io,
                        osc_page_gang_cbt cb, void *cbdata)
 {
        struct osc_page *ops;
+       struct pagevec  *pagevec;
        void            **pvec;
        pgoff_t         idx;
        unsigned int    nr;
@@ -3153,6 +3129,8 @@ int osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io,
 
        idx = start;
        pvec = osc_env_info(env)->oti_pvec;
+       pagevec = &osc_env_info(env)->oti_pagevec;
+       ll_pagevec_init(pagevec, 0);
        spin_lock(&osc->oo_tree_lock);
        while ((nr = radix_tree_gang_lookup(&osc->oo_tree, pvec,
                                            idx, OTI_PVEC_SIZE)) > 0) {
@@ -3199,8 +3177,10 @@ int osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io,
 
                        page = ops->ops_cl.cpl_page;
                        lu_ref_del(&page->cp_reference, "gang_lookup", current);
-                       cl_page_put(env, page);
+                       cl_pagevec_put(env, page, pagevec);
                }
+               pagevec_release(pagevec);
+
                if (nr < OTI_PVEC_SIZE || end_of_region)
                        break;