The ls_device_put() might be called from local_oid_storage_fini()
wrongly if mutex-protected check failed due to race
This patch is back-ported from the following one:
Lustre-commit:
458804418f3c24706db7ad9a46f791e59f008a7d
Lustre-change: http://review.whamcloud.com/6334
Signed-off-by: Mikhail Pershin <mike.pershin@intel.com>
Change-Id: I386597e431ded0dd2b63b078200571a00bc5fe96
Signed-off-by: Jian Yu <jian.yu@intel.com>
Reviewed-on: http://review.whamcloud.com/8461
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
ls = dt2ls_dev(los->los_dev);
mutex_lock(&ls->ls_los_mutex);
ls = dt2ls_dev(los->los_dev);
mutex_lock(&ls->ls_los_mutex);
- if (cfs_atomic_read(&los->los_refcount) == 0) {
- if (los->los_obj)
- lu_object_put_nocache(env, &los->los_obj->do_lu);
- cfs_list_del(&los->los_list);
- OBD_FREE_PTR(los);
+ if (cfs_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);
+ cfs_list_del(&los->los_list);
+ OBD_FREE_PTR(los);
mutex_unlock(&ls->ls_los_mutex);
ls_device_put(env, ls);
}
mutex_unlock(&ls->ls_los_mutex);
ls_device_put(env, ls);
}