mirror of https://gitee.com/openkylin/linux.git
nvmet: add metadata characteristics for a namespace
Fill those namespace fields from the block device format for adding metadata (T10-PI) over fabric support with block devices. Signed-off-by: Israel Rukshin <israelr@mellanox.com> Signed-off-by: Max Gurtovoy <maxg@mellanox.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
5ec5d3bddc
commit
d2d1c454a4
|
@ -4,6 +4,7 @@ config NVME_TARGET
|
|||
tristate "NVMe Target support"
|
||||
depends on BLOCK
|
||||
depends on CONFIGFS_FS
|
||||
select BLK_DEV_INTEGRITY_T10 if BLK_DEV_INTEGRITY
|
||||
select SGL_ALLOC
|
||||
help
|
||||
This enabled target side support for the NVMe protocol, that is
|
||||
|
|
|
@ -47,6 +47,22 @@ void nvmet_bdev_set_limits(struct block_device *bdev, struct nvme_id_ns *id)
|
|||
id->nows = to0based(ql->io_opt / ql->logical_block_size);
|
||||
}
|
||||
|
||||
static void nvmet_bdev_ns_enable_integrity(struct nvmet_ns *ns)
|
||||
{
|
||||
struct blk_integrity *bi = bdev_get_integrity(ns->bdev);
|
||||
|
||||
if (bi) {
|
||||
ns->metadata_size = bi->tuple_size;
|
||||
if (bi->profile == &t10_pi_type1_crc)
|
||||
ns->pi_type = NVME_NS_DPS_PI_TYPE1;
|
||||
else if (bi->profile == &t10_pi_type3_crc)
|
||||
ns->pi_type = NVME_NS_DPS_PI_TYPE3;
|
||||
else
|
||||
/* Unsupported metadata type */
|
||||
ns->metadata_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int nvmet_bdev_ns_enable(struct nvmet_ns *ns)
|
||||
{
|
||||
int ret;
|
||||
|
@ -64,6 +80,12 @@ int nvmet_bdev_ns_enable(struct nvmet_ns *ns)
|
|||
}
|
||||
ns->size = i_size_read(ns->bdev->bd_inode);
|
||||
ns->blksize_shift = blksize_bits(bdev_logical_block_size(ns->bdev));
|
||||
|
||||
ns->pi_type = 0;
|
||||
ns->metadata_size = 0;
|
||||
if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY_T10))
|
||||
nvmet_bdev_ns_enable_integrity(ns);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <linux/rcupdate.h>
|
||||
#include <linux/blkdev.h>
|
||||
#include <linux/radix-tree.h>
|
||||
#include <linux/t10-pi.h>
|
||||
|
||||
#define NVMET_ASYNC_EVENTS 4
|
||||
#define NVMET_ERROR_LOG_SLOTS 128
|
||||
|
@ -77,6 +78,8 @@ struct nvmet_ns {
|
|||
|
||||
int use_p2pmem;
|
||||
struct pci_dev *p2p_dev;
|
||||
int pi_type;
|
||||
int metadata_size;
|
||||
};
|
||||
|
||||
static inline struct nvmet_ns *to_nvmet_ns(struct config_item *item)
|
||||
|
|
Loading…
Reference in New Issue