summaryrefslogtreecommitdiffstats
path: root/block/partitions
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-08-23 11:10:42 +0200
committerJens Axboe <axboe@kernel.dk>2020-09-01 16:49:25 -0600
commitc2b4bb8cb3741c0bacf3683e4c1ecd04c977ada3 (patch)
tree1c036d3d5215adea62f0ba3534ac3c8ce5836fe4 /block/partitions
parent611bee526b4a89d49f1b9914a770bfdc101d5fb5 (diff)
downloadlinux-c2b4bb8cb3741c0bacf3683e4c1ecd04c977ada3.tar.gz
linux-c2b4bb8cb3741c0bacf3683e4c1ecd04c977ada3.tar.bz2
linux-c2b4bb8cb3741c0bacf3683e4c1ecd04c977ada3.zip
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 'block/partitions')
-rw-r--r--block/partitions/core.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 5b4869c08fb3..b1c0b50ca92d 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -592,8 +592,8 @@ int bdev_resize_partition(struct block_device *bdev, int partno,
if (partition_overlaps(bdev->bd_disk, start, length, partno))
goto out_unlock;
- part_nr_sects_write(part, (sector_t)length);
- i_size_write(bdevp->bd_inode, length << SECTOR_SHIFT);
+ part_nr_sects_write(part, length);
+ bd_set_nr_sectors(bdevp, length);
ret = 0;
out_unlock: