Skip to content

Commit 5d02a5c

Browse files
committed
nvme: Remove ADMIN_ONLY state
The admin only state was intended to fence off actions that don't apply to a non-IO capable controller. The only actual user of this is the scan_work, and pci was the only transport to ever set this state. The consequence of having this state is placing an additional burden on every other action that applies to both live and admin only controllers. Remove the admin only state and place the admin only burden on the only place that actually cares: scan_work. This also prepares to make it easier to temporarily pause a LIVE state so that we don't need to remember which state the controller had been in prior to the pause. Tested-by: Edmund Nadolski <[email protected]> Reviewed-by: James Smart <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 770597e commit 5d02a5c

File tree

4 files changed

+11
-37
lines changed

4 files changed

+11
-37
lines changed

drivers/nvme/host/core.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static void nvme_queue_scan(struct nvme_ctrl *ctrl)
116116
/*
117117
* Only new queue scan work when admin and IO queues are both alive
118118
*/
119-
if (ctrl->state == NVME_CTRL_LIVE)
119+
if (ctrl->state == NVME_CTRL_LIVE && ctrl->tagset)
120120
queue_work(nvme_wq, &ctrl->scan_work);
121121
}
122122

@@ -137,8 +137,7 @@ int nvme_reset_ctrl_sync(struct nvme_ctrl *ctrl)
137137
ret = nvme_reset_ctrl(ctrl);
138138
if (!ret) {
139139
flush_work(&ctrl->reset_work);
140-
if (ctrl->state != NVME_CTRL_LIVE &&
141-
ctrl->state != NVME_CTRL_ADMIN_ONLY)
140+
if (ctrl->state != NVME_CTRL_LIVE)
142141
ret = -ENETRESET;
143142
}
144143

@@ -315,15 +314,6 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
315314

316315
old_state = ctrl->state;
317316
switch (new_state) {
318-
case NVME_CTRL_ADMIN_ONLY:
319-
switch (old_state) {
320-
case NVME_CTRL_CONNECTING:
321-
changed = true;
322-
/* FALLTHRU */
323-
default:
324-
break;
325-
}
326-
break;
327317
case NVME_CTRL_LIVE:
328318
switch (old_state) {
329319
case NVME_CTRL_NEW:
@@ -339,7 +329,6 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
339329
switch (old_state) {
340330
case NVME_CTRL_NEW:
341331
case NVME_CTRL_LIVE:
342-
case NVME_CTRL_ADMIN_ONLY:
343332
changed = true;
344333
/* FALLTHRU */
345334
default:
@@ -359,7 +348,6 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
359348
case NVME_CTRL_DELETING:
360349
switch (old_state) {
361350
case NVME_CTRL_LIVE:
362-
case NVME_CTRL_ADMIN_ONLY:
363351
case NVME_CTRL_RESETTING:
364352
case NVME_CTRL_CONNECTING:
365353
changed = true;
@@ -2873,7 +2861,6 @@ static int nvme_dev_open(struct inode *inode, struct file *file)
28732861

28742862
switch (ctrl->state) {
28752863
case NVME_CTRL_LIVE:
2876-
case NVME_CTRL_ADMIN_ONLY:
28772864
break;
28782865
default:
28792866
return -EWOULDBLOCK;
@@ -3167,7 +3154,6 @@ static ssize_t nvme_sysfs_show_state(struct device *dev,
31673154
static const char *const state_name[] = {
31683155
[NVME_CTRL_NEW] = "new",
31693156
[NVME_CTRL_LIVE] = "live",
3170-
[NVME_CTRL_ADMIN_ONLY] = "only-admin",
31713157
[NVME_CTRL_RESETTING] = "resetting",
31723158
[NVME_CTRL_CONNECTING] = "connecting",
31733159
[NVME_CTRL_DELETING] = "deleting",
@@ -3678,11 +3664,10 @@ static void nvme_scan_work(struct work_struct *work)
36783664
struct nvme_id_ctrl *id;
36793665
unsigned nn;
36803666

3681-
if (ctrl->state != NVME_CTRL_LIVE)
3667+
/* No tagset on a live ctrl means IO queues could not created */
3668+
if (ctrl->state != NVME_CTRL_LIVE || !ctrl->tagset)
36823669
return;
36833670

3684-
WARN_ON_ONCE(!ctrl->tagset);
3685-
36863671
if (test_and_clear_bit(NVME_AER_NOTICE_NS_CHANGED, &ctrl->events)) {
36873672
dev_info(ctrl->device, "rescanning namespaces.\n");
36883673
nvme_clear_changed_ns_log(ctrl);

drivers/nvme/host/fabrics.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ bool nvmf_ip_options_match(struct nvme_ctrl *ctrl,
182182
static inline bool nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
183183
bool queue_live)
184184
{
185-
if (likely(ctrl->state == NVME_CTRL_LIVE ||
186-
ctrl->state == NVME_CTRL_ADMIN_ONLY))
185+
if (likely(ctrl->state == NVME_CTRL_LIVE))
187186
return true;
188187
return __nvmf_check_ready(ctrl, rq, queue_live);
189188
}

drivers/nvme/host/nvme.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ static inline u16 nvme_req_qid(struct request *req)
161161
enum nvme_ctrl_state {
162162
NVME_CTRL_NEW,
163163
NVME_CTRL_LIVE,
164-
NVME_CTRL_ADMIN_ONLY, /* Only admin queue live */
165164
NVME_CTRL_RESETTING,
166165
NVME_CTRL_CONNECTING,
167166
NVME_CTRL_DELETING,

drivers/nvme/host/pci.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,10 +2263,7 @@ static bool __nvme_disable_io_queues(struct nvme_dev *dev, u8 opcode)
22632263
return true;
22642264
}
22652265

2266-
/*
2267-
* return error value only when tagset allocation failed
2268-
*/
2269-
static int nvme_dev_add(struct nvme_dev *dev)
2266+
static void nvme_dev_add(struct nvme_dev *dev)
22702267
{
22712268
int ret;
22722269

@@ -2296,7 +2293,7 @@ static int nvme_dev_add(struct nvme_dev *dev)
22962293
if (ret) {
22972294
dev_warn(dev->ctrl.device,
22982295
"IO queues tagset allocation failed %d\n", ret);
2299-
return ret;
2296+
return;
23002297
}
23012298
dev->ctrl.tagset = &dev->tagset;
23022299
} else {
@@ -2307,7 +2304,6 @@ static int nvme_dev_add(struct nvme_dev *dev)
23072304
}
23082305

23092306
nvme_dbbuf_set(dev);
2310-
return 0;
23112307
}
23122308

23132309
static int nvme_pci_enable(struct nvme_dev *dev)
@@ -2527,7 +2523,6 @@ static void nvme_reset_work(struct work_struct *work)
25272523
container_of(work, struct nvme_dev, ctrl.reset_work);
25282524
bool was_suspend = !!(dev->ctrl.ctrl_config & NVME_CC_SHN_NORMAL);
25292525
int result;
2530-
enum nvme_ctrl_state new_state = NVME_CTRL_LIVE;
25312526

25322527
if (WARN_ON(dev->ctrl.state != NVME_CTRL_RESETTING)) {
25332528
result = -ENODEV;
@@ -2621,24 +2616,21 @@ static void nvme_reset_work(struct work_struct *work)
26212616
dev_warn(dev->ctrl.device, "IO queues not created\n");
26222617
nvme_kill_queues(&dev->ctrl);
26232618
nvme_remove_namespaces(&dev->ctrl);
2624-
new_state = NVME_CTRL_ADMIN_ONLY;
26252619
nvme_free_tagset(dev);
26262620
} else {
26272621
nvme_start_queues(&dev->ctrl);
26282622
nvme_wait_freeze(&dev->ctrl);
2629-
/* hit this only when allocate tagset fails */
2630-
if (nvme_dev_add(dev))
2631-
new_state = NVME_CTRL_ADMIN_ONLY;
2623+
nvme_dev_add(dev);
26322624
nvme_unfreeze(&dev->ctrl);
26332625
}
26342626

26352627
/*
26362628
* If only admin queue live, keep it to do further investigation or
26372629
* recovery.
26382630
*/
2639-
if (!nvme_change_ctrl_state(&dev->ctrl, new_state)) {
2631+
if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_LIVE)) {
26402632
dev_warn(dev->ctrl.device,
2641-
"failed to mark controller state %d\n", new_state);
2633+
"failed to mark controller live state\n");
26422634
result = -ENODEV;
26432635
goto out;
26442636
}
@@ -2945,8 +2937,7 @@ static int nvme_suspend(struct device *dev)
29452937
nvme_wait_freeze(ctrl);
29462938
nvme_sync_queues(ctrl);
29472939

2948-
if (ctrl->state != NVME_CTRL_LIVE &&
2949-
ctrl->state != NVME_CTRL_ADMIN_ONLY)
2940+
if (ctrl->state != NVME_CTRL_LIVE)
29502941
goto unfreeze;
29512942

29522943
ret = nvme_get_power_state(ctrl, &ndev->last_ps);

0 commit comments

Comments
 (0)