Whamcloud - gitweb
LU-9229 osc: osc page lru list race 86/26086/4
authorBobi Jam <bobijam.xu@intel.com>
Mon, 14 Mar 2016 02:53:39 +0000 (10:53 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 3 Jun 2017 03:57:02 +0000 (03:57 +0000)
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.xu@intel.com>
Change-Id: I41179112693f77113fdf43d3f859bf778d7bbc44
Reviewed-on: https://review.whamcloud.com/26086
Tested-by: Jenkins
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Li Xi <lixi@ddn.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osc/osc_page.c

index c1650b8..50d8ecd 100644 (file)
@@ -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 */
  */
 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);
                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);
                spin_unlock(&cli->cl_lru_list_lock);
-               atomic_long_inc(&cli->cl_lru_busy);
        }
 }
 
        }
 }