Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvmet: introduce new mdts configuration entry

Using this port configuration, one will be able to set the Maximum Data
Transfer Size (MDTS) for any controller that will be associated to the
configured port. The default value remains 0 (no limit).

Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: Aurelien Aptel <aaptel@nvidia.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>

authored by

Aurelien Aptel and committed by
Keith Busch
0a5a9464 723277b1

+51 -11
+2 -6
drivers/nvme/target/admin-cmd.c
··· 687 687 id->cmic = NVME_CTRL_CMIC_MULTI_PORT | NVME_CTRL_CMIC_MULTI_CTRL | 688 688 NVME_CTRL_CMIC_ANA; 689 689 690 - /* Limit MDTS according to transport capability */ 691 - if (ctrl->ops->get_mdts) 692 - id->mdts = ctrl->ops->get_mdts(ctrl); 693 - else 694 - id->mdts = 0; 695 - 690 + /* Limit MDTS according to port config or transport capability */ 691 + id->mdts = nvmet_ctrl_mdts(req); 696 692 id->cntlid = cpu_to_le16(ctrl->cntlid); 697 693 id->ver = cpu_to_le32(ctrl->subsys->ver); 698 694
+27
drivers/nvme/target/configfs.c
··· 301 301 302 302 CONFIGFS_ATTR(nvmet_, param_max_queue_size); 303 303 304 + static ssize_t nvmet_param_mdts_show(struct config_item *item, char *page) 305 + { 306 + struct nvmet_port *port = to_nvmet_port(item); 307 + 308 + return snprintf(page, PAGE_SIZE, "%d\n", port->mdts); 309 + } 310 + 311 + static ssize_t nvmet_param_mdts_store(struct config_item *item, 312 + const char *page, size_t count) 313 + { 314 + struct nvmet_port *port = to_nvmet_port(item); 315 + int ret; 316 + 317 + if (nvmet_is_port_enabled(port, __func__)) 318 + return -EACCES; 319 + ret = kstrtoint(page, 0, &port->mdts); 320 + if (ret) { 321 + pr_err("Invalid value '%s' for mdts\n", page); 322 + return -EINVAL; 323 + } 324 + return count; 325 + } 326 + 327 + CONFIGFS_ATTR(nvmet_, param_mdts); 328 + 304 329 #ifdef CONFIG_BLK_DEV_INTEGRITY 305 330 static ssize_t nvmet_param_pi_enable_show(struct config_item *item, 306 331 char *page) ··· 2020 1995 &nvmet_attr_addr_tsas, 2021 1996 &nvmet_attr_param_inline_data_size, 2022 1997 &nvmet_attr_param_max_queue_size, 1998 + &nvmet_attr_param_mdts, 2023 1999 #ifdef CONFIG_BLK_DEV_INTEGRITY 2024 2000 &nvmet_attr_param_pi_enable, 2025 2001 #endif ··· 2079 2053 INIT_LIST_HEAD(&port->referrals); 2080 2054 port->inline_data_size = -1; /* < 0 == let the transport choose */ 2081 2055 port->max_queue_size = -1; /* < 0 == let the transport choose */ 2056 + port->mdts = -1; /* < 0 == let the transport choose */ 2082 2057 2083 2058 port->disc_addr.trtype = NVMF_TRTYPE_MAX; 2084 2059 port->disc_addr.portid = cpu_to_le16(portid);
+8
drivers/nvme/target/core.c
··· 368 368 NVMET_MIN_QUEUE_SIZE, 369 369 NVMET_MAX_QUEUE_SIZE); 370 370 371 + /* 372 + * If the transport didn't set the mdts properly, then clamp it to the 373 + * target limits. Also set default values in case the transport didn't 374 + * set it at all. 375 + */ 376 + if (port->mdts < 0 || port->mdts > NVMET_MAX_MDTS) 377 + port->mdts = 0; 378 + 371 379 port->enabled = true; 372 380 port->tr_ops = ops; 373 381 return 0;
+13
drivers/nvme/target/nvmet.h
··· 214 214 bool enabled; 215 215 int inline_data_size; 216 216 int max_queue_size; 217 + int mdts; 217 218 const struct nvmet_fabrics_ops *tr_ops; 218 219 bool pi_enable; 219 220 }; ··· 673 672 #define NVMET_MAX_QUEUE_SIZE 1024 674 673 #define NVMET_NR_QUEUES 128 675 674 #define NVMET_MAX_CMD(ctrl) (NVME_CAP_MQES(ctrl->cap) + 1) 675 + #define NVMET_MAX_MDTS 255 676 676 677 677 /* 678 678 * Nice round number that makes a list of nsids fit into a page. ··· 760 758 static inline bool nvmet_is_pci_ctrl(struct nvmet_ctrl *ctrl) 761 759 { 762 760 return ctrl->port->disc_addr.trtype == NVMF_TRTYPE_PCI; 761 + } 762 + 763 + /* Limit MDTS according to port config or transport capability */ 764 + static inline u8 nvmet_ctrl_mdts(struct nvmet_req *req) 765 + { 766 + struct nvmet_ctrl *ctrl = req->sq->ctrl; 767 + u8 mdts = req->port->mdts; 768 + 769 + if (!ctrl->ops->get_mdts) 770 + return mdts; 771 + return min_not_zero(ctrl->ops->get_mdts(ctrl), mdts); 763 772 } 764 773 765 774 #ifdef CONFIG_NVME_TARGET_PASSTHRU
+1 -5
drivers/nvme/target/zns.c
··· 69 69 void nvmet_execute_identify_ctrl_zns(struct nvmet_req *req) 70 70 { 71 71 u8 zasl = req->sq->ctrl->subsys->zasl; 72 - struct nvmet_ctrl *ctrl = req->sq->ctrl; 73 72 struct nvme_id_ctrl_zns *id; 74 73 u16 status; 75 74 ··· 78 79 goto out; 79 80 } 80 81 81 - if (ctrl->ops->get_mdts) 82 - id->zasl = min_t(u8, ctrl->ops->get_mdts(ctrl), zasl); 83 - else 84 - id->zasl = zasl; 82 + id->zasl = min_not_zero(nvmet_ctrl_mdts(req), zasl); 85 83 86 84 status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); 87 85