Skip to content

Commit c786427

Browse files
committed
Merge tag 'for-linus-20180217' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: - NVMe pull request from Keith, with fixes all over the map for nvme. From various folks. - Classic polling fix, that avoids a latency issue where we still end up waiting for an interrupt in some cases. From Nitesh Shetty. - Comment typo fix from Minwoo Im. * tag 'for-linus-20180217' of git://git.kernel.dk/linux-block: block: fix a typo in comment of BLK_MQ_POLL_STATS_BKTS nvme-rdma: fix sysfs invoked reset_ctrl error flow nvmet: Change return code of discard command if not supported nvme-pci: Fix timeouts in connecting state nvme-pci: Remap CMB SQ entries on every controller reset nvme: fix the deadlock in nvme_update_formats blk: optimization for classic polling nvme: Don't use a stack buffer for keep-alive command nvme_fc: cleanup io completion nvme_fc: correct abort race condition on resets nvme: Fix discard buffer overrun nvme: delete NVME_CTRL_LIVE --> NVME_CTRL_CONNECTING transition nvme-rdma: use NVME_CTRL_CONNECTING state to mark init process nvme: rename NVME_CTRL_RECONNECTING state to NVME_CTRL_CONNECTING
2 parents fa2139e + 096392e commit c786427

File tree

9 files changed

+108
-171
lines changed

9 files changed

+108
-171
lines changed

block/blk-mq.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3164,6 +3164,7 @@ static bool __blk_mq_poll(struct blk_mq_hw_ctx *hctx, struct request *rq)
31643164
cpu_relax();
31653165
}
31663166

3167+
__set_current_state(TASK_RUNNING);
31673168
return false;
31683169
}
31693170

drivers/nvme/host/core.c

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,12 @@ int nvme_reset_ctrl_sync(struct nvme_ctrl *ctrl)
120120
int ret;
121121

122122
ret = nvme_reset_ctrl(ctrl);
123-
if (!ret)
123+
if (!ret) {
124124
flush_work(&ctrl->reset_work);
125+
if (ctrl->state != NVME_CTRL_LIVE)
126+
ret = -ENETRESET;
127+
}
128+
125129
return ret;
126130
}
127131
EXPORT_SYMBOL_GPL(nvme_reset_ctrl_sync);
@@ -265,7 +269,7 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
265269
switch (new_state) {
266270
case NVME_CTRL_ADMIN_ONLY:
267271
switch (old_state) {
268-
case NVME_CTRL_RECONNECTING:
272+
case NVME_CTRL_CONNECTING:
269273
changed = true;
270274
/* FALLTHRU */
271275
default:
@@ -276,7 +280,7 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
276280
switch (old_state) {
277281
case NVME_CTRL_NEW:
278282
case NVME_CTRL_RESETTING:
279-
case NVME_CTRL_RECONNECTING:
283+
case NVME_CTRL_CONNECTING:
280284
changed = true;
281285
/* FALLTHRU */
282286
default:
@@ -294,9 +298,9 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
294298
break;
295299
}
296300
break;
297-
case NVME_CTRL_RECONNECTING:
301+
case NVME_CTRL_CONNECTING:
298302
switch (old_state) {
299-
case NVME_CTRL_LIVE:
303+
case NVME_CTRL_NEW:
300304
case NVME_CTRL_RESETTING:
301305
changed = true;
302306
/* FALLTHRU */
@@ -309,7 +313,7 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
309313
case NVME_CTRL_LIVE:
310314
case NVME_CTRL_ADMIN_ONLY:
311315
case NVME_CTRL_RESETTING:
312-
case NVME_CTRL_RECONNECTING:
316+
case NVME_CTRL_CONNECTING:
313317
changed = true;
314318
/* FALLTHRU */
315319
default:
@@ -518,9 +522,11 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req,
518522
u64 slba = nvme_block_nr(ns, bio->bi_iter.bi_sector);
519523
u32 nlb = bio->bi_iter.bi_size >> ns->lba_shift;
520524

521-
range[n].cattr = cpu_to_le32(0);
522-
range[n].nlb = cpu_to_le32(nlb);
523-
range[n].slba = cpu_to_le64(slba);
525+
if (n < segments) {
526+
range[n].cattr = cpu_to_le32(0);
527+
range[n].nlb = cpu_to_le32(nlb);
528+
range[n].slba = cpu_to_le64(slba);
529+
}
524530
n++;
525531
}
526532

@@ -794,13 +800,9 @@ static void nvme_keep_alive_end_io(struct request *rq, blk_status_t status)
794800

795801
static int nvme_keep_alive(struct nvme_ctrl *ctrl)
796802
{
797-
struct nvme_command c;
798803
struct request *rq;
799804

800-
memset(&c, 0, sizeof(c));
801-
c.common.opcode = nvme_admin_keep_alive;
802-
803-
rq = nvme_alloc_request(ctrl->admin_q, &c, BLK_MQ_REQ_RESERVED,
805+
rq = nvme_alloc_request(ctrl->admin_q, &ctrl->ka_cmd, BLK_MQ_REQ_RESERVED,
804806
NVME_QID_ANY);
805807
if (IS_ERR(rq))
806808
return PTR_ERR(rq);
@@ -832,6 +834,8 @@ void nvme_start_keep_alive(struct nvme_ctrl *ctrl)
832834
return;
833835

834836
INIT_DELAYED_WORK(&ctrl->ka_work, nvme_keep_alive_work);
837+
memset(&ctrl->ka_cmd, 0, sizeof(ctrl->ka_cmd));
838+
ctrl->ka_cmd.common.opcode = nvme_admin_keep_alive;
835839
schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ);
836840
}
837841
EXPORT_SYMBOL_GPL(nvme_start_keep_alive);
@@ -1117,14 +1121,19 @@ static u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
11171121

11181122
static void nvme_update_formats(struct nvme_ctrl *ctrl)
11191123
{
1120-
struct nvme_ns *ns;
1124+
struct nvme_ns *ns, *next;
1125+
LIST_HEAD(rm_list);
11211126

11221127
mutex_lock(&ctrl->namespaces_mutex);
11231128
list_for_each_entry(ns, &ctrl->namespaces, list) {
1124-
if (ns->disk && nvme_revalidate_disk(ns->disk))
1125-
nvme_ns_remove(ns);
1129+
if (ns->disk && nvme_revalidate_disk(ns->disk)) {
1130+
list_move_tail(&ns->list, &rm_list);
1131+
}
11261132
}
11271133
mutex_unlock(&ctrl->namespaces_mutex);
1134+
1135+
list_for_each_entry_safe(ns, next, &rm_list, list)
1136+
nvme_ns_remove(ns);
11281137
}
11291138

11301139
static void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects)
@@ -2687,7 +2696,7 @@ static ssize_t nvme_sysfs_show_state(struct device *dev,
26872696
[NVME_CTRL_LIVE] = "live",
26882697
[NVME_CTRL_ADMIN_ONLY] = "only-admin",
26892698
[NVME_CTRL_RESETTING] = "resetting",
2690-
[NVME_CTRL_RECONNECTING]= "reconnecting",
2699+
[NVME_CTRL_CONNECTING] = "connecting",
26912700
[NVME_CTRL_DELETING] = "deleting",
26922701
[NVME_CTRL_DEAD] = "dead",
26932702
};

drivers/nvme/host/fabrics.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,14 @@ static inline blk_status_t nvmf_check_init_req(struct nvme_ctrl *ctrl,
171171
cmd->common.opcode != nvme_fabrics_command ||
172172
cmd->fabrics.fctype != nvme_fabrics_type_connect) {
173173
/*
174-
* Reconnecting state means transport disruption, which can take
175-
* a long time and even might fail permanently, fail fast to
176-
* give upper layers a chance to failover.
174+
* Connecting state means transport disruption or initial
175+
* establishment, which can take a long time and even might
176+
* fail permanently, fail fast to give upper layers a chance
177+
* to failover.
177178
* Deleting state means that the ctrl will never accept commands
178179
* again, fail it permanently.
179180
*/
180-
if (ctrl->state == NVME_CTRL_RECONNECTING ||
181+
if (ctrl->state == NVME_CTRL_CONNECTING ||
181182
ctrl->state == NVME_CTRL_DELETING) {
182183
nvme_req(rq)->status = NVME_SC_ABORT_REQ;
183184
return BLK_STS_IOERR;

0 commit comments

Comments
 (0)