From: Mikhail Pershin <[email protected]>

The ls_device_put() might be called from local_oid_storage_fini()
wrongly if mutex-protected check failed due to race

Lustre-change: http://review.whamcloud.com/6334
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3316
Signed-off-by: Mikhail Pershin <[email protected]>
Reviewed-by: Fan Yong <[email protected]>
Reviewed-by: Alex Zhuravlev <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: Peng Tao <[email protected]>
Signed-off-by: Andreas Dilger <[email protected]>
---
 .../staging/lustre/lustre/obdclass/local_storage.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/local_storage.c 
b/drivers/staging/lustre/lustre/obdclass/local_storage.c
index 295bb7c..367d3fd 100644
--- a/drivers/staging/lustre/lustre/obdclass/local_storage.c
+++ b/drivers/staging/lustre/lustre/obdclass/local_storage.c
@@ -882,12 +882,15 @@ void local_oid_storage_fini(const struct lu_env *env,
        ls = dt2ls_dev(los->los_dev);
 
        mutex_lock(&ls->ls_los_mutex);
-       if (atomic_read(&los->los_refcount) == 0) {
-               if (los->los_obj)
-                       lu_object_put_nocache(env, &los->los_obj->do_lu);
-               list_del(&los->los_list);
-               OBD_FREE_PTR(los);
+       if (atomic_read(&los->los_refcount) > 0) {
+               mutex_unlock(&ls->ls_los_mutex);
+               return;
        }
+
+       if (los->los_obj)
+               lu_object_put_nocache(env, &los->los_obj->do_lu);
+       list_del(&los->los_list);
+       OBD_FREE_PTR(los);
        mutex_unlock(&ls->ls_los_mutex);
        ls_device_put(env, ls);
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to