From b4f7f105275d996fbcb6abd65760307d2153a89b Mon Sep 17 00:00:00 2001 From: Ying Zhu Date: Sat, 29 Jun 2013 15:03:49 +0800 Subject: [PATCH] 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 Signed-off-by: Brian Behlendorf Closes #1557 --- module/zfs/arc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/zfs/arc.c b/module/zfs/arc.c index de86966..df3aeb7 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)); -- 1.8.3.1