Merge branch 'for-3.5' of ../cgroup into block/for-3.5/core-merged
[linux-drm-fsl-dcu.git] / block / blk-ioc.c
index 3f3dd51a1280a66c30f75c9acd118ff6d433de27..1e2d53b04858fc2d107aa8c5ead7478d53575fba 100644 (file)
@@ -130,6 +130,7 @@ static void ioc_release_fn(struct work_struct *work)
 void put_io_context(struct io_context *ioc)
 {
        unsigned long flags;
+       bool free_ioc = false;
 
        if (ioc == NULL)
                return;
@@ -144,8 +145,13 @@ void put_io_context(struct io_context *ioc)
                spin_lock_irqsave(&ioc->lock, flags);
                if (!hlist_empty(&ioc->icq_list))
                        schedule_work(&ioc->release_work);
+               else
+                       free_ioc = true;
                spin_unlock_irqrestore(&ioc->lock, flags);
        }
+
+       if (free_ioc)
+               kmem_cache_free(iocontext_cachep, ioc);
 }
 EXPORT_SYMBOL(put_io_context);