nvme: explicitly update mpath disk capacity on revalidation
authorAnthony Iliopoulos <ailiop@suse.com>
Tue, 14 Jul 2020 11:11:59 +0000 (13:11 +0200)
committerChristoph Hellwig <hch@lst.de>
Thu, 16 Jul 2020 14:40:27 +0000 (16:40 +0200)
Commit 3b4b19721ec652 ("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: 3b4b19721ec652 ("nvme: fix possible deadlock when I/O is
blocked")

Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/core.c
drivers/nvme/host/nvme.h

index 8410d03b940d7454e32df216e3e27f904c9c28e1..add040168e67e20aa241c87f9c1a013c8dea895a 100644 (file)
@@ -1980,6 +1980,7 @@ static int __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
        if (ns->head->disk) {
                nvme_update_disk_info(ns->head->disk, ns, id);
                blk_queue_stack_limits(ns->head->disk->queue, ns->queue);
+               nvme_mpath_update_disk_size(ns->head->disk);
        }
 #endif
        return 0;
index 2ef8d501e2a87c3c94e5965a61df34aae22fee0b..1de3f9b827aa568e77b5ae8ef1a34fd66bdfb54c 100644 (file)
@@ -604,6 +604,16 @@ static inline void nvme_trace_bio_complete(struct request *req,
                trace_block_bio_complete(ns->head->disk->queue, req->bio);
 }
 
+static inline void nvme_mpath_update_disk_size(struct gendisk *disk)
+{
+       struct block_device *bdev = bdget_disk(disk, 0);
+
+       if (bdev) {
+               bd_set_size(bdev, get_capacity(disk) << SECTOR_SHIFT);
+               bdput(bdev);
+       }
+}
+
 extern struct device_attribute dev_attr_ana_grpid;
 extern struct device_attribute dev_attr_ana_state;
 extern struct device_attribute subsys_attr_iopolicy;
@@ -679,6 +689,9 @@ static inline void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys)
 static inline void nvme_mpath_start_freeze(struct nvme_subsystem *subsys)
 {
 }
+static inline void nvme_mpath_update_disk_size(struct gendisk *disk)
+{
+}
 #endif /* CONFIG_NVME_MULTIPATH */
 
 #ifdef CONFIG_NVM