diff options
author | Christoph Hellwig <hch@lst.de> | 2020-08-23 12:10:42 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-09-02 01:49:25 +0300 |
commit | c2b4bb8cb3741c0bacf3683e4c1ecd04c977ada3 (patch) | |
tree | 1c036d3d5215adea62f0ba3534ac3c8ce5836fe4 /include | |
parent | 611bee526b4a89d49f1b9914a770bfdc101d5fb5 (diff) | |
download | linux-c2b4bb8cb3741c0bacf3683e4c1ecd04c977ada3.tar.xz |
block: fix locking for struct block_device size updates
Two different callers use two different mutexes for updating the
block device size, which obviously doesn't help to actually protect
against concurrent updates from the different callers. In addition
one of the locks, bd_mutex is rather prone to deadlocks with other
parts of the block stack that use it for high level synchronization.
Switch to using a new spinlock protecting just the size updates, as
that is all we need, and make sure everyone does the update through
the proper helper.
This fixes a bug reported with the nvme revalidating disks during a
hot removal operation, which can currently deadlock on bd_mutex.
Reported-by: Xianting Tian <xianting_tian@126.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/blk_types.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 4ecf4fed171f..5accc2549d22 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -38,6 +38,7 @@ struct block_device { /* number of times partitions within this device have been opened. */ unsigned bd_part_count; int bd_invalidated; + spinlock_t bd_size_lock; /* for bd_inode->i_size updates */ struct gendisk * bd_disk; struct backing_dev_info *bd_bdi; |