From: jxiong Date: Fri, 18 Sep 2009 05:00:23 +0000 (+0000) Subject: b=19537 X-Git-Tag: v1_9_270~31 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=c7f0a3e01d2691a3208b586c0de1f1afbf79b82e b=19537 r=rread Use atomic_dec_and_lock() so that if it is NOT the last refcount, it doesn't need to take the lock. --- diff --git a/lustre/obdclass/cl_page.c b/lustre/obdclass/cl_page.c index 0e09051..55887f9 100644 --- a/lustre/obdclass/cl_page.c +++ b/lustre/obdclass/cl_page.c @@ -630,8 +630,7 @@ void cl_page_put(const struct lu_env *env, struct cl_page *page) 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 @@ -656,8 +655,8 @@ void cl_page_put(const struct lu_env *env, struct cl_page *page) EXIT; return; } + spin_unlock(&hdr->coh_page_guard); } - spin_unlock(&hdr->coh_page_guard); EXIT; }