aboutsummaryrefslogtreecommitdiffstats
path: root/mm/backing-dev.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2017-04-12 06:24:26 -0400
committerJens Axboe <axboe@fb.com>2017-04-20 14:09:55 -0400
commit5af110b2fb59eda9ba22ff1057f36bd96e340e09 (patch)
tree0a0c299a51e01403609339e72f65c7f948047ea2 /mm/backing-dev.c
parentbaf7a616d537f577d33b7d9986f40532e2bd9f66 (diff)
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 <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'mm/backing-dev.c')
-rw-r--r--mm/backing-dev.c2
1 files changed, 2 insertions, 0 deletions
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)
961 struct backing_dev_info *bdi = 961 struct backing_dev_info *bdi =
962 container_of(ref, struct backing_dev_info, refcnt); 962 container_of(ref, struct backing_dev_info, refcnt);
963 963
964 if (test_bit(WB_registered, &bdi->wb.state))
965 bdi_unregister(bdi);
964 bdi_exit(bdi); 966 bdi_exit(bdi);
965 kfree(bdi); 967 kfree(bdi);
966} 968}