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.

Merge branch 'for-linus' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:
"A collection of fixes for the nvme over fabrics code"

* 'for-linus' of git://git.kernel.dk/linux-block:
nvme-rdma: Get rid of redundant defines
nvme-rdma: Get rid of duplicate variable
nvme: fabrics drivers don't need the nvme-pci driver
nvme-fabrics: get a reference when reusing a nvme_host structure
nvme-fabrics: change NQN UUID to big-endian format
nvme-loop: set sqsize to 0-based value, per spec
nvme-rdma: fix sqsize/hsqsize per spec
fabrics: define admin sqsize min default, per spec
nvmet-rdma: +1 to *queue_size from hsqsize/hrqsize
nvmet-rdma: Fix use after free
nvme-rdma: initialize ret to zero to avoid returning garbage

+54 -34
+1 -1
drivers/nvme/host/Kconfig
··· 31 31 config NVME_RDMA 32 32 tristate "NVM Express over Fabrics RDMA host driver" 33 33 depends on INFINIBAND 34 - depends on BLK_DEV_NVME 34 + select NVME_CORE 35 35 select NVME_FABRICS 36 36 select SG_POOL 37 37 help
+16 -7
drivers/nvme/host/fabrics.c
··· 47 47 48 48 mutex_lock(&nvmf_hosts_mutex); 49 49 host = __nvmf_host_find(hostnqn); 50 - if (host) 50 + if (host) { 51 + kref_get(&host->ref); 51 52 goto out_unlock; 53 + } 52 54 53 55 host = kmalloc(sizeof(*host), GFP_KERNEL); 54 56 if (!host) ··· 58 56 59 57 kref_init(&host->ref); 60 58 memcpy(host->nqn, hostnqn, NVMF_NQN_SIZE); 61 - uuid_le_gen(&host->id); 59 + uuid_be_gen(&host->id); 62 60 63 61 list_add_tail(&host->list, &nvmf_hosts); 64 62 out_unlock: ··· 75 73 return NULL; 76 74 77 75 kref_init(&host->ref); 78 - uuid_le_gen(&host->id); 76 + uuid_be_gen(&host->id); 79 77 snprintf(host->nqn, NVMF_NQN_SIZE, 80 - "nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUl", &host->id); 78 + "nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUb", &host->id); 81 79 82 80 mutex_lock(&nvmf_hosts_mutex); 83 81 list_add_tail(&host->list, &nvmf_hosts); ··· 365 363 cmd.connect.opcode = nvme_fabrics_command; 366 364 cmd.connect.fctype = nvme_fabrics_type_connect; 367 365 cmd.connect.qid = 0; 368 - cmd.connect.sqsize = cpu_to_le16(ctrl->sqsize); 366 + 367 + /* 368 + * fabrics spec sets a minimum of depth 32 for admin queue, 369 + * so set the queue with this depth always until 370 + * justification otherwise. 371 + */ 372 + cmd.connect.sqsize = cpu_to_le16(NVMF_AQ_DEPTH - 1); 373 + 369 374 /* 370 375 * Set keep-alive timeout in seconds granularity (ms * 1000) 371 376 * and add a grace period for controller kato enforcement ··· 384 375 if (!data) 385 376 return -ENOMEM; 386 377 387 - memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_le)); 378 + memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_be)); 388 379 data->cntlid = cpu_to_le16(0xffff); 389 380 strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE); 390 381 strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE); ··· 443 434 if (!data) 444 435 return -ENOMEM; 445 436 446 - memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_le)); 437 + memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_be)); 447 438 data->cntlid = cpu_to_le16(ctrl->cntlid); 448 439 strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE); 449 440 strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE);
+1 -1
drivers/nvme/host/fabrics.h
··· 34 34 struct kref ref; 35 35 struct list_head list; 36 36 char nqn[NVMF_NQN_SIZE]; 37 - uuid_le id; 37 + uuid_be id; 38 38 }; 39 39 40 40 /**
+28 -18
drivers/nvme/host/rdma.c
··· 43 43 44 44 #define NVME_RDMA_MAX_INLINE_SEGMENTS 1 45 45 46 - #define NVME_RDMA_MAX_PAGES_PER_MR 512 47 - 48 - #define NVME_RDMA_DEF_RECONNECT_DELAY 20 49 - 50 46 /* 51 47 * We handle AEN commands ourselves and don't even let the 52 48 * block layer know about them. ··· 73 77 u32 num_sge; 74 78 int nents; 75 79 bool inline_data; 76 - bool need_inval; 77 80 struct ib_reg_wr reg_wr; 78 81 struct ib_cqe reg_cqe; 79 82 struct nvme_rdma_queue *queue; ··· 281 286 struct nvme_rdma_request *req = blk_mq_rq_to_pdu(rq); 282 287 int ret = 0; 283 288 284 - if (!req->need_inval) 289 + if (!req->mr->need_inval) 285 290 goto out; 286 291 287 292 ib_dereg_mr(req->mr); ··· 293 298 req->mr = NULL; 294 299 } 295 300 296 - req->need_inval = false; 301 + req->mr->need_inval = false; 297 302 298 303 out: 299 304 return ret; ··· 640 645 int i, ret; 641 646 642 647 for (i = 1; i < ctrl->queue_count; i++) { 643 - ret = nvme_rdma_init_queue(ctrl, i, ctrl->ctrl.sqsize); 648 + ret = nvme_rdma_init_queue(ctrl, i, 649 + ctrl->ctrl.opts->queue_size); 644 650 if (ret) { 645 651 dev_info(ctrl->ctrl.device, 646 652 "failed to initialize i/o queue: %d\n", ret); ··· 845 849 if (!blk_rq_bytes(rq)) 846 850 return; 847 851 848 - if (req->need_inval) { 852 + if (req->mr->need_inval) { 849 853 res = nvme_rdma_inv_rkey(queue, req); 850 854 if (res < 0) { 851 855 dev_err(ctrl->ctrl.device, ··· 931 935 IB_ACCESS_REMOTE_READ | 932 936 IB_ACCESS_REMOTE_WRITE; 933 937 934 - req->need_inval = true; 938 + req->mr->need_inval = true; 935 939 936 940 sg->addr = cpu_to_le64(req->mr->iova); 937 941 put_unaligned_le24(req->mr->length, sg->length); ··· 954 958 955 959 req->num_sge = 1; 956 960 req->inline_data = false; 957 - req->need_inval = false; 961 + req->mr->need_inval = false; 958 962 959 963 c->common.flags |= NVME_CMD_SGL_METABUF; 960 964 ··· 1141 1145 1142 1146 if ((wc->wc_flags & IB_WC_WITH_INVALIDATE) && 1143 1147 wc->ex.invalidate_rkey == req->mr->rkey) 1144 - req->need_inval = false; 1148 + req->mr->need_inval = false; 1145 1149 1146 1150 blk_mq_complete_request(rq, status); 1147 1151 ··· 1274 1278 1275 1279 priv.recfmt = cpu_to_le16(NVME_RDMA_CM_FMT_1_0); 1276 1280 priv.qid = cpu_to_le16(nvme_rdma_queue_idx(queue)); 1277 - priv.hrqsize = cpu_to_le16(queue->queue_size); 1278 - priv.hsqsize = cpu_to_le16(queue->queue_size); 1281 + /* 1282 + * set the admin queue depth to the minimum size 1283 + * specified by the Fabrics standard. 1284 + */ 1285 + if (priv.qid == 0) { 1286 + priv.hrqsize = cpu_to_le16(NVMF_AQ_DEPTH); 1287 + priv.hsqsize = cpu_to_le16(NVMF_AQ_DEPTH - 1); 1288 + } else { 1289 + /* 1290 + * current interpretation of the fabrics spec 1291 + * is at minimum you make hrqsize sqsize+1, or a 1292 + * 1's based representation of sqsize. 1293 + */ 1294 + priv.hrqsize = cpu_to_le16(queue->queue_size); 1295 + priv.hsqsize = cpu_to_le16(queue->ctrl->ctrl.sqsize); 1296 + } 1279 1297 1280 1298 ret = rdma_connect(queue->cm_id, &param); 1281 1299 if (ret) { ··· 1329 1319 static int nvme_rdma_device_unplug(struct nvme_rdma_queue *queue) 1330 1320 { 1331 1321 struct nvme_rdma_ctrl *ctrl = queue->ctrl; 1332 - int ret; 1322 + int ret = 0; 1333 1323 1334 1324 /* Own the controller deletion */ 1335 1325 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING)) ··· 1471 1461 if (rq->cmd_type == REQ_TYPE_FS && req_op(rq) == REQ_OP_FLUSH) 1472 1462 flush = true; 1473 1463 ret = nvme_rdma_post_send(queue, sqe, req->sge, req->num_sge, 1474 - req->need_inval ? &req->reg_wr.wr : NULL, flush); 1464 + req->mr->need_inval ? &req->reg_wr.wr : NULL, flush); 1475 1465 if (ret) { 1476 1466 nvme_rdma_unmap_data(queue, rq); 1477 1467 goto err; ··· 1826 1816 1827 1817 memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set)); 1828 1818 ctrl->tag_set.ops = &nvme_rdma_mq_ops; 1829 - ctrl->tag_set.queue_depth = ctrl->ctrl.sqsize; 1819 + ctrl->tag_set.queue_depth = ctrl->ctrl.opts->queue_size; 1830 1820 ctrl->tag_set.reserved_tags = 1; /* fabric connect */ 1831 1821 ctrl->tag_set.numa_node = NUMA_NO_NODE; 1832 1822 ctrl->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; ··· 1924 1914 spin_lock_init(&ctrl->lock); 1925 1915 1926 1916 ctrl->queue_count = opts->nr_io_queues + 1; /* +1 for admin queue */ 1927 - ctrl->ctrl.sqsize = opts->queue_size; 1917 + ctrl->ctrl.sqsize = opts->queue_size - 1; 1928 1918 ctrl->ctrl.kato = opts->kato; 1929 1919 1930 1920 ret = -ENOMEM;
+1 -1
drivers/nvme/target/Kconfig
··· 15 15 16 16 config NVME_TARGET_LOOP 17 17 tristate "NVMe loopback device support" 18 - depends on BLK_DEV_NVME 19 18 depends on NVME_TARGET 19 + select NVME_CORE 20 20 select NVME_FABRICS 21 21 select SG_POOL 22 22 help
+2 -2
drivers/nvme/target/loop.c
··· 556 556 557 557 memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set)); 558 558 ctrl->tag_set.ops = &nvme_loop_mq_ops; 559 - ctrl->tag_set.queue_depth = ctrl->ctrl.sqsize; 559 + ctrl->tag_set.queue_depth = ctrl->ctrl.opts->queue_size; 560 560 ctrl->tag_set.reserved_tags = 1; /* fabric connect */ 561 561 ctrl->tag_set.numa_node = NUMA_NO_NODE; 562 562 ctrl->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; ··· 620 620 621 621 ret = -ENOMEM; 622 622 623 - ctrl->ctrl.sqsize = opts->queue_size; 623 + ctrl->ctrl.sqsize = opts->queue_size - 1; 624 624 ctrl->ctrl.kato = opts->kato; 625 625 626 626 ctrl->queues = kcalloc(opts->nr_io_queues + 1, sizeof(*ctrl->queues),
+4 -3
drivers/nvme/target/rdma.c
··· 978 978 container_of(w, struct nvmet_rdma_queue, release_work); 979 979 struct rdma_cm_id *cm_id = queue->cm_id; 980 980 struct nvmet_rdma_device *dev = queue->dev; 981 + enum nvmet_rdma_queue_state state = queue->state; 981 982 982 983 nvmet_rdma_free_queue(queue); 983 984 984 - if (queue->state != NVMET_RDMA_IN_DEVICE_REMOVAL) 985 + if (state != NVMET_RDMA_IN_DEVICE_REMOVAL) 985 986 rdma_destroy_id(cm_id); 986 987 987 988 kref_put(&dev->ref, nvmet_rdma_free_dev); ··· 1004 1003 queue->host_qid = le16_to_cpu(req->qid); 1005 1004 1006 1005 /* 1007 - * req->hsqsize corresponds to our recv queue size 1006 + * req->hsqsize corresponds to our recv queue size plus 1 1008 1007 * req->hrqsize corresponds to our send queue size 1009 1008 */ 1010 - queue->recv_queue_size = le16_to_cpu(req->hsqsize); 1009 + queue->recv_queue_size = le16_to_cpu(req->hsqsize) + 1; 1011 1010 queue->send_queue_size = le16_to_cpu(req->hrqsize); 1012 1011 1013 1012 if (!queue->host_qid && queue->recv_queue_size > NVMF_AQ_DEPTH)
+1 -1
include/linux/nvme.h
··· 794 794 }; 795 795 796 796 struct nvmf_connect_data { 797 - uuid_le hostid; 797 + uuid_be hostid; 798 798 __le16 cntlid; 799 799 char resv4[238]; 800 800 char subsysnqn[NVMF_NQN_FIELD_LEN];