@@ -1869,7 +1869,8 @@ static int __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
* controller.
*/
if (ns->ctrl->ops->flags & NVME_F_METADATA_SUPPORTED) {
- if (ns->ctrl->ops->flags & NVME_F_FABRICS ||
+ if ((ns->ctrl->ops->flags & NVME_F_FABRICS &&
+ ns->ctrl->opts->pi_enable) ||
!(ns->features & NVME_NS_EXT_LBAS))
ns->features |= NVME_NS_MD_HOST_SUPPORTED;
}
@@ -612,6 +612,7 @@ bool __nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
{ NVMF_OPT_NR_WRITE_QUEUES, "nr_write_queues=%d" },
{ NVMF_OPT_NR_POLL_QUEUES, "nr_poll_queues=%d" },
{ NVMF_OPT_TOS, "tos=%d" },
+ { NVMF_OPT_PI_ENABLE, "pi_enable" },
{ NVMF_OPT_ERR, NULL }
};
@@ -634,6 +635,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
opts->hdr_digest = false;
opts->data_digest = false;
opts->tos = -1; /* < 0 == use transport default */
+ opts->pi_enable = false;
options = o = kstrdup(buf, GFP_KERNEL);
if (!options)
@@ -867,6 +869,15 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
}
opts->tos = token;
break;
+#ifdef CONFIG_BLK_DEV_INTEGRITY
+ case NVMF_OPT_PI_ENABLE:
+ if (opts->discovery_nqn) {
+ pr_debug("Ignoring pi_enable value for discovery controller\n");
+ break;
+ }
+ opts->pi_enable = true;
+ break;
+#endif
default:
pr_warn("unknown parameter or missing value '%s' in ctrl creation request\n",
p);
@@ -56,6 +56,7 @@ enum {
NVMF_OPT_NR_WRITE_QUEUES = 1 << 17,
NVMF_OPT_NR_POLL_QUEUES = 1 << 18,
NVMF_OPT_TOS = 1 << 19,
+ NVMF_OPT_PI_ENABLE = 1 << 20,
};
/**
@@ -89,6 +90,7 @@ enum {
* @nr_write_queues: number of queues for write I/O
* @nr_poll_queues: number of queues for polling I/O
* @tos: type of service
+ * @pi_enable: Enable metadata (T10-PI) support
*/
struct nvmf_ctrl_options {
unsigned mask;
@@ -111,6 +113,7 @@ struct nvmf_ctrl_options {
unsigned int nr_write_queues;
unsigned int nr_poll_queues;
int tos;
+ bool pi_enable;
};
/*