Skip to content

Commit 5cad875

Browse files
committed
Merge tag 'nvme-5.15-2021-09-24' of git://git.infradead.org/nvme into block-5.15
Pull NVMe fixes from Christoph: "nvme fixes for Linux 5.15: - keep ctrl->namespaces ordered (me) - fix incorrect h2cdata pdu offset accounting in nvme-tcp (Sagi Grimberg) - handled updated hw_queues in nvme-fc more carefully (Daniel Wagner, James Smart)" * tag 'nvme-5.15-2021-09-24' of git://git.infradead.org/nvme: nvme: keep ctrl->namespaces ordered nvme-tcp: fix incorrect h2cdata pdu offset accounting nvme-fc: remove freeze/unfreeze around update_nr_hw_queues nvme-fc: avoid race between time out and tear down nvme-fc: update hardware queues before using them
2 parents cd586d2 + 298ba0e commit 5cad875

File tree

3 files changed

+36
-28
lines changed

3 files changed

+36
-28
lines changed

drivers/nvme/host/core.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <linux/kernel.h>
1414
#include <linux/module.h>
1515
#include <linux/backing-dev.h>
16-
#include <linux/list_sort.h>
1716
#include <linux/slab.h>
1817
#include <linux/types.h>
1918
#include <linux/pr.h>
@@ -3716,15 +3715,6 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
37163715
return ret;
37173716
}
37183717

3719-
static int ns_cmp(void *priv, const struct list_head *a,
3720-
const struct list_head *b)
3721-
{
3722-
struct nvme_ns *nsa = container_of(a, struct nvme_ns, list);
3723-
struct nvme_ns *nsb = container_of(b, struct nvme_ns, list);
3724-
3725-
return nsa->head->ns_id - nsb->head->ns_id;
3726-
}
3727-
37283718
struct nvme_ns *nvme_find_get_ns(struct nvme_ctrl *ctrl, unsigned nsid)
37293719
{
37303720
struct nvme_ns *ns, *ret = NULL;
@@ -3745,6 +3735,22 @@ struct nvme_ns *nvme_find_get_ns(struct nvme_ctrl *ctrl, unsigned nsid)
37453735
}
37463736
EXPORT_SYMBOL_NS_GPL(nvme_find_get_ns, NVME_TARGET_PASSTHRU);
37473737

3738+
/*
3739+
* Add the namespace to the controller list while keeping the list ordered.
3740+
*/
3741+
static void nvme_ns_add_to_ctrl_list(struct nvme_ns *ns)
3742+
{
3743+
struct nvme_ns *tmp;
3744+
3745+
list_for_each_entry_reverse(tmp, &ns->ctrl->namespaces, list) {
3746+
if (tmp->head->ns_id < ns->head->ns_id) {
3747+
list_add(&ns->list, &tmp->list);
3748+
return;
3749+
}
3750+
}
3751+
list_add(&ns->list, &ns->ctrl->namespaces);
3752+
}
3753+
37483754
static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
37493755
struct nvme_ns_ids *ids)
37503756
{
@@ -3795,9 +3801,8 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
37953801
goto out_unlink_ns;
37963802

37973803
down_write(&ctrl->namespaces_rwsem);
3798-
list_add_tail(&ns->list, &ctrl->namespaces);
3804+
nvme_ns_add_to_ctrl_list(ns);
37993805
up_write(&ctrl->namespaces_rwsem);
3800-
38013806
nvme_get_ctrl(ctrl);
38023807

38033808
if (device_add_disk(ctrl->device, ns->disk, nvme_ns_id_attr_groups))
@@ -4080,10 +4085,6 @@ static void nvme_scan_work(struct work_struct *work)
40804085
if (nvme_scan_ns_list(ctrl) != 0)
40814086
nvme_scan_ns_sequential(ctrl);
40824087
mutex_unlock(&ctrl->scan_lock);
4083-
4084-
down_write(&ctrl->namespaces_rwsem);
4085-
list_sort(NULL, &ctrl->namespaces, ns_cmp);
4086-
up_write(&ctrl->namespaces_rwsem);
40874088
}
40884089

40894090
/*

drivers/nvme/host/fc.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2487,6 +2487,7 @@ __nvme_fc_abort_outstanding_ios(struct nvme_fc_ctrl *ctrl, bool start_queues)
24872487
*/
24882488
if (ctrl->ctrl.queue_count > 1) {
24892489
nvme_stop_queues(&ctrl->ctrl);
2490+
nvme_sync_io_queues(&ctrl->ctrl);
24902491
blk_mq_tagset_busy_iter(&ctrl->tag_set,
24912492
nvme_fc_terminate_exchange, &ctrl->ctrl);
24922493
blk_mq_tagset_wait_completed_request(&ctrl->tag_set);
@@ -2510,6 +2511,7 @@ __nvme_fc_abort_outstanding_ios(struct nvme_fc_ctrl *ctrl, bool start_queues)
25102511
* clean up the admin queue. Same thing as above.
25112512
*/
25122513
blk_mq_quiesce_queue(ctrl->ctrl.admin_q);
2514+
blk_sync_queue(ctrl->ctrl.admin_q);
25132515
blk_mq_tagset_busy_iter(&ctrl->admin_tag_set,
25142516
nvme_fc_terminate_exchange, &ctrl->ctrl);
25152517
blk_mq_tagset_wait_completed_request(&ctrl->admin_tag_set);
@@ -2951,6 +2953,13 @@ nvme_fc_recreate_io_queues(struct nvme_fc_ctrl *ctrl)
29512953
if (ctrl->ctrl.queue_count == 1)
29522954
return 0;
29532955

2956+
if (prior_ioq_cnt != nr_io_queues) {
2957+
dev_info(ctrl->ctrl.device,
2958+
"reconnect: revising io queue count from %d to %d\n",
2959+
prior_ioq_cnt, nr_io_queues);
2960+
blk_mq_update_nr_hw_queues(&ctrl->tag_set, nr_io_queues);
2961+
}
2962+
29542963
ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
29552964
if (ret)
29562965
goto out_free_io_queues;
@@ -2959,15 +2968,6 @@ nvme_fc_recreate_io_queues(struct nvme_fc_ctrl *ctrl)
29592968
if (ret)
29602969
goto out_delete_hw_queues;
29612970

2962-
if (prior_ioq_cnt != nr_io_queues) {
2963-
dev_info(ctrl->ctrl.device,
2964-
"reconnect: revising io queue count from %d to %d\n",
2965-
prior_ioq_cnt, nr_io_queues);
2966-
nvme_wait_freeze(&ctrl->ctrl);
2967-
blk_mq_update_nr_hw_queues(&ctrl->tag_set, nr_io_queues);
2968-
nvme_unfreeze(&ctrl->ctrl);
2969-
}
2970-
29712971
return 0;
29722972

29732973
out_delete_hw_queues:

drivers/nvme/host/tcp.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ static int nvme_tcp_setup_h2c_data_pdu(struct nvme_tcp_request *req,
620620
cpu_to_le32(data->hdr.hlen + hdgst + req->pdu_len + ddgst);
621621
data->ttag = pdu->ttag;
622622
data->command_id = nvme_cid(rq);
623-
data->data_offset = cpu_to_le32(req->data_sent);
623+
data->data_offset = pdu->r2t_offset;
624624
data->data_length = cpu_to_le32(req->pdu_len);
625625
return 0;
626626
}
@@ -953,7 +953,15 @@ static int nvme_tcp_try_send_data(struct nvme_tcp_request *req)
953953
nvme_tcp_ddgst_update(queue->snd_hash, page,
954954
offset, ret);
955955

956-
/* fully successful last write*/
956+
/*
957+
* update the request iterator except for the last payload send
958+
* in the request where we don't want to modify it as we may
959+
* compete with the RX path completing the request.
960+
*/
961+
if (req->data_sent + ret < req->data_len)
962+
nvme_tcp_advance_req(req, ret);
963+
964+
/* fully successful last send in current PDU */
957965
if (last && ret == len) {
958966
if (queue->data_digest) {
959967
nvme_tcp_ddgst_final(queue->snd_hash,
@@ -965,7 +973,6 @@ static int nvme_tcp_try_send_data(struct nvme_tcp_request *req)
965973
}
966974
return 1;
967975
}
968-
nvme_tcp_advance_req(req, ret);
969976
}
970977
return -EAGAIN;
971978
}

0 commit comments

Comments
 (0)