- if (cfs_atomic_dec_and_lock(&page->cp_ref, &page->cp_lock)) {
- cfs_atomic_dec(&site->cs_pages.cs_busy);
- /* We're going to access the page w/o a reference, but it's
- * ok because we have grabbed the lock cp_lock, which
- * means nobody is able to free this page behind us.
- */
- if (page->cp_state == CPS_FREEING) {
- /* We drop the page reference and check the page state
- * inside the cp_lock. So that if it gets here,
- * it is the REALLY last reference to this page.
- */
- spin_unlock(&page->cp_lock);
-
- LASSERT(cfs_atomic_read(&page->cp_ref) == 0);
- PASSERT(env, page, page->cp_owner == NULL);
- PASSERT(env, page, cfs_list_empty(&page->cp_batch));
- /*
- * Page is no longer reachable by other threads. Tear
- * it down.
- */
- cl_page_free(env, page);
-
- EXIT;
- return;
- }
- spin_unlock(&page->cp_lock);
+ if (cfs_atomic_dec_and_test(&page->cp_ref)) {
+ LASSERT(page->cp_state == CPS_FREEING);
+
+ LASSERT(cfs_atomic_read(&page->cp_ref) == 0);
+ PASSERT(env, page, page->cp_owner == NULL);
+ PASSERT(env, page, cfs_list_empty(&page->cp_batch));
+ /*
+ * Page is no longer reachable by other threads. Tear
+ * it down.
+ */
+ cl_page_free(env, page);