From c8c7598536daa2fb943b66681240436391217078 Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Mon, 14 Mar 2016 10:53:39 +0800 Subject: [PATCH] LU-9229 osc: osc page lru list race In osc_lru_use() the osc page's ops_lru access is not protected, which could race with osc_lru_del() and ensuing that client_obd::cl_lru_in_list counter decreased twice for a single page. Signed-off-by: Bobi Jam Change-Id: I41179112693f77113fdf43d3f859bf778d7bbc44 Reviewed-on: https://review.whamcloud.com/26086 Tested-by: Jenkins Reviewed-by: Jinshan Xiong Tested-by: Maloo Reviewed-by: Li Xi Reviewed-by: Oleg Drokin --- lustre/osc/osc_page.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lustre/osc/osc_page.c b/lustre/osc/osc_page.c index c1650b8..50d8ecd 100644 --- a/lustre/osc/osc_page.c +++ b/lustre/osc/osc_page.c @@ -482,17 +482,19 @@ static void osc_lru_del(struct client_obd *cli, struct osc_page *opg) } /** - * Delete page from LRUlist for redirty. + * Delete page from LRU list for redirty. */ static void osc_lru_use(struct client_obd *cli, struct osc_page *opg) { /* If page is being transferred for the first time, * ops_lru should be empty */ - if (opg->ops_in_lru && !list_empty(&opg->ops_lru)) { + if (opg->ops_in_lru) { spin_lock(&cli->cl_lru_list_lock); - __osc_lru_del(cli, opg); + if (!list_empty(&opg->ops_lru)) { + __osc_lru_del(cli, opg); + atomic_long_inc(&cli->cl_lru_busy); + } spin_unlock(&cli->cl_lru_list_lock); - atomic_long_inc(&cli->cl_lru_busy); } } -- 1.8.3.1