mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
nvmet: add metadata/T10-PI support
Expose the namespace metadata format when PI is enabled. The user needs to enable the capability per subsystem and per port. The other metadata properties are taken from the namespace/bdev. Usage example: echo 1 > /config/nvmet/subsystems/${NAME}/attr_pi_enable echo 1 > /config/nvmet/ports/${PORT_NUM}/param_pi_enable Signed-off-by: Israel Rukshin <israelr@mellanox.com> Signed-off-by: Max Gurtovoy <maxg@mellanox.com> Reviewed-by: James Smart <james.smart@broadcom.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
39481fbd14
commit
ea52ac1c66
5 changed files with 121 additions and 10 deletions
|
@ -341,6 +341,7 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
|
|||
{
|
||||
struct nvmet_ctrl *ctrl = req->sq->ctrl;
|
||||
struct nvme_id_ctrl *id;
|
||||
u32 cmd_capsule_size;
|
||||
u16 status = 0;
|
||||
|
||||
id = kzalloc(sizeof(*id), GFP_KERNEL);
|
||||
|
@ -433,9 +434,15 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
|
|||
|
||||
strlcpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn));
|
||||
|
||||
/* Max command capsule size is sqe + single page of in-capsule data */
|
||||
id->ioccsz = cpu_to_le32((sizeof(struct nvme_command) +
|
||||
req->port->inline_data_size) / 16);
|
||||
/*
|
||||
* Max command capsule size is sqe + in-capsule data size.
|
||||
* Disable in-capsule data for Metadata capable controllers.
|
||||
*/
|
||||
cmd_capsule_size = sizeof(struct nvme_command);
|
||||
if (!ctrl->pi_support)
|
||||
cmd_capsule_size += req->port->inline_data_size;
|
||||
id->ioccsz = cpu_to_le32(cmd_capsule_size / 16);
|
||||
|
||||
/* Max response capsule size is cqe */
|
||||
id->iorcsz = cpu_to_le32(sizeof(struct nvme_completion) / 16);
|
||||
|
||||
|
@ -465,6 +472,7 @@ out:
|
|||
|
||||
static void nvmet_execute_identify_ns(struct nvmet_req *req)
|
||||
{
|
||||
struct nvmet_ctrl *ctrl = req->sq->ctrl;
|
||||
struct nvmet_ns *ns;
|
||||
struct nvme_id_ns *id;
|
||||
u16 status = 0;
|
||||
|
@ -482,7 +490,7 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
|
|||
}
|
||||
|
||||
/* return an all zeroed buffer if we can't find an active namespace */
|
||||
ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->identify.nsid);
|
||||
ns = nvmet_find_namespace(ctrl, req->cmd->identify.nsid);
|
||||
if (!ns)
|
||||
goto done;
|
||||
|
||||
|
@ -523,6 +531,16 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
|
|||
|
||||
id->lbaf[0].ds = ns->blksize_shift;
|
||||
|
||||
if (ctrl->pi_support && nvmet_ns_has_pi(ns)) {
|
||||
id->dpc = NVME_NS_DPC_PI_FIRST | NVME_NS_DPC_PI_LAST |
|
||||
NVME_NS_DPC_PI_TYPE1 | NVME_NS_DPC_PI_TYPE2 |
|
||||
NVME_NS_DPC_PI_TYPE3;
|
||||
id->mc = NVME_MC_EXTENDED_LBA;
|
||||
id->dps = ns->pi_type;
|
||||
id->flbas = NVME_NS_FLBAS_META_EXT;
|
||||
id->lbaf[0].ms = cpu_to_le16(ns->metadata_size);
|
||||
}
|
||||
|
||||
if (ns->readonly)
|
||||
id->nsattr |= (1 << 0);
|
||||
nvmet_put_namespace(ns);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue