Skip to content

Commit 037b262

Browse files
committed
Merge branch 'nvme-5.1' of git://git.infradead.org/nvme into for-5.1/block
Pull NVMe changes for 5.1 from Christoph * 'nvme-5.1' of git://git.infradead.org/nvme: (22 commits) nvme-rdma: use nr_phys_segments when map rq to sgl nvmet: convert to SPDX identifiers nvmet-rdma: convert to SPDX identifiers nvme-loop: convert to SPDX identifiers nvmet-fcloop: convert to SPDX identifiers nvmet-fc: convert to SPDX identifiers nvme: convert to SPDX identifiers nvme-pci: convert to SPDX identifiers nvme-lightnvm: convert to SPDX identifiers nvme-rdma: convert to SPDX identifiers nvme-fc: convert to SPDX identifiers nvme-fabrics: convert to SPDX identifiers nvme-tcp.h: fix SPDX header nvme_ioctl.h: remove duplicate GPL boilerplate nvme: return error from nvme_alloc_ns() nvme: avoid that deleting a controller triggers a circular locking complaint nvme: introduce a helper function for controller deletion nvme: unexport nvme_delete_ctrl_sync() nvme-pci: check kstrtoint() return value in queue_count_set() nvme-fabrics: document the poll function argument ...
2 parents 49b1f22 + 34e0819 commit 037b262

29 files changed

+168
-289
lines changed

drivers/nvme/host/core.c

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1+
// SPDX-License-Identifier: GPL-2.0
12
/*
23
* NVM Express device driver
34
* Copyright (c) 2011-2014, Intel Corporation.
4-
*
5-
* This program is free software; you can redistribute it and/or modify it
6-
* under the terms and conditions of the GNU General Public License,
7-
* version 2, as published by the Free Software Foundation.
8-
*
9-
* This program is distributed in the hope it will be useful, but WITHOUT
10-
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11-
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12-
* more details.
135
*/
146

157
#include <linux/blkdev.h>
@@ -151,11 +143,8 @@ int nvme_reset_ctrl_sync(struct nvme_ctrl *ctrl)
151143
}
152144
EXPORT_SYMBOL_GPL(nvme_reset_ctrl_sync);
153145

154-
static void nvme_delete_ctrl_work(struct work_struct *work)
146+
static void nvme_do_delete_ctrl(struct nvme_ctrl *ctrl)
155147
{
156-
struct nvme_ctrl *ctrl =
157-
container_of(work, struct nvme_ctrl, delete_work);
158-
159148
dev_info(ctrl->device,
160149
"Removing ctrl: NQN \"%s\"\n", ctrl->opts->subsysnqn);
161150

@@ -167,6 +156,14 @@ static void nvme_delete_ctrl_work(struct work_struct *work)
167156
nvme_put_ctrl(ctrl);
168157
}
169158

159+
static void nvme_delete_ctrl_work(struct work_struct *work)
160+
{
161+
struct nvme_ctrl *ctrl =
162+
container_of(work, struct nvme_ctrl, delete_work);
163+
164+
nvme_do_delete_ctrl(ctrl);
165+
}
166+
170167
int nvme_delete_ctrl(struct nvme_ctrl *ctrl)
171168
{
172169
if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_DELETING))
@@ -177,7 +174,7 @@ int nvme_delete_ctrl(struct nvme_ctrl *ctrl)
177174
}
178175
EXPORT_SYMBOL_GPL(nvme_delete_ctrl);
179176

180-
int nvme_delete_ctrl_sync(struct nvme_ctrl *ctrl)
177+
static int nvme_delete_ctrl_sync(struct nvme_ctrl *ctrl)
181178
{
182179
int ret = 0;
183180

@@ -186,13 +183,13 @@ int nvme_delete_ctrl_sync(struct nvme_ctrl *ctrl)
186183
* can free the controller.
187184
*/
188185
nvme_get_ctrl(ctrl);
189-
ret = nvme_delete_ctrl(ctrl);
186+
if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_DELETING))
187+
ret = -EBUSY;
190188
if (!ret)
191-
flush_work(&ctrl->delete_work);
189+
nvme_do_delete_ctrl(ctrl);
192190
nvme_put_ctrl(ctrl);
193191
return ret;
194192
}
195-
EXPORT_SYMBOL_GPL(nvme_delete_ctrl_sync);
196193

197194
static inline bool nvme_ns_has_pi(struct nvme_ns *ns)
198195
{
@@ -2328,6 +2325,9 @@ static struct attribute *nvme_subsys_attrs[] = {
23282325
&subsys_attr_serial.attr,
23292326
&subsys_attr_firmware_rev.attr,
23302327
&subsys_attr_subsysnqn.attr,
2328+
#ifdef CONFIG_NVME_MULTIPATH
2329+
&subsys_attr_iopolicy.attr,
2330+
#endif
23312331
NULL,
23322332
};
23332333

@@ -2380,6 +2380,9 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
23802380
memcpy(subsys->firmware_rev, id->fr, sizeof(subsys->firmware_rev));
23812381
subsys->vendor_id = le16_to_cpu(id->vid);
23822382
subsys->cmic = id->cmic;
2383+
#ifdef CONFIG_NVME_MULTIPATH
2384+
subsys->iopolicy = NVME_IOPOLICY_NUMA;
2385+
#endif
23832386

23842387
subsys->dev.class = nvme_subsys_class;
23852388
subsys->dev.release = nvme_release_subsystem;
@@ -3211,21 +3214,23 @@ static int nvme_setup_streams_ns(struct nvme_ctrl *ctrl, struct nvme_ns *ns)
32113214
return 0;
32123215
}
32133216

3214-
static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
3217+
static int nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
32153218
{
32163219
struct nvme_ns *ns;
32173220
struct gendisk *disk;
32183221
struct nvme_id_ns *id;
32193222
char disk_name[DISK_NAME_LEN];
3220-
int node = ctrl->numa_node, flags = GENHD_FL_EXT_DEVT;
3223+
int node = ctrl->numa_node, flags = GENHD_FL_EXT_DEVT, ret;
32213224

32223225
ns = kzalloc_node(sizeof(*ns), GFP_KERNEL, node);
32233226
if (!ns)
3224-
return;
3227+
return -ENOMEM;
32253228

32263229
ns->queue = blk_mq_init_queue(ctrl->tagset);
3227-
if (IS_ERR(ns->queue))
3230+
if (IS_ERR(ns->queue)) {
3231+
ret = PTR_ERR(ns->queue);
32283232
goto out_free_ns;
3233+
}
32293234

32303235
blk_queue_flag_set(QUEUE_FLAG_NONROT, ns->queue);
32313236
if (ctrl->ops->flags & NVME_F_PCI_P2PDMA)
@@ -3241,20 +3246,27 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
32413246
nvme_set_queue_limits(ctrl, ns->queue);
32423247

32433248
id = nvme_identify_ns(ctrl, nsid);
3244-
if (!id)
3249+
if (!id) {
3250+
ret = -EIO;
32453251
goto out_free_queue;
3252+
}
32463253

3247-
if (id->ncap == 0)
3254+
if (id->ncap == 0) {
3255+
ret = -EINVAL;
32483256
goto out_free_id;
3257+
}
32493258

3250-
if (nvme_init_ns_head(ns, nsid, id))
3259+
ret = nvme_init_ns_head(ns, nsid, id);
3260+
if (ret)
32513261
goto out_free_id;
32523262
nvme_setup_streams_ns(ctrl, ns);
32533263
nvme_set_disk_name(disk_name, ns, ctrl, &flags);
32543264

32553265
disk = alloc_disk_node(0, node);
3256-
if (!disk)
3266+
if (!disk) {
3267+
ret = -ENOMEM;
32573268
goto out_unlink_ns;
3269+
}
32583270

32593271
disk->fops = &nvme_fops;
32603272
disk->private_data = ns;
@@ -3266,7 +3278,8 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
32663278
__nvme_revalidate_disk(disk, id);
32673279

32683280
if ((ctrl->quirks & NVME_QUIRK_LIGHTNVM) && id->vs[0] == 0x1) {
3269-
if (nvme_nvm_register(ns, disk_name, node)) {
3281+
ret = nvme_nvm_register(ns, disk_name, node);
3282+
if (ret) {
32703283
dev_warn(ctrl->device, "LightNVM init failure\n");
32713284
goto out_put_disk;
32723285
}
@@ -3284,7 +3297,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
32843297
nvme_fault_inject_init(ns);
32853298
kfree(id);
32863299

3287-
return;
3300+
return 0;
32883301
out_put_disk:
32893302
put_disk(ns->disk);
32903303
out_unlink_ns:
@@ -3297,6 +3310,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
32973310
blk_cleanup_queue(ns->queue);
32983311
out_free_ns:
32993312
kfree(ns);
3313+
return ret;
33003314
}
33013315

33023316
static void nvme_ns_remove(struct nvme_ns *ns)

drivers/nvme/host/fabrics.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1+
// SPDX-License-Identifier: GPL-2.0
12
/*
23
* NVMe over Fabrics common host code.
34
* Copyright (c) 2015-2016 HGST, a Western Digital Company.
4-
*
5-
* This program is free software; you can redistribute it and/or modify it
6-
* under the terms and conditions of the GNU General Public License,
7-
* version 2, as published by the Free Software Foundation.
8-
*
9-
* This program is distributed in the hope it will be useful, but WITHOUT
10-
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11-
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12-
* more details.
135
*/
146
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
157
#include <linux/init.h>
@@ -430,6 +422,7 @@ EXPORT_SYMBOL_GPL(nvmf_connect_admin_queue);
430422
* @qid: NVMe I/O queue number for the new I/O connection between
431423
* host and target (note qid == 0 is illegal as this is
432424
* the Admin queue, per NVMe standard).
425+
* @poll: Whether or not to poll for the completion of the connect cmd.
433426
*
434427
* This function issues a fabrics-protocol connection
435428
* of a NVMe I/O queue (via NVMe Fabrics "Connect" command)

drivers/nvme/host/fabrics.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
12
/*
23
* NVMe over Fabrics common host code.
34
* Copyright (c) 2015-2016 HGST, a Western Digital Company.
4-
*
5-
* This program is free software; you can redistribute it and/or modify it
6-
* under the terms and conditions of the GNU General Public License,
7-
* version 2, as published by the Free Software Foundation.
8-
*
9-
* This program is distributed in the hope it will be useful, but WITHOUT
10-
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11-
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12-
* more details.
135
*/
146
#ifndef _NVME_FABRICS_H
157
#define _NVME_FABRICS_H 1

drivers/nvme/host/fault_inject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
// SPDX-License-Identifier: GPL-2.0
12
/*
23
* fault injection support for nvme.
34
*
45
* Copyright (c) 2018, Oracle and/or its affiliates
5-
*
66
*/
77

88
#include <linux/moduleparam.h>

drivers/nvme/host/fc.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
1+
// SPDX-License-Identifier: GPL-2.0
12
/*
23
* Copyright (c) 2016 Avago Technologies. All rights reserved.
3-
*
4-
* This program is free software; you can redistribute it and/or modify
5-
* it under the terms of version 2 of the GNU General Public License as
6-
* published by the Free Software Foundation.
7-
*
8-
* This program is distributed in the hope that it will be useful.
9-
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
10-
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
11-
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO
12-
* THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.
13-
* See the GNU General Public License for more details, a copy of which
14-
* can be found in the file COPYING included with this package
15-
*
164
*/
175
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
186
#include <linux/module.h>

drivers/nvme/host/lightnvm.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
1+
// SPDX-License-Identifier: GPL-2.0
12
/*
23
* nvme-lightnvm.c - LightNVM NVMe device
34
*
45
* Copyright (C) 2014-2015 IT University of Copenhagen
56
* Initial release: Matias Bjorling <mb@lightnvm.io>
6-
*
7-
* This program is free software; you can redistribute it and/or
8-
* modify it under the terms of the GNU General Public License version
9-
* 2 as published by the Free Software Foundation.
10-
*
11-
* This program is distributed in the hope that it will be useful, but
12-
* WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14-
* General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU General Public License
17-
* along with this program; see the file COPYING. If not, write to
18-
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
19-
* USA.
20-
*
217
*/
228

239
#include "nvme.h"

0 commit comments

Comments
 (0)