summaryrefslogtreecommitdiffstats
path: root/module/zfs/arc.c
diff options
context:
space:
mode:
authorYing Zhu <[email protected]>2013-06-29 15:03:49 +0800
committerBrian Behlendorf <[email protected]>2013-07-09 11:53:28 -0700
commitb4f7f105275d996fbcb6abd65760307d2153a89b (patch)
tree4f3c05d269ebd8f97b844207de648804175bd182 /module/zfs/arc.c
parent8e07b99b2f5e1e281af72e07dee87301c8872f56 (diff)
Improve code in arc_buf_remove_ref
When we remove references of arc bufs in the arc_anon state we needn't take its header's hash_lock, so postpone it to where we really need it to avoid unnecessary invocations of function buf_hash. Signed-off-by: Ying Zhu <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #1557
Diffstat (limited to 'module/zfs/arc.c')
-rw-r--r--module/zfs/arc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/module/zfs/arc.c b/module/zfs/arc.c
index de869666b..df3aeb734 100644
--- a/module/zfs/arc.c
+++ b/module/zfs/arc.c
@@ -1642,7 +1642,7 @@ int
arc_buf_remove_ref(arc_buf_t *buf, void* tag)
{
arc_buf_hdr_t *hdr = buf->b_hdr;
- kmutex_t *hash_lock = HDR_LOCK(hdr);
+ kmutex_t *hash_lock = NULL;
int no_callback = (buf->b_efunc == NULL);
if (hdr->b_state == arc_anon) {
@@ -1651,6 +1651,7 @@ arc_buf_remove_ref(arc_buf_t *buf, void* tag)
return (no_callback);
}
+ hash_lock = HDR_LOCK(hdr);
mutex_enter(hash_lock);
hdr = buf->b_hdr;
ASSERT3P(hash_lock, ==, HDR_LOCK(hdr));