From: Jan Kara Date: Wed, 12 Apr 2017 10:24:26 +0000 (+0200) Subject: block: Unregister bdi on last reference drop X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5af110b2fb59eda9ba22ff1057f36bd96e340e09;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git block: Unregister bdi on last reference drop Most users will want to unregister bdi when dropping last reference to a bdi. Only a few users (like block devices) want to play more complex tricks with bdi registration and unregistration. So unregister bdi when the last reference to bdi is dropped and just make sure we don't unregister the bdi the second time if it is already unregistered. Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara Signed-off-by: Jens Axboe --- diff --git a/mm/backing-dev.c b/mm/backing-dev.c index e5e0972bdd6f..164ccc93690f 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -961,6 +961,8 @@ static void release_bdi(struct kref *ref) struct backing_dev_info *bdi = container_of(ref, struct backing_dev_info, refcnt); + if (test_bit(WB_registered, &bdi->wb.state)) + bdi_unregister(bdi); bdi_exit(bdi); kfree(bdi); }