Skip to content

Commit

Permalink
block: Unregister bdi on last reference drop
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
jankara authored and axboe committed Apr 20, 2017
1 parent baf7a61 commit 5af110b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mm/backing-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5af110b

Please sign in to comment.