]> git.proxmox.com Git - mirror_spl.git/commit - module/spl/spl-kmem.c
Fix race in spl_kmem_cache_reap_now()
authorRichard Yao <ryao@gentoo.org>
Sun, 4 Aug 2013 23:35:08 +0000 (19:35 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 8 Aug 2013 16:14:41 +0000 (09:14 -0700)
commit251e7a779ba5d4b5e46c42d8b792c481380da28b
tree9ba48df6ae559684fe303827da60fb6c091a3343
parentba062980728bbd09c4b829f5d801a773af7381cf
Fix race in spl_kmem_cache_reap_now()

The current code contains a race condition that triggers when bit 2 in
spl.spl_kmem_cache_expire is set, spl_kmem_cache_reap_now() is invoked
and another thread is concurrently accessing its magazine.

spl_kmem_cache_reap_now() currently invokes spl_cache_flush() on each
magazine in the same thread when bit 2 in spl.spl_kmem_cache_expire is
set. This is unsafe because there is one magazine per CPU and the
magazines are lockless, so it is impossible to guarentee that another
CPU is not using its magazine when this function is called.

The solution is to only touch the local CPU's magazine and leave other
CPU's magazines to other CPUs.

Reported-by: DHE
Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #274
module/spl/spl-kmem.c