[lustre-devel] [PATCH 20/30] lustre: osc: osc page lru list race
James Simmons
jsimmons at infradead.org
Mon Sep 17 10:30:30 PDT 2018
From: Bobi Jam <bobijam at hotmail.com>
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 <bobijam at hotmail.com>
WC-bug-id: https://jira.whamcloud.com/browse/LU-9229
Reviewed-on: https://review.whamcloud.com/26086
Reviewed-by: Jinshan Xiong <jinshan.xiong at gmail.com>
Reviewed-by: Li Xi <lixi at ddn.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
drivers/staging/lustre/lustre/osc/osc_page.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
index 20c553e..189e3e78 100644
--- a/drivers/staging/lustre/lustre/osc/osc_page.c
+++ b/drivers/staging/lustre/lustre/osc/osc_page.c
@@ -478,18 +478,20 @@ 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
More information about the lustre-devel
mailing list