nvme: introduce max_integrity_segments ctrl attribute
authorMax Gurtovoy <maxg@mellanox.com>
Tue, 19 May 2020 14:05:52 +0000 (17:05 +0300)
committerChristoph Hellwig <hch@lst.de>
Wed, 27 May 2020 05:12:39 +0000 (07:12 +0200)
This patch doesn't change any logic, and is needed as a preparation
for adding PI support for fabrics drivers that will use an extended
LBA format for metadata and will support more than 1 integrity segment.

Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
Signed-off-by: Israel Rukshin <israelr@mellanox.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/core.c
drivers/nvme/host/nvme.h
drivers/nvme/host/pci.c

index beea013..404edce 100644 (file)
@@ -1693,7 +1693,8 @@ static int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo)
 }
 
 #ifdef CONFIG_BLK_DEV_INTEGRITY
-static void nvme_init_integrity(struct gendisk *disk, u16 ms, u8 pi_type)
+static void nvme_init_integrity(struct gendisk *disk, u16 ms, u8 pi_type,
+                               u32 max_integrity_segments)
 {
        struct blk_integrity integrity;
 
@@ -1716,10 +1717,11 @@ static void nvme_init_integrity(struct gendisk *disk, u16 ms, u8 pi_type)
        }
        integrity.tuple_size = ms;
        blk_integrity_register(disk, &integrity);
-       blk_queue_max_integrity_segments(disk->queue, 1);
+       blk_queue_max_integrity_segments(disk->queue, max_integrity_segments);
 }
 #else
-static void nvme_init_integrity(struct gendisk *disk, u16 ms, u8 pi_type)
+static void nvme_init_integrity(struct gendisk *disk, u16 ms, u8 pi_type,
+                               u32 max_integrity_segments)
 {
 }
 #endif /* CONFIG_BLK_DEV_INTEGRITY */
@@ -1895,7 +1897,8 @@ static void nvme_update_disk_info(struct gendisk *disk,
        if (ns->ms) {
                if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) &&
                    (ns->features & NVME_NS_METADATA_SUPPORTED))
-                       nvme_init_integrity(disk, ns->ms, ns->pi_type);
+                       nvme_init_integrity(disk, ns->ms, ns->pi_type,
+                                           ns->ctrl->max_integrity_segments);
                else if (!nvme_ns_has_pi(ns))
                        capacity = 0;
        }
index c83ff69..5b5ed12 100644 (file)
@@ -229,6 +229,7 @@ struct nvme_ctrl {
        u32 page_size;
        u32 max_hw_sectors;
        u32 max_segments;
+       u32 max_integrity_segments;
        u16 crdt[3];
        u16 oncs;
        u16 oacs;
index 6cc4630..b307c06 100644 (file)
@@ -2565,6 +2565,12 @@ static void nvme_reset_work(struct work_struct *work)
                goto out;
        }
 
+       /*
+        * We do not support an SGL for metadata (yet), so we are limited to a
+        * single integrity segment for the separate metadata pointer.
+        */
+       dev->ctrl.max_integrity_segments = 1;
+
        result = nvme_init_identify(&dev->ctrl);
        if (result)
                goto out;