Skip to content

Commit 7bee607

Browse files
Keith Buschaxboe
authored andcommitted
NVMe: Reread partitions on metadata formats
This patch has the driver automatically reread partitions if a namespace has a separate metadata format. Previously revalidating a disk was sufficient to get the correct capacity set on such formatted drives, but partitions that may exist would not have been surfaced. Reported-by: Paul Grabinar <paul.grabinar@ranbarg.com> Signed-off-by: Keith Busch <keith.busch@intel.com> Cc: Matthew Wilcox <willy@linux.intel.com> Tested-by: Paul Grabinar <paul.grabinar@ranbarg.com> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent 77b5a08 commit 7bee607

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/block/nvme-core.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,8 +2108,17 @@ static void nvme_alloc_ns(struct nvme_dev *dev, unsigned nsid)
21082108
goto out_free_disk;
21092109

21102110
add_disk(ns->disk);
2111-
if (ns->ms)
2112-
revalidate_disk(ns->disk);
2111+
if (ns->ms) {
2112+
struct block_device *bd = bdget_disk(ns->disk, 0);
2113+
if (!bd)
2114+
return;
2115+
if (blkdev_get(bd, FMODE_READ, NULL)) {
2116+
bdput(bd);
2117+
return;
2118+
}
2119+
blkdev_reread_part(bd);
2120+
blkdev_put(bd, FMODE_READ);
2121+
}
21132122
return;
21142123
out_free_disk:
21152124
kfree(disk);

0 commit comments

Comments
 (0)