From ed91ee6bd642e031dab781ab4ebf6524476beddd Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Wed, 15 Nov 2017 15:02:30 +0800 Subject: [PATCH] LU-10244 osc: add a bit to indicate osc_page in cache tree Add osc_page::ops_intree to indicate whether the osc_page is in the osc_object's cache tree, so that when page cannot insert in the cache as race happens, the cleanup code won't try to remove it from the cache. Signed-off-by: Bobi Jam Change-Id: Ifcfe158d10c23a40c116414c7f4f86b257e1fa76 Reviewed-on: https://review.whamcloud.com/30096 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Jinshan Xiong Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- lustre/include/lustre_osc.h | 6 +++++- lustre/osc/osc_page.c | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lustre/include/lustre_osc.h b/lustre/include/lustre_osc.h index 21f1764..ebc0168 100644 --- a/lustre/include/lustre_osc.h +++ b/lustre/include/lustre_osc.h @@ -533,7 +533,11 @@ struct osc_page { /** * Set if the page must be transferred with OBD_BRW_SRVLOCK. */ - ops_srvlock:1; + ops_srvlock:1, + /** + * If the page is in osc_object::oo_tree. + */ + ops_intree:1; /** * lru page list. See osc_lru_{del|use}() in osc_page.c for usage. */ diff --git a/lustre/osc/osc_page.c b/lustre/osc/osc_page.c index 8bc7fca..709e9dd 100644 --- a/lustre/osc/osc_page.c +++ b/lustre/osc/osc_page.c @@ -196,12 +196,17 @@ static void osc_page_delete(const struct lu_env *env, osc_lru_del(osc_cli(obj), opg); if (slice->cpl_page->cp_type == CPT_CACHEABLE) { - void *value; + void *value = NULL; spin_lock(&obj->oo_tree_lock); - value = radix_tree_delete(&obj->oo_tree, osc_index(opg)); - if (value != NULL) - --obj->oo_npages; + if (opg->ops_intree) { + value = radix_tree_delete(&obj->oo_tree, + osc_index(opg)); + if (value != NULL) { + --obj->oo_npages; + opg->ops_intree = 0; + } + } spin_unlock(&obj->oo_tree_lock); LASSERT(ergo(value != NULL, value == opg)); @@ -300,8 +305,10 @@ int osc_page_init(const struct lu_env *env, struct cl_object *obj, spin_lock(&osc->oo_tree_lock); result = radix_tree_insert(&osc->oo_tree, index, opg); - if (result == 0) + if (result == 0) { ++osc->oo_npages; + opg->ops_intree = 1; + } spin_unlock(&osc->oo_tree_lock); radix_tree_preload_end(); -- 1.8.3.1