r=rread
Use atomic_dec_and_lock() so that if it is NOT the last refcount, it doesn't need to take the lock.
CL_PAGE_HEADER(D_TRACE, env, page, "%i\n", atomic_read(&page->cp_ref));
hdr = cl_object_header(cl_object_top(page->cp_obj));
CL_PAGE_HEADER(D_TRACE, env, page, "%i\n", atomic_read(&page->cp_ref));
hdr = cl_object_header(cl_object_top(page->cp_obj));
- spin_lock(&hdr->coh_page_guard);
- if (atomic_dec_and_test(&page->cp_ref)) {
+ if (atomic_dec_and_lock(&page->cp_ref, &hdr->coh_page_guard)) {
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 coh_page_guard, which
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 coh_page_guard, which
+ spin_unlock(&hdr->coh_page_guard);
- spin_unlock(&hdr->coh_page_guard);