linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Max Gurtovoy <maxg@mellanox.com>
To: James Smart <james.smart@broadcom.com>,
	linux-nvme@lists.infradead.org, kbusch@kernel.org, hch@lst.de,
	sagi@grimberg.me, martin.petersen@oracle.com,
	jsmart2021@gmail.com, axboe@kernel.dk
Cc: vladimirk@mellanox.com, idanb@mellanox.com, israelr@mellanox.com,
	shlomin@mellanox.com, oren@mellanox.com, nitzanc@mellanox.com
Subject: Re: [PATCH 14/16] nvmet: add metadata/T10-PI support
Date: Thu, 14 May 2020 18:09:25 +0300	[thread overview]
Message-ID: <ff45413c-c43d-010d-68d9-d48b23693cee@mellanox.com> (raw)
In-Reply-To: <0599e55c-a9bf-75f6-5df3-9558029712b8@broadcom.com>


On 5/13/2020 10:51 PM, James Smart wrote:
>
>
> On 5/4/2020 8:57 AM, Max Gurtovoy wrote:
>> From: Israel Rukshin <israelr@mellanox.com>
>>
>> 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>
>> ---
>>   drivers/nvme/target/admin-cmd.c   | 26 +++++++++++++++---
>>   drivers/nvme/target/configfs.c    | 58 
>> +++++++++++++++++++++++++++++++++++++++
>>   drivers/nvme/target/core.c        | 21 +++++++++++---
>>   drivers/nvme/target/fabrics-cmd.c |  7 +++--
>>   drivers/nvme/target/nvmet.h       | 19 +++++++++++++
>>   5 files changed, 121 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/nvme/target/admin-cmd.c 
>> b/drivers/nvme/target/admin-cmd.c
>> index 905aba8..9c8a00d 100644
>> --- a/drivers/nvme/target/admin-cmd.c
>> +++ b/drivers/nvme/target/admin-cmd.c
>> @@ -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);
>> +
>
> This seems odd to me, and should probably be referencing attributes of 
> the a transport, which should probably be set based on what transport 
> port the command was received on.

we set this in admin_connect:

ctrl->pi_support = ctrl->port->pi_enable && ctrl->subsys->pi_support;


>
>
>>       /* Max response capsule size is cqe */
>>       id->iorcsz = cpu_to_le32(sizeof(struct nvme_completion) / 16);
>>   @@ -465,6 +472,7 @@ static void nvmet_execute_identify_ctrl(struct 
>> nvmet_req *req)
>>     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;
>>   @@ -526,6 +534,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;
>
> Why is PI_TYPE2 getting set if nvmet_bdev_ns_enable_integrity() won't 
> set a metadata size ?

It wont:

static inline bool nvmet_ns_has_pi(struct nvmet_ns *ns)
{
         if (!IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY))
                 return false;
         return ns->pi_type && ns->metadata_size == sizeof(struct 
t10_pi_tuple);
}

>
>> +        id->mc = NVME_MC_EXTENDED_LBA;
>> +        id->dps = ns->pi_type;
>> +        id->flbas = NVME_NS_FLBAS_META_EXT;
>
> I guess this is ok - always requiring extended lbas. Will this ever 
> change over time ?

This is according to the SPEC of NVMe/Fabrics


>
>> +        id->lbaf[0].ms = ns->metadata_size;
>> +    }
>> +
>>       if (ns->readonly)
>>           id->nsattr |= (1 << 0);
>>       nvmet_put_namespace(ns);
> ...
>> diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
>> index 50dfc60..9f6b0f9 100644
>> --- a/drivers/nvme/target/core.c
>> +++ b/drivers/nvme/target/core.c
>> @@ -322,12 +322,21 @@ int nvmet_enable_port(struct nvmet_port *port)
>>       if (!try_module_get(ops->owner))
>>           return -EINVAL;
>>   -    ret = ops->add_port(port);
>> -    if (ret) {
>> -        module_put(ops->owner);
>> -        return ret;
>> +    /*
>> +     * If the user requested PI support and the transport isn't pi 
>> capable,
>> +     * don't enable the port.
>> +     */
>> +    if (port->pi_enable && !ops->metadata_support) {
>> +        pr_err("T10-PI is not supported by transport type %d\n",
>> +               port->disc_addr.trtype);
>> +        ret = -EINVAL;
>> +        goto out_put;
>>       }
>>   +    ret = ops->add_port(port);
>> +    if (ret)
>> +        goto out_put;
>> +
>
> ok for now - but it's going to have to be changed later to check the 
> port attributes, not the transport ops.  So it'll go back to add_port, 
> then validation w/ delete_port if fails.
>
>>       /* If the transport didn't set inline_data_size, then disable 
>> it. */
>>       if (port->inline_data_size < 0)
>>           port->inline_data_size = 0;
>> @@ -335,6 +344,10 @@ int nvmet_enable_port(struct nvmet_port *port)
>>       port->enabled = true;
>>       port->tr_ops = ops;
>>       return 0;
>> +
>> +out_put:
>> +    module_put(ops->owner);
>> +    return ret;
>>   }
>>     void nvmet_disable_port(struct nvmet_port *port)
>> diff --git a/drivers/nvme/target/fabrics-cmd.c 
>> b/drivers/nvme/target/fabrics-cmd.c
>> index 52a6f70..42bd12b 100644
>> --- a/drivers/nvme/target/fabrics-cmd.c
>> +++ b/drivers/nvme/target/fabrics-cmd.c
>> @@ -197,6 +197,8 @@ static void nvmet_execute_admin_connect(struct 
>> nvmet_req *req)
>>           goto out;
>>       }
>>   +    ctrl->pi_support = ctrl->port->pi_enable && 
>> ctrl->subsys->pi_support;
>> +
>>       uuid_copy(&ctrl->hostid, &d->hostid);
>>         status = nvmet_install_queue(ctrl, req);
>> @@ -205,8 +207,9 @@ static void nvmet_execute_admin_connect(struct 
>> nvmet_req *req)
>>           goto out;
>>       }
>>   -    pr_info("creating controller %d for subsystem %s for NQN %s.\n",
>> -        ctrl->cntlid, ctrl->subsys->subsysnqn, ctrl->hostnqn);
>> +    pr_info("creating controller %d for subsystem %s for NQN %s%s.\n",
>> +        ctrl->cntlid, ctrl->subsys->subsysnqn, ctrl->hostnqn,
>> +        ctrl->pi_support ? " T10-PI is enabled" : "");
>>       req->cqe->result.u16 = cpu_to_le16(ctrl->cntlid);
>>     out:
>> diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
>> index ceedaaf..2986e2c 100644
>> --- a/drivers/nvme/target/nvmet.h
>> +++ b/drivers/nvme/target/nvmet.h
>> @@ -145,6 +145,7 @@ struct nvmet_port {
>>       bool                enabled;
>>       int                inline_data_size;
>>       const struct nvmet_fabrics_ops    *tr_ops;
>> +    bool                pi_enable;
>
> ok - but would have liked to have seen this generic-ized for metadata 
> support, then PI in the metadata.
>
>
> -- james
>
>
>

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  reply	other threads:[~2020-05-14 15:09 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-04 15:57 [PATCH 00/16 v7] nvme-rdma/nvmet-rdma: Add metadata/T10-PI support Max Gurtovoy
2020-05-04 15:57 ` [PATCH 01/16] block: always define struct blk_integrity in genhd.h Max Gurtovoy
2020-05-14  2:51   ` Martin K. Petersen
2020-05-04 15:57 ` [PATCH 02/16] nvme: introduce namespace features flag Max Gurtovoy
2020-05-04 23:59   ` James Smart
2020-05-14  2:52   ` Martin K. Petersen
2020-05-04 15:57 ` [PATCH 03/16] nvme: introduce NVME_NS_METADATA_SUPPORTED flag Max Gurtovoy
2020-05-05 23:33   ` James Smart
2020-05-06  8:39     ` Max Gurtovoy
2020-05-06 20:44       ` James Smart
2020-05-07  9:02         ` Max Gurtovoy
2020-05-11 23:50           ` James Smart
2020-05-13 18:18             ` Christoph Hellwig
2020-05-13 19:53               ` James Smart
2020-05-14  2:53   ` Martin K. Petersen
2020-05-04 15:57 ` [PATCH 04/16] nvme: make nvme_ns_has_pi accessible to transports Max Gurtovoy
2020-05-14  2:53   ` Martin K. Petersen
2020-05-04 15:57 ` [PATCH 05/16] nvme: introduce max_integrity_segments ctrl attribute Max Gurtovoy
2020-05-05 23:51   ` James Smart
2020-05-06  7:08     ` Christoph Hellwig
2020-05-13 19:04   ` James Smart
2020-05-04 15:57 ` [PATCH 06/16] nvme: enforce extended LBA format for fabrics metadata Max Gurtovoy
2020-05-13 19:03   ` James Smart
2020-05-14  2:56     ` Martin K. Petersen
2020-05-14  8:28       ` Max Gurtovoy
2020-05-14  8:15     ` Max Gurtovoy
2020-05-04 15:57 ` [PATCH 07/16] nvme: introduce NVME_INLINE_METADATA_SG_CNT Max Gurtovoy
2020-05-13 19:05   ` James Smart
2020-05-04 15:57 ` [PATCH 08/16] nvme-rdma: introduce nvme_rdma_sgl structure Max Gurtovoy
2020-05-04 15:57 ` [PATCH 09/16] nvme-rdma: add metadata/T10-PI support Max Gurtovoy
2020-05-05  6:12   ` Christoph Hellwig
2020-05-14  3:02   ` Martin K. Petersen
2020-05-14  8:48     ` Max Gurtovoy
2020-05-14 22:40       ` Martin K. Petersen
2020-05-15 14:50         ` Max Gurtovoy
2020-05-18 17:22           ` Martin K. Petersen
2020-05-04 15:57 ` [PATCH 10/16] nvmet: add metadata characteristics for a namespace Max Gurtovoy
2020-05-13 19:25   ` James Smart
2020-05-14  3:06     ` Martin K. Petersen
2020-05-04 15:57 ` [PATCH 11/16] nvmet: rename nvmet_rw_len to nvmet_rw_data_len Max Gurtovoy
2020-05-13 19:25   ` James Smart
2020-05-04 15:57 ` [PATCH 12/16] nvmet: rename nvmet_check_data_len to nvmet_check_transfer_len Max Gurtovoy
2020-05-13 19:27   ` James Smart
2020-05-04 15:57 ` [PATCH 13/16] nvme: add Metadata Capabilities enumerations Max Gurtovoy
2020-05-13 19:27   ` James Smart
2020-05-14  3:07   ` Martin K. Petersen
2020-05-04 15:57 ` [PATCH 14/16] nvmet: add metadata/T10-PI support Max Gurtovoy
2020-05-13 19:51   ` James Smart
2020-05-14 15:09     ` Max Gurtovoy [this message]
2020-05-14 15:37       ` James Smart
2020-05-04 15:57 ` [PATCH 15/16] nvmet: add metadata support for block devices Max Gurtovoy
2020-05-04 15:57 ` [PATCH 16/16] nvmet-rdma: add metadata/T10-PI support Max Gurtovoy
2020-05-14  3:10   ` Martin K. Petersen
2020-05-14  8:55     ` Max Gurtovoy
2020-05-05  6:13 ` [PATCH 00/16 v7] nvme-rdma/nvmet-rdma: Add " Christoph Hellwig
2020-05-14 15:55   ` Max Gurtovoy
  -- strict thread matches above, loose matches on Subject: below --
2020-05-19 14:05 [PATCH 00/16 v8] " Max Gurtovoy
2020-05-19 14:06 ` [PATCH 14/16] nvmet: add " Max Gurtovoy
2019-12-02 14:47 [PATCH 00/16 V2] nvme-rdma/nvmet-rdma: Add " Max Gurtovoy
2019-12-02 14:48 ` [PATCH 14/16] nvmet: " Max Gurtovoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ff45413c-c43d-010d-68d9-d48b23693cee@mellanox.com \
    --to=maxg@mellanox.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=idanb@mellanox.com \
    --cc=israelr@mellanox.com \
    --cc=james.smart@broadcom.com \
    --cc=jsmart2021@gmail.com \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=martin.petersen@oracle.com \
    --cc=nitzanc@mellanox.com \
    --cc=oren@mellanox.com \
    --cc=sagi@grimberg.me \
    --cc=shlomin@mellanox.com \
    --cc=vladimirk@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).