OSDN Git Service

block: Unhash block device inodes on gendisk destruction
authorJan Kara <jack@suse.cz>
Thu, 2 Feb 2017 14:56:49 +0000 (15:56 +0100)
committerRitesh Harjani <riteshh@codeaurora.org>
Wed, 18 Oct 2017 06:35:43 +0000 (12:05 +0530)
commit393737a28b63836b3f12613b1c031e6f32cc3476
tree74a6132fb9db0006d846d926931afa7fb83ffb9c
parentfa53f7f14b3c5f02ab920fc7fa0a906a5493a9ab
block: Unhash block device inodes on gendisk destruction

Currently, block device inodes stay around after corresponding gendisk
hash died until memory reclaim finds them and frees them. Since we will
make block device inode pin the bdi, we want to free the block device
inode as soon as the device goes away so that bdi does not stay around
unnecessarily. Furthermore we need to avoid issues when new device with
the same major,minor pair gets created since reusing the bdi structure
would be rather difficult in this case.

Unhashing block device inode on gendisk destruction nicely deals with
these problems. Once last block device inode reference is dropped (which
may be directly in del_gendisk()), the inode gets evicted. Furthermore if
the major,minor pair gets reallocated, we are guaranteed to get new
block device inode even if old block device inode is not yet evicted and
thus we avoid issues with possible reuse of bdi.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
Change-Id: I41087d3bc818c4e58e0b4e20876e136ec1cbb07b
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git
Git-commit: f44f1ab5a2dcd4e16eab850fd08e40ff2d0c28d4
[riteshh@codeaurora.org: resolved merge conflicts]
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
block/genhd.c
fs/block_dev.c
include/linux/fs.h