block: fix stacked driver stats init and free

If a driver allocates a queue for stacked usage, then it does
not currently get stats allocated. This causes the later init
of, eg, writeback throttling to blow up. Move the init to the
queue allocation instead.

Additionally, allow a NULL callback unregistration. This avoids
having the caller check for that, fixing another oops on
removal of a block device that doesn't have poll stats allocated.

Fixes: 34dbad5d26 ("blk-stat: convert to callback-based statistics reporting")
Signed-off-by: Jens Axboe <axboe@fb.com>
This commit is contained in:
Jens Axboe
2017-03-21 17:20:01 -06:00
parent 34dbad5d26
commit a83b576c9c
2 changed files with 8 additions and 5 deletions

View File

@@ -210,7 +210,8 @@ static void blk_stat_free_callback_rcu(struct rcu_head *head)
void blk_stat_free_callback(struct blk_stat_callback *cb)
{
call_rcu(&cb->rcu, blk_stat_free_callback_rcu);
if (cb)
call_rcu(&cb->rcu, blk_stat_free_callback_rcu);
}
EXPORT_SYMBOL_GPL(blk_stat_free_callback);