[PATCH] deal with rmmod/put_io_context() races
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index caa8fcf..6dc7691 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -3477,10 +3477,12 @@
BUG_ON(atomic_read(&ioc->refcount) == 0);
if (atomic_dec_and_test(&ioc->refcount)) {
+ rcu_read_lock();
if (ioc->aic && ioc->aic->dtor)
ioc->aic->dtor(ioc->aic);
if (ioc->cic && ioc->cic->dtor)
ioc->cic->dtor(ioc->cic);
+ rcu_read_unlock();
kmem_cache_free(iocontext_cachep, ioc);
}