Commit 5196e42c authored by Jinshan Xiong's avatar Jinshan Xiong Committed by Greg Kroah-Hartman

staging/lustre/osc: Adjustment on osc LRU for performance

Add and discard pages from LRU in batch.
Signed-off-by: default avatarJinshan Xiong <jinshan.xiong@intel.com>
Reviewed-on: http://review.whamcloud.com/7890
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3321Reviewed-by: default avatarNiu Yawei <yawei.niu@intel.com>
Reviewed-by: default avatarLai Siyao <lai.siyao@intel.com>
Signed-off-by: default avatarOleg Drokin <green@linuxhacker.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 26f98e82
...@@ -85,10 +85,7 @@ static struct ll_sb_info *ll_init_sbi(struct super_block *sb) ...@@ -85,10 +85,7 @@ static struct ll_sb_info *ll_init_sbi(struct super_block *sb)
si_meminfo(&si); si_meminfo(&si);
pages = si.totalram - si.totalhigh; pages = si.totalram - si.totalhigh;
if (pages >> (20 - PAGE_CACHE_SHIFT) < 512) lru_page_max = pages / 2;
lru_page_max = pages / 2;
else
lru_page_max = (pages / 4) * 3;
/* initialize lru data */ /* initialize lru data */
atomic_set(&sbi->ll_cache.ccc_users, 0); atomic_set(&sbi->ll_cache.ccc_users, 0);
......
...@@ -223,7 +223,7 @@ static ssize_t osc_cached_mb_seq_write(struct file *file, ...@@ -223,7 +223,7 @@ static ssize_t osc_cached_mb_seq_write(struct file *file,
rc = atomic_read(&cli->cl_lru_in_list) - pages_number; rc = atomic_read(&cli->cl_lru_in_list) - pages_number;
if (rc > 0) if (rc > 0)
(void)osc_lru_shrink(cli, rc); (void)osc_lru_shrink(cli, rc, true);
return count; return count;
} }
......
...@@ -856,6 +856,8 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext, ...@@ -856,6 +856,8 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext,
ext->oe_rc = rc ?: ext->oe_nr_pages; ext->oe_rc = rc ?: ext->oe_nr_pages;
EASSERT(ergo(rc == 0, ext->oe_state == OES_RPC), ext); EASSERT(ergo(rc == 0, ext->oe_state == OES_RPC), ext);
osc_lru_add_batch(cli, &ext->oe_pages);
list_for_each_entry_safe(oap, tmp, &ext->oe_pages, oap_pending_item) { list_for_each_entry_safe(oap, tmp, &ext->oe_pages, oap_pending_item) {
list_del_init(&oap->oap_rpc_item); list_del_init(&oap->oap_rpc_item);
list_del_init(&oap->oap_pending_item); list_del_init(&oap->oap_pending_item);
......
...@@ -77,6 +77,8 @@ struct osc_io { ...@@ -77,6 +77,8 @@ struct osc_io {
*/ */
struct osc_extent *oi_trunc; struct osc_extent *oi_trunc;
int oi_lru_reserved;
struct obd_info oi_info; struct obd_info oi_info;
struct obdo oi_oa; struct obdo oi_oa;
struct osc_async_cbargs { struct osc_async_cbargs {
...@@ -100,7 +102,7 @@ struct osc_session { ...@@ -100,7 +102,7 @@ struct osc_session {
struct osc_io os_io; struct osc_io os_io;
}; };
#define OTI_PVEC_SIZE 64 #define OTI_PVEC_SIZE 256
struct osc_thread_info { struct osc_thread_info {
struct ldlm_res_id oti_resname; struct ldlm_res_id oti_resname;
ldlm_policy_data_t oti_policy; ldlm_policy_data_t oti_policy;
...@@ -369,18 +371,15 @@ struct osc_page { ...@@ -369,18 +371,15 @@ struct osc_page {
* Set if the page must be transferred with OBD_BRW_SRVLOCK. * Set if the page must be transferred with OBD_BRW_SRVLOCK.
*/ */
ops_srvlock:1; ops_srvlock:1;
union { /**
/** * lru page list. See osc_lru_{del|use}() in osc_page.c for usage.
* lru page list. ops_inflight and ops_lru are exclusive so */
* that they can share the same data. struct list_head ops_lru;
*/ /**
struct list_head ops_lru; * Linkage into a per-osc_object list of pages in flight. For
/** * debugging.
* Linkage into a per-osc_object list of pages in flight. For */
* debugging. struct list_head ops_inflight;
*/
struct list_head ops_inflight;
};
/** /**
* Thread that submitted this page for transfer. For debugging. * Thread that submitted this page for transfer. For debugging.
*/ */
...@@ -432,6 +431,7 @@ void osc_index2policy (ldlm_policy_data_t *policy, const struct cl_object *obj, ...@@ -432,6 +431,7 @@ void osc_index2policy (ldlm_policy_data_t *policy, const struct cl_object *obj,
int osc_lvb_print (const struct lu_env *env, void *cookie, int osc_lvb_print (const struct lu_env *env, void *cookie,
lu_printer_t p, const struct ost_lvb *lvb); lu_printer_t p, const struct ost_lvb *lvb);
void osc_lru_add_batch(struct client_obd *cli, struct list_head *list);
void osc_page_submit(const struct lu_env *env, struct osc_page *opg, 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);
int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops); int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops);
......
...@@ -130,7 +130,8 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, ...@@ -130,7 +130,8 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo,
int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *cfg); int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *cfg);
int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
struct list_head *ext_list, int cmd); struct list_head *ext_list, int cmd);
int osc_lru_shrink(struct client_obd *cli, int target); int osc_lru_shrink(struct client_obd *cli, int target, bool force);
int osc_lru_reclaim(struct client_obd *cli);
extern spinlock_t osc_ast_guard; extern spinlock_t osc_ast_guard;
......
...@@ -308,6 +308,55 @@ static int osc_io_commit_write(const struct lu_env *env, ...@@ -308,6 +308,55 @@ static int osc_io_commit_write(const struct lu_env *env,
return 0; return 0;
} }
static int osc_io_rw_iter_init(const struct lu_env *env,
const struct cl_io_slice *ios)
{
struct cl_io *io = ios->cis_io;
struct osc_io *oio = osc_env_io(env);
struct osc_object *osc = cl2osc(ios->cis_obj);
struct client_obd *cli = osc_cli(osc);
unsigned long c;
unsigned int npages;
unsigned int max_pages;
if (cl_io_is_append(io))
return 0;
npages = io->u.ci_rw.crw_count >> PAGE_CACHE_SHIFT;
if (io->u.ci_rw.crw_pos & ~PAGE_MASK)
++npages;
max_pages = cli->cl_max_pages_per_rpc * cli->cl_max_rpcs_in_flight;
if (npages > max_pages)
npages = max_pages;
c = atomic_read(cli->cl_lru_left);
if (c < npages && osc_lru_reclaim(cli) > 0)
c = atomic_read(cli->cl_lru_left);
while (c >= npages) {
if (c == atomic_cmpxchg(cli->cl_lru_left, c, c - npages)) {
oio->oi_lru_reserved = npages;
break;
}
c = atomic_read(cli->cl_lru_left);
}
return 0;
}
static void osc_io_rw_iter_fini(const struct lu_env *env,
const struct cl_io_slice *ios)
{
struct osc_io *oio = osc_env_io(env);
struct osc_object *osc = cl2osc(ios->cis_obj);
struct client_obd *cli = osc_cli(osc);
if (oio->oi_lru_reserved > 0) {
atomic_add(oio->oi_lru_reserved, cli->cl_lru_left);
oio->oi_lru_reserved = 0;
}
}
static int osc_io_fault_start(const struct lu_env *env, static int osc_io_fault_start(const struct lu_env *env,
const struct cl_io_slice *ios) const struct cl_io_slice *ios)
{ {
...@@ -650,6 +699,8 @@ static const struct cl_io_operations osc_io_ops = { ...@@ -650,6 +699,8 @@ static const struct cl_io_operations osc_io_ops = {
.cio_fini = osc_io_fini .cio_fini = osc_io_fini
}, },
[CIT_WRITE] = { [CIT_WRITE] = {
.cio_iter_init = osc_io_rw_iter_init,
.cio_iter_fini = osc_io_rw_iter_fini,
.cio_start = osc_io_write_start, .cio_start = osc_io_write_start,
.cio_end = osc_io_end, .cio_end = osc_io_end,
.cio_fini = osc_io_fini .cio_fini = osc_io_fini
......
...@@ -2910,7 +2910,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, ...@@ -2910,7 +2910,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp,
int nr = atomic_read(&cli->cl_lru_in_list) >> 1; int nr = atomic_read(&cli->cl_lru_in_list) >> 1;
int target = *(int *)val; int target = *(int *)val;
nr = osc_lru_shrink(cli, min(nr, target)); nr = osc_lru_shrink(cli, min(nr, target), true);
*(int *)val -= nr; *(int *)val -= nr;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment