Skip to content

Commit 05b2902

Browse files
Anthony IliopoulosChristoph Hellwig
authored andcommitted
nvme: explicitly update mpath disk capacity on revalidation
Commit 3b4b197 ("nvme: fix possible deadlock when I/O is blocked") reverted multipath head disk revalidation due to deadlocks caused by holding the bd_mutex during revalidate. Updating the multipath disk blockdev size is still required though for userspace to be able to observe any resizing while the device is mounted. Directly update the bdev inode size to avoid unnecessarily holding the bdev->bd_mutex. Fixes: 3b4b197 ("nvme: fix possible deadlock when I/O is blocked") Signed-off-by: Anthony Iliopoulos <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 579dd91 commit 05b2902

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

drivers/nvme/host/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,6 +1980,7 @@ static int __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
19801980
if (ns->head->disk) {
19811981
nvme_update_disk_info(ns->head->disk, ns, id);
19821982
blk_queue_stack_limits(ns->head->disk->queue, ns->queue);
1983+
nvme_mpath_update_disk_size(ns->head->disk);
19831984
}
19841985
#endif
19851986
return 0;

drivers/nvme/host/nvme.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,16 @@ static inline void nvme_trace_bio_complete(struct request *req,
604604
trace_block_bio_complete(ns->head->disk->queue, req->bio);
605605
}
606606

607+
static inline void nvme_mpath_update_disk_size(struct gendisk *disk)
608+
{
609+
struct block_device *bdev = bdget_disk(disk, 0);
610+
611+
if (bdev) {
612+
bd_set_size(bdev, get_capacity(disk) << SECTOR_SHIFT);
613+
bdput(bdev);
614+
}
615+
}
616+
607617
extern struct device_attribute dev_attr_ana_grpid;
608618
extern struct device_attribute dev_attr_ana_state;
609619
extern struct device_attribute subsys_attr_iopolicy;
@@ -679,6 +689,9 @@ static inline void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys)
679689
static inline void nvme_mpath_start_freeze(struct nvme_subsystem *subsys)
680690
{
681691
}
692+
static inline void nvme_mpath_update_disk_size(struct gendisk *disk)
693+
{
694+
}
682695
#endif /* CONFIG_NVME_MULTIPATH */
683696

684697
#ifdef CONFIG_NVM

0 commit comments

Comments
 (0)