2019-02-18 08:36:29 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2015-10-03 13:46:41 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011-2014, Intel Corporation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NVME_H
|
|
|
|
#define _NVME_H
|
|
|
|
|
|
|
|
#include <linux/nvme.h>
|
2017-10-18 14:59:25 +00:00
|
|
|
#include <linux/cdev.h>
|
2015-10-03 13:46:41 +00:00
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/kref.h>
|
|
|
|
#include <linux/blk-mq.h>
|
2016-09-16 12:25:07 +00:00
|
|
|
#include <linux/lightnvm.h>
|
2017-02-03 19:50:32 +00:00
|
|
|
#include <linux/sed-opal.h>
|
nvme: Add fault injection feature
Linux's fault injection framework provides a systematic way to support
error injection via debugfs in the /sys/kernel/debug directory. This
patch uses the framework to add error injection to NVMe driver. The
fault injection source code is stored in a separate file and only linked
if CONFIG_FAULT_INJECTION_DEBUG_FS kernel config is selected.
Once the error injection is enabled, NVME_SC_INVALID_OPCODE with no
retry will be injected into the nvme_end_request. Users can change
the default status code and no retry flag via debufs. Following example
shows how to enable and inject an error. For more examples, refer to
Documentation/fault-injection/nvme-fault-injection.txt
How to enable nvme fault injection:
First, enable CONFIG_FAULT_INJECTION_DEBUG_FS kernel config,
recompile the kernel. After booting up the kernel, do the
following.
How to inject an error:
mount /dev/nvme0n1 /mnt
echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/times
echo 100 > /sys/kernel/debug/nvme0n1/fault_inject/probability
cp a.file /mnt
Expected Result:
cp: cannot stat ‘/mnt/a.file’: Input/output error
Message from dmesg:
FAULT_INJECTION: forcing a failure.
name fault_inject, interval 1, probability 100, space 0, times 1
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.15.0-rc8+ #2
Hardware name: innotek GmbH VirtualBox/VirtualBox,
BIOS VirtualBox 12/01/2006
Call Trace:
<IRQ>
dump_stack+0x5c/0x7d
should_fail+0x148/0x170
nvme_should_fail+0x2f/0x50 [nvme_core]
nvme_process_cq+0xe7/0x1d0 [nvme]
nvme_irq+0x1e/0x40 [nvme]
__handle_irq_event_percpu+0x3a/0x190
handle_irq_event_percpu+0x30/0x70
handle_irq_event+0x36/0x60
handle_fasteoi_irq+0x78/0x120
handle_irq+0xa7/0x130
? tick_irq_enter+0xa8/0xc0
do_IRQ+0x43/0xc0
common_interrupt+0xa2/0xa2
</IRQ>
RIP: 0010:native_safe_halt+0x2/0x10
RSP: 0018:ffffffff82003e90 EFLAGS: 00000246 ORIG_RAX: ffffffffffffffdd
RAX: ffffffff817a10c0 RBX: ffffffff82012480 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 000000008e38ce64 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff82012480
R13: ffffffff82012480 R14: 0000000000000000 R15: 0000000000000000
? __sched_text_end+0x4/0x4
default_idle+0x18/0xf0
do_idle+0x150/0x1d0
cpu_startup_entry+0x6f/0x80
start_kernel+0x4c4/0x4e4
? set_init_arg+0x55/0x55
secondary_startup_64+0xa5/0xb0
print_req_error: I/O error, dev nvme0n1, sector 9240
EXT4-fs error (device nvme0n1): ext4_find_entry:1436:
inode #2: comm cp: reading directory lblock 0
Signed-off-by: Thomas Tai <thomas.tai@oracle.com>
Reviewed-by: Eric Saint-Etienne <eric.saint.etienne@oracle.com>
Signed-off-by: Karl Volz <karl.volz@oracle.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-02-08 18:38:29 +00:00
|
|
|
#include <linux/fault-inject.h>
|
2018-05-17 11:52:50 +00:00
|
|
|
#include <linux/rcupdate.h>
|
2019-09-04 16:06:11 +00:00
|
|
|
#include <linux/wait.h>
|
2015-10-03 13:46:41 +00:00
|
|
|
|
2019-07-24 13:47:55 +00:00
|
|
|
#include <trace/events/block.h>
|
|
|
|
|
2017-09-07 00:23:56 +00:00
|
|
|
extern unsigned int nvme_io_timeout;
|
2015-10-03 13:46:41 +00:00
|
|
|
#define NVME_IO_TIMEOUT (nvme_io_timeout * HZ)
|
|
|
|
|
2017-09-07 00:23:56 +00:00
|
|
|
extern unsigned int admin_timeout;
|
2015-11-26 08:08:36 +00:00
|
|
|
#define ADMIN_TIMEOUT (admin_timeout * HZ)
|
|
|
|
|
2016-06-13 14:45:28 +00:00
|
|
|
#define NVME_DEFAULT_KATO 5
|
|
|
|
#define NVME_KATO_GRACE 10
|
|
|
|
|
2017-06-07 18:31:55 +00:00
|
|
|
extern struct workqueue_struct *nvme_wq;
|
2018-01-14 10:39:02 +00:00
|
|
|
extern struct workqueue_struct *nvme_reset_wq;
|
|
|
|
extern struct workqueue_struct *nvme_delete_wq;
|
2017-06-07 18:31:55 +00:00
|
|
|
|
2015-10-29 08:57:29 +00:00
|
|
|
enum {
|
|
|
|
NVME_NS_LBA = 0,
|
|
|
|
NVME_NS_LIGHTNVM = 1,
|
|
|
|
};
|
|
|
|
|
2015-10-03 13:46:41 +00:00
|
|
|
/*
|
2015-11-26 09:07:41 +00:00
|
|
|
* List of workarounds for devices that required behavior not specified in
|
|
|
|
* the standard.
|
2015-10-03 13:46:41 +00:00
|
|
|
*/
|
2015-11-26 09:07:41 +00:00
|
|
|
enum nvme_quirks {
|
|
|
|
/*
|
|
|
|
* Prefers I/O aligned to a stripe size specified in a vendor
|
|
|
|
* specific Identify field.
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_STRIPE_SIZE = (1 << 0),
|
2015-10-22 21:45:06 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The controller doesn't handle Identify value others than 0 or 1
|
|
|
|
* correctly.
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_IDENTIFY_CNS = (1 << 1),
|
2016-03-04 20:15:17 +00:00
|
|
|
|
|
|
|
/*
|
2017-04-05 17:21:13 +00:00
|
|
|
* The controller deterministically returns O's on reads to
|
|
|
|
* logical blocks that deallocate was called on.
|
2016-03-04 20:15:17 +00:00
|
|
|
*/
|
2017-04-05 17:21:13 +00:00
|
|
|
NVME_QUIRK_DEALLOCATE_ZEROES = (1 << 2),
|
2016-06-14 21:22:41 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The controller needs a delay before starts checking the device
|
|
|
|
* readiness, which is done by reading the NVME_CSTS_RDY bit.
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_DELAY_BEFORE_CHK_RDY = (1 << 3),
|
nvme: Enable autonomous power state transitions
NVMe devices can advertise multiple power states. These states can
be either "operational" (the device is fully functional but possibly
slow) or "non-operational" (the device is asleep until woken up).
Some devices can automatically enter a non-operational state when
idle for a specified amount of time and then automatically wake back
up when needed.
The hardware configuration is a table. For each state, an entry in
the table indicates the next deeper non-operational state, if any,
to autonomously transition to and the idle time required before
transitioning.
This patch teaches the driver to program APST so that each successive
non-operational state will be entered after an idle time equal to 100%
of the total latency (entry plus exit) associated with that state.
The maximum acceptable latency is controlled using dev_pm_qos
(e.g. power/pm_qos_latency_tolerance_us in sysfs); non-operational
states with total latency greater than this value will not be used.
As a special case, setting the latency tolerance to 0 will disable
APST entirely. On hardware without APST support, the sysfs file will
not be exposed.
The latency tolerance for newly-probed devices is set by the module
parameter nvme_core.default_ps_max_latency_us.
In theory, the device can expose "default" APST table, but this
doesn't seem to function correctly on my device (Samsung 950), nor
does it seem particularly useful. There is also an optional
mechanism by which a configuration can be "saved" so it will be
automatically loaded on reset. This can be configured from
userspace, but it doesn't seem useful to support in the driver.
On my laptop, enabling APST seems to save nearly 1W.
The hardware tables can be decoded in userspace with nvme-cli.
'nvme id-ctrl /dev/nvmeN' will show the power state table and
'nvme get-feature -f 0x0c -H /dev/nvme0' will show the current APST
configuration.
This feature is quirked off on a known-buggy Samsung device.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-02-07 18:08:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* APST should not be used.
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_NO_APST = (1 << 4),
|
2017-04-20 20:37:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The deepest sleep state should not be used.
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_NO_DEEPEST_PS = (1 << 5),
|
2017-09-06 09:45:24 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Supports the LighNVM command set if indicated in vs[1].
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_LIGHTNVM = (1 << 6),
|
2018-05-08 16:25:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set MEDIUM priority on SQ creation
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_MEDIUM_PRIO_SQ = (1 << 7),
|
2019-01-08 17:20:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Ignore device provided subnqn.
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_IGNORE_DEV_SUBNQN = (1 << 8),
|
2019-03-13 17:55:05 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Broken Write Zeroes.
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_DISABLE_WRITE_ZEROES = (1 << 9),
|
2019-08-16 20:16:19 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Force simple suspend/resume path.
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_SIMPLE_SUSPEND = (1 << 10),
|
2019-09-17 23:57:47 +00:00
|
|
|
|
2019-08-07 07:51:21 +00:00
|
|
|
/*
|
|
|
|
* Use only one interrupt vector for all queues
|
|
|
|
*/
|
2019-09-17 23:57:47 +00:00
|
|
|
NVME_QUIRK_SINGLE_VECTOR = (1 << 11),
|
2019-08-07 07:51:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Use non-standard 128 bytes SQEs.
|
|
|
|
*/
|
2019-09-17 23:57:47 +00:00
|
|
|
NVME_QUIRK_128_BYTES_SQES = (1 << 12),
|
2019-08-07 07:51:22 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Prevent tag overlap between queues
|
|
|
|
*/
|
2019-09-17 23:57:47 +00:00
|
|
|
NVME_QUIRK_SHARED_TAGS = (1 << 13),
|
2015-11-26 09:07:41 +00:00
|
|
|
};
|
|
|
|
|
2016-11-10 15:32:33 +00:00
|
|
|
/*
|
|
|
|
* Common request structure for NVMe passthrough. All drivers must have
|
|
|
|
* this structure as the first member of their request-private data.
|
|
|
|
*/
|
|
|
|
struct nvme_request {
|
|
|
|
struct nvme_command *cmd;
|
|
|
|
union nvme_result result;
|
2017-04-05 17:18:11 +00:00
|
|
|
u8 retries;
|
2017-04-20 14:02:57 +00:00
|
|
|
u8 flags;
|
|
|
|
u16 status;
|
2018-06-29 22:50:00 +00:00
|
|
|
struct nvme_ctrl *ctrl;
|
2017-04-20 14:02:57 +00:00
|
|
|
};
|
|
|
|
|
2017-11-02 11:59:30 +00:00
|
|
|
/*
|
|
|
|
* Mark a bio as coming in through the mpath node.
|
|
|
|
*/
|
|
|
|
#define REQ_NVME_MPATH REQ_DRV
|
|
|
|
|
2017-04-20 14:02:57 +00:00
|
|
|
enum {
|
|
|
|
NVME_REQ_CANCELLED = (1 << 0),
|
2018-04-12 15:16:15 +00:00
|
|
|
NVME_REQ_USERCMD = (1 << 1),
|
2016-11-10 15:32:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct nvme_request *nvme_req(struct request *req)
|
|
|
|
{
|
|
|
|
return blk_mq_rq_to_pdu(req);
|
|
|
|
}
|
|
|
|
|
2018-06-29 22:50:01 +00:00
|
|
|
static inline u16 nvme_req_qid(struct request *req)
|
|
|
|
{
|
|
|
|
if (!req->rq_disk)
|
|
|
|
return 0;
|
|
|
|
return blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(req)) + 1;
|
|
|
|
}
|
|
|
|
|
2016-06-14 21:22:41 +00:00
|
|
|
/* The below value is the specific amount of delay needed before checking
|
|
|
|
* readiness in case of the PCI_DEVICE(0x1c58, 0x0003), which needs the
|
|
|
|
* NVME_QUIRK_DELAY_BEFORE_CHK_RDY quirk enabled. The value (in ms) was
|
|
|
|
* found empirically.
|
|
|
|
*/
|
2017-11-21 16:44:37 +00:00
|
|
|
#define NVME_QUIRK_DELAY_AMOUNT 2300
|
2016-06-14 21:22:41 +00:00
|
|
|
|
2016-04-26 11:51:57 +00:00
|
|
|
enum nvme_ctrl_state {
|
|
|
|
NVME_CTRL_NEW,
|
|
|
|
NVME_CTRL_LIVE,
|
|
|
|
NVME_CTRL_RESETTING,
|
2018-01-31 16:31:24 +00:00
|
|
|
NVME_CTRL_CONNECTING,
|
2016-04-26 11:51:57 +00:00
|
|
|
NVME_CTRL_DELETING,
|
2016-05-12 14:37:14 +00:00
|
|
|
NVME_CTRL_DEAD,
|
2016-04-26 11:51:57 +00:00
|
|
|
};
|
|
|
|
|
2019-06-20 06:49:02 +00:00
|
|
|
struct nvme_fault_inject {
|
|
|
|
#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
|
|
|
|
struct fault_attr attr;
|
|
|
|
struct dentry *parent;
|
|
|
|
bool dont_retry; /* DNR, do not retry */
|
|
|
|
u16 status; /* status code */
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2015-11-26 09:06:56 +00:00
|
|
|
struct nvme_ctrl {
|
2018-11-02 17:28:15 +00:00
|
|
|
bool comp_seen;
|
2016-04-26 11:51:57 +00:00
|
|
|
enum nvme_ctrl_state state;
|
2017-02-22 20:32:36 +00:00
|
|
|
bool identified;
|
2016-04-26 11:51:57 +00:00
|
|
|
spinlock_t lock;
|
2019-01-28 16:46:07 +00:00
|
|
|
struct mutex scan_lock;
|
2015-11-26 09:06:56 +00:00
|
|
|
const struct nvme_ctrl_ops *ops;
|
2015-10-03 13:46:41 +00:00
|
|
|
struct request_queue *admin_q;
|
2016-06-13 14:45:26 +00:00
|
|
|
struct request_queue *connect_q;
|
2019-08-03 02:33:59 +00:00
|
|
|
struct request_queue *fabrics_q;
|
2015-10-03 13:46:41 +00:00
|
|
|
struct device *dev;
|
|
|
|
int instance;
|
2018-11-16 08:22:29 +00:00
|
|
|
int numa_node;
|
2015-11-28 14:39:07 +00:00
|
|
|
struct blk_mq_tag_set *tagset;
|
2017-07-10 06:22:29 +00:00
|
|
|
struct blk_mq_tag_set *admin_tagset;
|
2015-10-03 13:46:41 +00:00
|
|
|
struct list_head namespaces;
|
2018-02-12 12:54:46 +00:00
|
|
|
struct rw_semaphore namespaces_rwsem;
|
2017-10-18 11:25:42 +00:00
|
|
|
struct device ctrl_device;
|
2015-11-28 14:39:07 +00:00
|
|
|
struct device *device; /* char device */
|
2017-10-18 14:59:25 +00:00
|
|
|
struct cdev cdev;
|
2017-06-15 13:41:08 +00:00
|
|
|
struct work_struct reset_work;
|
2017-10-29 08:44:29 +00:00
|
|
|
struct work_struct delete_work;
|
2019-09-04 16:06:11 +00:00
|
|
|
wait_queue_head_t state_wq;
|
2015-11-26 09:06:56 +00:00
|
|
|
|
2017-11-09 12:48:55 +00:00
|
|
|
struct nvme_subsystem *subsys;
|
|
|
|
struct list_head subsys_entry;
|
|
|
|
|
2017-02-17 12:59:39 +00:00
|
|
|
struct opal_dev *opal_dev;
|
2017-02-03 19:50:32 +00:00
|
|
|
|
2015-10-03 13:46:41 +00:00
|
|
|
char name[12];
|
2016-04-16 18:57:58 +00:00
|
|
|
u16 cntlid;
|
2015-11-28 14:03:49 +00:00
|
|
|
|
|
|
|
u32 ctrl_config;
|
2017-07-12 10:40:40 +00:00
|
|
|
u16 mtfa;
|
2017-04-24 07:58:29 +00:00
|
|
|
u32 queue_count;
|
2015-11-28 14:03:49 +00:00
|
|
|
|
2017-06-27 19:16:38 +00:00
|
|
|
u64 cap;
|
2015-11-28 14:03:49 +00:00
|
|
|
u32 page_size;
|
2015-10-03 13:46:41 +00:00
|
|
|
u32 max_hw_sectors;
|
2018-06-21 15:49:37 +00:00
|
|
|
u32 max_segments;
|
2018-11-27 16:40:57 +00:00
|
|
|
u16 crdt[3];
|
2015-10-03 13:46:41 +00:00
|
|
|
u16 oncs;
|
2017-02-17 12:59:40 +00:00
|
|
|
u16 oacs;
|
2017-06-27 18:03:06 +00:00
|
|
|
u16 nssa;
|
|
|
|
u16 nr_streams;
|
2019-09-26 03:44:39 +00:00
|
|
|
u16 sqsize;
|
2018-05-14 06:48:54 +00:00
|
|
|
u32 max_namespaces;
|
2015-11-20 08:36:44 +00:00
|
|
|
atomic_t abort_limit;
|
2015-10-03 13:46:41 +00:00
|
|
|
u8 vwc;
|
2015-11-28 14:40:19 +00:00
|
|
|
u32 vs;
|
2016-06-13 14:45:26 +00:00
|
|
|
u32 sgls;
|
2016-06-13 14:45:28 +00:00
|
|
|
u16 kas;
|
nvme: Enable autonomous power state transitions
NVMe devices can advertise multiple power states. These states can
be either "operational" (the device is fully functional but possibly
slow) or "non-operational" (the device is asleep until woken up).
Some devices can automatically enter a non-operational state when
idle for a specified amount of time and then automatically wake back
up when needed.
The hardware configuration is a table. For each state, an entry in
the table indicates the next deeper non-operational state, if any,
to autonomously transition to and the idle time required before
transitioning.
This patch teaches the driver to program APST so that each successive
non-operational state will be entered after an idle time equal to 100%
of the total latency (entry plus exit) associated with that state.
The maximum acceptable latency is controlled using dev_pm_qos
(e.g. power/pm_qos_latency_tolerance_us in sysfs); non-operational
states with total latency greater than this value will not be used.
As a special case, setting the latency tolerance to 0 will disable
APST entirely. On hardware without APST support, the sysfs file will
not be exposed.
The latency tolerance for newly-probed devices is set by the module
parameter nvme_core.default_ps_max_latency_us.
In theory, the device can expose "default" APST table, but this
doesn't seem to function correctly on my device (Samsung 950), nor
does it seem particularly useful. There is also an optional
mechanism by which a configuration can be "saved" so it will be
automatically loaded on reset. This can be configured from
userspace, but it doesn't seem useful to support in the driver.
On my laptop, enabling APST seems to save nearly 1W.
The hardware tables can be decoded in userspace with nvme-cli.
'nvme id-ctrl /dev/nvmeN' will show the power state table and
'nvme get-feature -f 0x0c -H /dev/nvme0' will show the current APST
configuration.
This feature is quirked off on a known-buggy Samsung device.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-02-07 18:08:45 +00:00
|
|
|
u8 npss;
|
|
|
|
u8 apsta;
|
2018-05-22 09:09:55 +00:00
|
|
|
u32 oaes;
|
2017-11-07 22:13:14 +00:00
|
|
|
u32 aen_result;
|
2018-11-02 17:28:14 +00:00
|
|
|
u32 ctratt;
|
2017-08-25 23:14:50 +00:00
|
|
|
unsigned int shutdown_timeout;
|
2016-06-13 14:45:28 +00:00
|
|
|
unsigned int kato;
|
2015-11-28 14:40:19 +00:00
|
|
|
bool subsystem;
|
2015-11-26 09:07:41 +00:00
|
|
|
unsigned long quirks;
|
nvme: Enable autonomous power state transitions
NVMe devices can advertise multiple power states. These states can
be either "operational" (the device is fully functional but possibly
slow) or "non-operational" (the device is asleep until woken up).
Some devices can automatically enter a non-operational state when
idle for a specified amount of time and then automatically wake back
up when needed.
The hardware configuration is a table. For each state, an entry in
the table indicates the next deeper non-operational state, if any,
to autonomously transition to and the idle time required before
transitioning.
This patch teaches the driver to program APST so that each successive
non-operational state will be entered after an idle time equal to 100%
of the total latency (entry plus exit) associated with that state.
The maximum acceptable latency is controlled using dev_pm_qos
(e.g. power/pm_qos_latency_tolerance_us in sysfs); non-operational
states with total latency greater than this value will not be used.
As a special case, setting the latency tolerance to 0 will disable
APST entirely. On hardware without APST support, the sysfs file will
not be exposed.
The latency tolerance for newly-probed devices is set by the module
parameter nvme_core.default_ps_max_latency_us.
In theory, the device can expose "default" APST table, but this
doesn't seem to function correctly on my device (Samsung 950), nor
does it seem particularly useful. There is also an optional
mechanism by which a configuration can be "saved" so it will be
automatically loaded on reset. This can be configured from
userspace, but it doesn't seem useful to support in the driver.
On my laptop, enabling APST seems to save nearly 1W.
The hardware tables can be decoded in userspace with nvme-cli.
'nvme id-ctrl /dev/nvmeN' will show the power state table and
'nvme get-feature -f 0x0c -H /dev/nvme0' will show the current APST
configuration.
This feature is quirked off on a known-buggy Samsung device.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-02-07 18:08:45 +00:00
|
|
|
struct nvme_id_power_state psd[32];
|
2017-11-07 17:28:32 +00:00
|
|
|
struct nvme_effects_log *effects;
|
2016-04-26 11:51:59 +00:00
|
|
|
struct work_struct scan_work;
|
2016-04-26 11:52:00 +00:00
|
|
|
struct work_struct async_event_work;
|
2016-06-13 14:45:28 +00:00
|
|
|
struct delayed_work ka_work;
|
2018-01-11 21:38:15 +00:00
|
|
|
struct nvme_command ka_cmd;
|
2017-07-12 10:40:40 +00:00
|
|
|
struct work_struct fw_act_work;
|
2018-05-25 16:17:41 +00:00
|
|
|
unsigned long events;
|
2016-06-13 14:45:26 +00:00
|
|
|
|
2018-05-14 06:48:54 +00:00
|
|
|
#ifdef CONFIG_NVME_MULTIPATH
|
|
|
|
/* asymmetric namespace access: */
|
|
|
|
u8 anacap;
|
|
|
|
u8 anatt;
|
|
|
|
u32 anagrpmax;
|
|
|
|
u32 nanagrpid;
|
|
|
|
struct mutex ana_lock;
|
|
|
|
struct nvme_ana_rsp_hdr *ana_log_buf;
|
|
|
|
size_t ana_log_size;
|
|
|
|
struct timer_list anatt_timer;
|
|
|
|
struct work_struct ana_work;
|
|
|
|
#endif
|
|
|
|
|
nvme: Enable autonomous power state transitions
NVMe devices can advertise multiple power states. These states can
be either "operational" (the device is fully functional but possibly
slow) or "non-operational" (the device is asleep until woken up).
Some devices can automatically enter a non-operational state when
idle for a specified amount of time and then automatically wake back
up when needed.
The hardware configuration is a table. For each state, an entry in
the table indicates the next deeper non-operational state, if any,
to autonomously transition to and the idle time required before
transitioning.
This patch teaches the driver to program APST so that each successive
non-operational state will be entered after an idle time equal to 100%
of the total latency (entry plus exit) associated with that state.
The maximum acceptable latency is controlled using dev_pm_qos
(e.g. power/pm_qos_latency_tolerance_us in sysfs); non-operational
states with total latency greater than this value will not be used.
As a special case, setting the latency tolerance to 0 will disable
APST entirely. On hardware without APST support, the sysfs file will
not be exposed.
The latency tolerance for newly-probed devices is set by the module
parameter nvme_core.default_ps_max_latency_us.
In theory, the device can expose "default" APST table, but this
doesn't seem to function correctly on my device (Samsung 950), nor
does it seem particularly useful. There is also an optional
mechanism by which a configuration can be "saved" so it will be
automatically loaded on reset. This can be configured from
userspace, but it doesn't seem useful to support in the driver.
On my laptop, enabling APST seems to save nearly 1W.
The hardware tables can be decoded in userspace with nvme-cli.
'nvme id-ctrl /dev/nvmeN' will show the power state table and
'nvme get-feature -f 0x0c -H /dev/nvme0' will show the current APST
configuration.
This feature is quirked off on a known-buggy Samsung device.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-02-07 18:08:45 +00:00
|
|
|
/* Power saving configuration */
|
|
|
|
u64 ps_max_latency_us;
|
2017-06-26 20:39:54 +00:00
|
|
|
bool apst_enabled;
|
nvme: Enable autonomous power state transitions
NVMe devices can advertise multiple power states. These states can
be either "operational" (the device is fully functional but possibly
slow) or "non-operational" (the device is asleep until woken up).
Some devices can automatically enter a non-operational state when
idle for a specified amount of time and then automatically wake back
up when needed.
The hardware configuration is a table. For each state, an entry in
the table indicates the next deeper non-operational state, if any,
to autonomously transition to and the idle time required before
transitioning.
This patch teaches the driver to program APST so that each successive
non-operational state will be entered after an idle time equal to 100%
of the total latency (entry plus exit) associated with that state.
The maximum acceptable latency is controlled using dev_pm_qos
(e.g. power/pm_qos_latency_tolerance_us in sysfs); non-operational
states with total latency greater than this value will not be used.
As a special case, setting the latency tolerance to 0 will disable
APST entirely. On hardware without APST support, the sysfs file will
not be exposed.
The latency tolerance for newly-probed devices is set by the module
parameter nvme_core.default_ps_max_latency_us.
In theory, the device can expose "default" APST table, but this
doesn't seem to function correctly on my device (Samsung 950), nor
does it seem particularly useful. There is also an optional
mechanism by which a configuration can be "saved" so it will be
automatically loaded on reset. This can be configured from
userspace, but it doesn't seem useful to support in the driver.
On my laptop, enabling APST seems to save nearly 1W.
The hardware tables can be decoded in userspace with nvme-cli.
'nvme id-ctrl /dev/nvmeN' will show the power state table and
'nvme get-feature -f 0x0c -H /dev/nvme0' will show the current APST
configuration.
This feature is quirked off on a known-buggy Samsung device.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-02-07 18:08:45 +00:00
|
|
|
|
2017-09-11 16:09:28 +00:00
|
|
|
/* PCIe only: */
|
2017-05-12 15:16:10 +00:00
|
|
|
u32 hmpre;
|
|
|
|
u32 hmmin;
|
2017-09-11 16:09:28 +00:00
|
|
|
u32 hmminds;
|
|
|
|
u16 hmmaxd;
|
2017-05-12 15:16:10 +00:00
|
|
|
|
2016-06-13 14:45:26 +00:00
|
|
|
/* Fabrics only */
|
|
|
|
u32 ioccsz;
|
|
|
|
u32 iorcsz;
|
|
|
|
u16 icdoff;
|
|
|
|
u16 maxcmd;
|
2017-05-04 10:33:15 +00:00
|
|
|
int nr_reconnects;
|
2016-06-13 14:45:26 +00:00
|
|
|
struct nvmf_ctrl_options *opts;
|
2018-12-12 16:18:11 +00:00
|
|
|
|
|
|
|
struct page *discard_page;
|
|
|
|
unsigned long discard_page_busy;
|
2019-06-09 14:17:01 +00:00
|
|
|
|
|
|
|
struct nvme_fault_inject fault_inject;
|
2015-10-03 13:46:41 +00:00
|
|
|
};
|
|
|
|
|
2019-02-18 10:43:26 +00:00
|
|
|
enum nvme_iopolicy {
|
|
|
|
NVME_IOPOLICY_NUMA,
|
|
|
|
NVME_IOPOLICY_RR,
|
|
|
|
};
|
|
|
|
|
2017-11-09 12:48:55 +00:00
|
|
|
struct nvme_subsystem {
|
|
|
|
int instance;
|
|
|
|
struct device dev;
|
|
|
|
/*
|
|
|
|
* Because we unregister the device on the last put we need
|
|
|
|
* a separate refcount.
|
|
|
|
*/
|
|
|
|
struct kref ref;
|
|
|
|
struct list_head entry;
|
|
|
|
struct mutex lock;
|
|
|
|
struct list_head ctrls;
|
2017-11-09 12:50:43 +00:00
|
|
|
struct list_head nsheads;
|
2017-11-09 12:48:55 +00:00
|
|
|
char subnqn[NVMF_NQN_SIZE];
|
|
|
|
char serial[20];
|
|
|
|
char model[40];
|
|
|
|
char firmware_rev[8];
|
|
|
|
u8 cmic;
|
|
|
|
u16 vendor_id;
|
2019-06-28 16:53:31 +00:00
|
|
|
u16 awupf; /* 0's based awupf value. */
|
2017-11-09 12:50:43 +00:00
|
|
|
struct ida ns_ida;
|
2019-02-18 10:43:26 +00:00
|
|
|
#ifdef CONFIG_NVME_MULTIPATH
|
|
|
|
enum nvme_iopolicy iopolicy;
|
|
|
|
#endif
|
2017-11-09 12:48:55 +00:00
|
|
|
};
|
|
|
|
|
2017-11-09 12:50:16 +00:00
|
|
|
/*
|
|
|
|
* Container structure for uniqueue namespace identifiers.
|
|
|
|
*/
|
|
|
|
struct nvme_ns_ids {
|
|
|
|
u8 eui64[8];
|
|
|
|
u8 nguid[16];
|
|
|
|
uuid_t uuid;
|
|
|
|
};
|
|
|
|
|
2017-11-09 12:50:43 +00:00
|
|
|
/*
|
|
|
|
* Anchor structure for namespaces. There is one for each namespace in a
|
|
|
|
* NVMe subsystem that any of our controllers can see, and the namespace
|
|
|
|
* structure for each controller is chained of it. For private namespaces
|
|
|
|
* there is a 1:1 relation to our namespace structures, that is ->list
|
|
|
|
* only ever has a single entry for private namespaces.
|
|
|
|
*/
|
|
|
|
struct nvme_ns_head {
|
|
|
|
struct list_head list;
|
|
|
|
struct srcu_struct srcu;
|
|
|
|
struct nvme_subsystem *subsys;
|
|
|
|
unsigned ns_id;
|
|
|
|
struct nvme_ns_ids ids;
|
|
|
|
struct list_head entry;
|
|
|
|
struct kref ref;
|
|
|
|
int instance;
|
2018-09-11 07:51:29 +00:00
|
|
|
#ifdef CONFIG_NVME_MULTIPATH
|
|
|
|
struct gendisk *disk;
|
|
|
|
struct bio_list requeue_list;
|
|
|
|
spinlock_t requeue_lock;
|
|
|
|
struct work_struct requeue_work;
|
|
|
|
struct mutex lock;
|
|
|
|
struct nvme_ns __rcu *current_path[];
|
|
|
|
#endif
|
2017-11-09 12:50:43 +00:00
|
|
|
};
|
|
|
|
|
2015-10-03 13:46:41 +00:00
|
|
|
struct nvme_ns {
|
|
|
|
struct list_head list;
|
|
|
|
|
2015-11-26 09:06:56 +00:00
|
|
|
struct nvme_ctrl *ctrl;
|
2015-10-03 13:46:41 +00:00
|
|
|
struct request_queue *queue;
|
|
|
|
struct gendisk *disk;
|
2018-05-14 06:48:54 +00:00
|
|
|
#ifdef CONFIG_NVME_MULTIPATH
|
|
|
|
enum nvme_ana_state ana_state;
|
|
|
|
u32 ana_grpid;
|
|
|
|
#endif
|
2017-11-09 12:50:43 +00:00
|
|
|
struct list_head siblings;
|
2016-09-16 12:25:07 +00:00
|
|
|
struct nvm_dev *ndev;
|
2015-10-03 13:46:41 +00:00
|
|
|
struct kref kref;
|
2017-11-09 12:50:43 +00:00
|
|
|
struct nvme_ns_head *head;
|
2015-10-03 13:46:41 +00:00
|
|
|
|
|
|
|
int lba_shift;
|
|
|
|
u16 ms;
|
2017-06-27 18:03:06 +00:00
|
|
|
u16 sgs;
|
|
|
|
u32 sws;
|
2015-10-03 13:46:41 +00:00
|
|
|
bool ext;
|
|
|
|
u8 pi_type;
|
2016-02-24 16:15:54 +00:00
|
|
|
unsigned long flags;
|
2018-05-14 06:48:54 +00:00
|
|
|
#define NVME_NS_REMOVING 0
|
|
|
|
#define NVME_NS_DEAD 1
|
|
|
|
#define NVME_NS_ANA_PENDING 2
|
2017-08-16 13:47:37 +00:00
|
|
|
u16 noiob;
|
nvme: Add fault injection feature
Linux's fault injection framework provides a systematic way to support
error injection via debugfs in the /sys/kernel/debug directory. This
patch uses the framework to add error injection to NVMe driver. The
fault injection source code is stored in a separate file and only linked
if CONFIG_FAULT_INJECTION_DEBUG_FS kernel config is selected.
Once the error injection is enabled, NVME_SC_INVALID_OPCODE with no
retry will be injected into the nvme_end_request. Users can change
the default status code and no retry flag via debufs. Following example
shows how to enable and inject an error. For more examples, refer to
Documentation/fault-injection/nvme-fault-injection.txt
How to enable nvme fault injection:
First, enable CONFIG_FAULT_INJECTION_DEBUG_FS kernel config,
recompile the kernel. After booting up the kernel, do the
following.
How to inject an error:
mount /dev/nvme0n1 /mnt
echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/times
echo 100 > /sys/kernel/debug/nvme0n1/fault_inject/probability
cp a.file /mnt
Expected Result:
cp: cannot stat ‘/mnt/a.file’: Input/output error
Message from dmesg:
FAULT_INJECTION: forcing a failure.
name fault_inject, interval 1, probability 100, space 0, times 1
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.15.0-rc8+ #2
Hardware name: innotek GmbH VirtualBox/VirtualBox,
BIOS VirtualBox 12/01/2006
Call Trace:
<IRQ>
dump_stack+0x5c/0x7d
should_fail+0x148/0x170
nvme_should_fail+0x2f/0x50 [nvme_core]
nvme_process_cq+0xe7/0x1d0 [nvme]
nvme_irq+0x1e/0x40 [nvme]
__handle_irq_event_percpu+0x3a/0x190
handle_irq_event_percpu+0x30/0x70
handle_irq_event+0x36/0x60
handle_fasteoi_irq+0x78/0x120
handle_irq+0xa7/0x130
? tick_irq_enter+0xa8/0xc0
do_IRQ+0x43/0xc0
common_interrupt+0xa2/0xa2
</IRQ>
RIP: 0010:native_safe_halt+0x2/0x10
RSP: 0018:ffffffff82003e90 EFLAGS: 00000246 ORIG_RAX: ffffffffffffffdd
RAX: ffffffff817a10c0 RBX: ffffffff82012480 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 000000008e38ce64 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff82012480
R13: ffffffff82012480 R14: 0000000000000000 R15: 0000000000000000
? __sched_text_end+0x4/0x4
default_idle+0x18/0xf0
do_idle+0x150/0x1d0
cpu_startup_entry+0x6f/0x80
start_kernel+0x4c4/0x4e4
? set_init_arg+0x55/0x55
secondary_startup_64+0xa5/0xb0
print_req_error: I/O error, dev nvme0n1, sector 9240
EXT4-fs error (device nvme0n1): ext4_find_entry:1436:
inode #2: comm cp: reading directory lblock 0
Signed-off-by: Thomas Tai <thomas.tai@oracle.com>
Reviewed-by: Eric Saint-Etienne <eric.saint.etienne@oracle.com>
Signed-off-by: Karl Volz <karl.volz@oracle.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-02-08 18:38:29 +00:00
|
|
|
|
|
|
|
struct nvme_fault_inject fault_inject;
|
|
|
|
|
2015-10-03 13:46:41 +00:00
|
|
|
};
|
|
|
|
|
2015-11-26 09:06:56 +00:00
|
|
|
struct nvme_ctrl_ops {
|
2016-06-13 14:45:24 +00:00
|
|
|
const char *name;
|
2016-02-10 18:03:29 +00:00
|
|
|
struct module *module;
|
2017-05-20 13:14:44 +00:00
|
|
|
unsigned int flags;
|
|
|
|
#define NVME_F_FABRICS (1 << 0)
|
2017-05-20 13:14:45 +00:00
|
|
|
#define NVME_F_METADATA_SUPPORTED (1 << 1)
|
2018-10-04 21:27:44 +00:00
|
|
|
#define NVME_F_PCI_P2PDMA (1 << 2)
|
2015-11-26 09:06:56 +00:00
|
|
|
int (*reg_read32)(struct nvme_ctrl *ctrl, u32 off, u32 *val);
|
2015-11-28 14:03:49 +00:00
|
|
|
int (*reg_write32)(struct nvme_ctrl *ctrl, u32 off, u32 val);
|
2015-11-28 14:37:52 +00:00
|
|
|
int (*reg_read64)(struct nvme_ctrl *ctrl, u32 off, u64 *val);
|
2015-11-26 09:54:19 +00:00
|
|
|
void (*free_ctrl)(struct nvme_ctrl *ctrl);
|
2017-11-07 22:13:12 +00:00
|
|
|
void (*submit_async_event)(struct nvme_ctrl *ctrl);
|
2017-10-29 08:44:29 +00:00
|
|
|
void (*delete_ctrl)(struct nvme_ctrl *ctrl);
|
2016-06-13 14:45:24 +00:00
|
|
|
int (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size);
|
2015-10-03 13:46:41 +00:00
|
|
|
};
|
|
|
|
|
nvme: Add fault injection feature
Linux's fault injection framework provides a systematic way to support
error injection via debugfs in the /sys/kernel/debug directory. This
patch uses the framework to add error injection to NVMe driver. The
fault injection source code is stored in a separate file and only linked
if CONFIG_FAULT_INJECTION_DEBUG_FS kernel config is selected.
Once the error injection is enabled, NVME_SC_INVALID_OPCODE with no
retry will be injected into the nvme_end_request. Users can change
the default status code and no retry flag via debufs. Following example
shows how to enable and inject an error. For more examples, refer to
Documentation/fault-injection/nvme-fault-injection.txt
How to enable nvme fault injection:
First, enable CONFIG_FAULT_INJECTION_DEBUG_FS kernel config,
recompile the kernel. After booting up the kernel, do the
following.
How to inject an error:
mount /dev/nvme0n1 /mnt
echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/times
echo 100 > /sys/kernel/debug/nvme0n1/fault_inject/probability
cp a.file /mnt
Expected Result:
cp: cannot stat ‘/mnt/a.file’: Input/output error
Message from dmesg:
FAULT_INJECTION: forcing a failure.
name fault_inject, interval 1, probability 100, space 0, times 1
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.15.0-rc8+ #2
Hardware name: innotek GmbH VirtualBox/VirtualBox,
BIOS VirtualBox 12/01/2006
Call Trace:
<IRQ>
dump_stack+0x5c/0x7d
should_fail+0x148/0x170
nvme_should_fail+0x2f/0x50 [nvme_core]
nvme_process_cq+0xe7/0x1d0 [nvme]
nvme_irq+0x1e/0x40 [nvme]
__handle_irq_event_percpu+0x3a/0x190
handle_irq_event_percpu+0x30/0x70
handle_irq_event+0x36/0x60
handle_fasteoi_irq+0x78/0x120
handle_irq+0xa7/0x130
? tick_irq_enter+0xa8/0xc0
do_IRQ+0x43/0xc0
common_interrupt+0xa2/0xa2
</IRQ>
RIP: 0010:native_safe_halt+0x2/0x10
RSP: 0018:ffffffff82003e90 EFLAGS: 00000246 ORIG_RAX: ffffffffffffffdd
RAX: ffffffff817a10c0 RBX: ffffffff82012480 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 000000008e38ce64 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff82012480
R13: ffffffff82012480 R14: 0000000000000000 R15: 0000000000000000
? __sched_text_end+0x4/0x4
default_idle+0x18/0xf0
do_idle+0x150/0x1d0
cpu_startup_entry+0x6f/0x80
start_kernel+0x4c4/0x4e4
? set_init_arg+0x55/0x55
secondary_startup_64+0xa5/0xb0
print_req_error: I/O error, dev nvme0n1, sector 9240
EXT4-fs error (device nvme0n1): ext4_find_entry:1436:
inode #2: comm cp: reading directory lblock 0
Signed-off-by: Thomas Tai <thomas.tai@oracle.com>
Reviewed-by: Eric Saint-Etienne <eric.saint.etienne@oracle.com>
Signed-off-by: Karl Volz <karl.volz@oracle.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-02-08 18:38:29 +00:00
|
|
|
#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
|
2019-06-20 06:49:02 +00:00
|
|
|
void nvme_fault_inject_init(struct nvme_fault_inject *fault_inj,
|
|
|
|
const char *dev_name);
|
|
|
|
void nvme_fault_inject_fini(struct nvme_fault_inject *fault_inject);
|
nvme: Add fault injection feature
Linux's fault injection framework provides a systematic way to support
error injection via debugfs in the /sys/kernel/debug directory. This
patch uses the framework to add error injection to NVMe driver. The
fault injection source code is stored in a separate file and only linked
if CONFIG_FAULT_INJECTION_DEBUG_FS kernel config is selected.
Once the error injection is enabled, NVME_SC_INVALID_OPCODE with no
retry will be injected into the nvme_end_request. Users can change
the default status code and no retry flag via debufs. Following example
shows how to enable and inject an error. For more examples, refer to
Documentation/fault-injection/nvme-fault-injection.txt
How to enable nvme fault injection:
First, enable CONFIG_FAULT_INJECTION_DEBUG_FS kernel config,
recompile the kernel. After booting up the kernel, do the
following.
How to inject an error:
mount /dev/nvme0n1 /mnt
echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/times
echo 100 > /sys/kernel/debug/nvme0n1/fault_inject/probability
cp a.file /mnt
Expected Result:
cp: cannot stat ‘/mnt/a.file’: Input/output error
Message from dmesg:
FAULT_INJECTION: forcing a failure.
name fault_inject, interval 1, probability 100, space 0, times 1
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.15.0-rc8+ #2
Hardware name: innotek GmbH VirtualBox/VirtualBox,
BIOS VirtualBox 12/01/2006
Call Trace:
<IRQ>
dump_stack+0x5c/0x7d
should_fail+0x148/0x170
nvme_should_fail+0x2f/0x50 [nvme_core]
nvme_process_cq+0xe7/0x1d0 [nvme]
nvme_irq+0x1e/0x40 [nvme]
__handle_irq_event_percpu+0x3a/0x190
handle_irq_event_percpu+0x30/0x70
handle_irq_event+0x36/0x60
handle_fasteoi_irq+0x78/0x120
handle_irq+0xa7/0x130
? tick_irq_enter+0xa8/0xc0
do_IRQ+0x43/0xc0
common_interrupt+0xa2/0xa2
</IRQ>
RIP: 0010:native_safe_halt+0x2/0x10
RSP: 0018:ffffffff82003e90 EFLAGS: 00000246 ORIG_RAX: ffffffffffffffdd
RAX: ffffffff817a10c0 RBX: ffffffff82012480 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 000000008e38ce64 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff82012480
R13: ffffffff82012480 R14: 0000000000000000 R15: 0000000000000000
? __sched_text_end+0x4/0x4
default_idle+0x18/0xf0
do_idle+0x150/0x1d0
cpu_startup_entry+0x6f/0x80
start_kernel+0x4c4/0x4e4
? set_init_arg+0x55/0x55
secondary_startup_64+0xa5/0xb0
print_req_error: I/O error, dev nvme0n1, sector 9240
EXT4-fs error (device nvme0n1): ext4_find_entry:1436:
inode #2: comm cp: reading directory lblock 0
Signed-off-by: Thomas Tai <thomas.tai@oracle.com>
Reviewed-by: Eric Saint-Etienne <eric.saint.etienne@oracle.com>
Signed-off-by: Karl Volz <karl.volz@oracle.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-02-08 18:38:29 +00:00
|
|
|
void nvme_should_fail(struct request *req);
|
|
|
|
#else
|
2019-06-20 06:49:02 +00:00
|
|
|
static inline void nvme_fault_inject_init(struct nvme_fault_inject *fault_inj,
|
|
|
|
const char *dev_name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline void nvme_fault_inject_fini(struct nvme_fault_inject *fault_inj)
|
|
|
|
{
|
|
|
|
}
|
nvme: Add fault injection feature
Linux's fault injection framework provides a systematic way to support
error injection via debugfs in the /sys/kernel/debug directory. This
patch uses the framework to add error injection to NVMe driver. The
fault injection source code is stored in a separate file and only linked
if CONFIG_FAULT_INJECTION_DEBUG_FS kernel config is selected.
Once the error injection is enabled, NVME_SC_INVALID_OPCODE with no
retry will be injected into the nvme_end_request. Users can change
the default status code and no retry flag via debufs. Following example
shows how to enable and inject an error. For more examples, refer to
Documentation/fault-injection/nvme-fault-injection.txt
How to enable nvme fault injection:
First, enable CONFIG_FAULT_INJECTION_DEBUG_FS kernel config,
recompile the kernel. After booting up the kernel, do the
following.
How to inject an error:
mount /dev/nvme0n1 /mnt
echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/times
echo 100 > /sys/kernel/debug/nvme0n1/fault_inject/probability
cp a.file /mnt
Expected Result:
cp: cannot stat ‘/mnt/a.file’: Input/output error
Message from dmesg:
FAULT_INJECTION: forcing a failure.
name fault_inject, interval 1, probability 100, space 0, times 1
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.15.0-rc8+ #2
Hardware name: innotek GmbH VirtualBox/VirtualBox,
BIOS VirtualBox 12/01/2006
Call Trace:
<IRQ>
dump_stack+0x5c/0x7d
should_fail+0x148/0x170
nvme_should_fail+0x2f/0x50 [nvme_core]
nvme_process_cq+0xe7/0x1d0 [nvme]
nvme_irq+0x1e/0x40 [nvme]
__handle_irq_event_percpu+0x3a/0x190
handle_irq_event_percpu+0x30/0x70
handle_irq_event+0x36/0x60
handle_fasteoi_irq+0x78/0x120
handle_irq+0xa7/0x130
? tick_irq_enter+0xa8/0xc0
do_IRQ+0x43/0xc0
common_interrupt+0xa2/0xa2
</IRQ>
RIP: 0010:native_safe_halt+0x2/0x10
RSP: 0018:ffffffff82003e90 EFLAGS: 00000246 ORIG_RAX: ffffffffffffffdd
RAX: ffffffff817a10c0 RBX: ffffffff82012480 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 000000008e38ce64 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff82012480
R13: ffffffff82012480 R14: 0000000000000000 R15: 0000000000000000
? __sched_text_end+0x4/0x4
default_idle+0x18/0xf0
do_idle+0x150/0x1d0
cpu_startup_entry+0x6f/0x80
start_kernel+0x4c4/0x4e4
? set_init_arg+0x55/0x55
secondary_startup_64+0xa5/0xb0
print_req_error: I/O error, dev nvme0n1, sector 9240
EXT4-fs error (device nvme0n1): ext4_find_entry:1436:
inode #2: comm cp: reading directory lblock 0
Signed-off-by: Thomas Tai <thomas.tai@oracle.com>
Reviewed-by: Eric Saint-Etienne <eric.saint.etienne@oracle.com>
Signed-off-by: Karl Volz <karl.volz@oracle.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-02-08 18:38:29 +00:00
|
|
|
static inline void nvme_should_fail(struct request *req) {}
|
|
|
|
#endif
|
|
|
|
|
2015-11-28 14:40:19 +00:00
|
|
|
static inline int nvme_reset_subsystem(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
if (!ctrl->subsystem)
|
|
|
|
return -ENOTTY;
|
|
|
|
return ctrl->ops->reg_write32(ctrl, NVME_REG_NSSR, 0x4E564D65);
|
|
|
|
}
|
|
|
|
|
2015-10-03 13:46:41 +00:00
|
|
|
static inline u64 nvme_block_nr(struct nvme_ns *ns, sector_t sector)
|
|
|
|
{
|
|
|
|
return (sector >> (ns->lba_shift - 9));
|
|
|
|
}
|
|
|
|
|
2017-04-20 14:02:57 +00:00
|
|
|
static inline void nvme_end_request(struct request *req, __le16 status,
|
|
|
|
union nvme_result result)
|
2015-10-16 05:58:39 +00:00
|
|
|
{
|
2017-04-20 14:02:57 +00:00
|
|
|
struct nvme_request *rq = nvme_req(req);
|
2015-10-16 05:58:39 +00:00
|
|
|
|
2017-04-20 14:02:57 +00:00
|
|
|
rq->status = le16_to_cpu(status) >> 1;
|
|
|
|
rq->result = result;
|
nvme: Add fault injection feature
Linux's fault injection framework provides a systematic way to support
error injection via debugfs in the /sys/kernel/debug directory. This
patch uses the framework to add error injection to NVMe driver. The
fault injection source code is stored in a separate file and only linked
if CONFIG_FAULT_INJECTION_DEBUG_FS kernel config is selected.
Once the error injection is enabled, NVME_SC_INVALID_OPCODE with no
retry will be injected into the nvme_end_request. Users can change
the default status code and no retry flag via debufs. Following example
shows how to enable and inject an error. For more examples, refer to
Documentation/fault-injection/nvme-fault-injection.txt
How to enable nvme fault injection:
First, enable CONFIG_FAULT_INJECTION_DEBUG_FS kernel config,
recompile the kernel. After booting up the kernel, do the
following.
How to inject an error:
mount /dev/nvme0n1 /mnt
echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/times
echo 100 > /sys/kernel/debug/nvme0n1/fault_inject/probability
cp a.file /mnt
Expected Result:
cp: cannot stat ‘/mnt/a.file’: Input/output error
Message from dmesg:
FAULT_INJECTION: forcing a failure.
name fault_inject, interval 1, probability 100, space 0, times 1
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.15.0-rc8+ #2
Hardware name: innotek GmbH VirtualBox/VirtualBox,
BIOS VirtualBox 12/01/2006
Call Trace:
<IRQ>
dump_stack+0x5c/0x7d
should_fail+0x148/0x170
nvme_should_fail+0x2f/0x50 [nvme_core]
nvme_process_cq+0xe7/0x1d0 [nvme]
nvme_irq+0x1e/0x40 [nvme]
__handle_irq_event_percpu+0x3a/0x190
handle_irq_event_percpu+0x30/0x70
handle_irq_event+0x36/0x60
handle_fasteoi_irq+0x78/0x120
handle_irq+0xa7/0x130
? tick_irq_enter+0xa8/0xc0
do_IRQ+0x43/0xc0
common_interrupt+0xa2/0xa2
</IRQ>
RIP: 0010:native_safe_halt+0x2/0x10
RSP: 0018:ffffffff82003e90 EFLAGS: 00000246 ORIG_RAX: ffffffffffffffdd
RAX: ffffffff817a10c0 RBX: ffffffff82012480 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 000000008e38ce64 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff82012480
R13: ffffffff82012480 R14: 0000000000000000 R15: 0000000000000000
? __sched_text_end+0x4/0x4
default_idle+0x18/0xf0
do_idle+0x150/0x1d0
cpu_startup_entry+0x6f/0x80
start_kernel+0x4c4/0x4e4
? set_init_arg+0x55/0x55
secondary_startup_64+0xa5/0xb0
print_req_error: I/O error, dev nvme0n1, sector 9240
EXT4-fs error (device nvme0n1): ext4_find_entry:1436:
inode #2: comm cp: reading directory lblock 0
Signed-off-by: Thomas Tai <thomas.tai@oracle.com>
Reviewed-by: Eric Saint-Etienne <eric.saint.etienne@oracle.com>
Signed-off-by: Karl Volz <karl.volz@oracle.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-02-08 18:38:29 +00:00
|
|
|
/* inject error when permitted by fault injection framework */
|
|
|
|
nvme_should_fail(req);
|
2017-04-20 14:03:09 +00:00
|
|
|
blk_mq_complete_request(req);
|
2015-11-28 14:41:58 +00:00
|
|
|
}
|
|
|
|
|
2017-10-18 11:25:42 +00:00
|
|
|
static inline void nvme_get_ctrl(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
get_device(ctrl->device);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void nvme_put_ctrl(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
put_device(ctrl->device);
|
|
|
|
}
|
|
|
|
|
2017-03-30 11:41:32 +00:00
|
|
|
void nvme_complete_rq(struct request *req);
|
2018-11-08 17:24:07 +00:00
|
|
|
bool nvme_cancel_request(struct request *req, void *data, bool reserved);
|
2016-04-26 11:51:57 +00:00
|
|
|
bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
|
|
|
|
enum nvme_ctrl_state new_state);
|
2019-09-04 16:06:11 +00:00
|
|
|
bool nvme_wait_reset(struct nvme_ctrl *ctrl);
|
2019-07-23 00:06:54 +00:00
|
|
|
int nvme_disable_ctrl(struct nvme_ctrl *ctrl);
|
2019-07-23 00:06:53 +00:00
|
|
|
int nvme_enable_ctrl(struct nvme_ctrl *ctrl);
|
2015-11-28 14:03:49 +00:00
|
|
|
int nvme_shutdown_ctrl(struct nvme_ctrl *ctrl);
|
2015-11-28 14:40:19 +00:00
|
|
|
int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
|
|
|
|
const struct nvme_ctrl_ops *ops, unsigned long quirks);
|
2015-11-28 14:41:02 +00:00
|
|
|
void nvme_uninit_ctrl(struct nvme_ctrl *ctrl);
|
2017-07-02 07:56:43 +00:00
|
|
|
void nvme_start_ctrl(struct nvme_ctrl *ctrl);
|
|
|
|
void nvme_stop_ctrl(struct nvme_ctrl *ctrl);
|
2015-11-26 09:54:19 +00:00
|
|
|
void nvme_put_ctrl(struct nvme_ctrl *ctrl);
|
2015-11-28 14:37:52 +00:00
|
|
|
int nvme_init_identify(struct nvme_ctrl *ctrl);
|
2015-11-28 14:39:07 +00:00
|
|
|
|
|
|
|
void nvme_remove_namespaces(struct nvme_ctrl *ctrl);
|
2015-11-26 09:54:19 +00:00
|
|
|
|
2017-02-17 12:59:39 +00:00
|
|
|
int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len,
|
|
|
|
bool send);
|
2017-02-03 19:50:32 +00:00
|
|
|
|
2016-11-10 15:32:34 +00:00
|
|
|
void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,
|
2018-05-17 16:31:46 +00:00
|
|
|
volatile union nvme_result *res);
|
2016-04-26 11:52:00 +00:00
|
|
|
|
2016-01-04 16:10:57 +00:00
|
|
|
void nvme_stop_queues(struct nvme_ctrl *ctrl);
|
|
|
|
void nvme_start_queues(struct nvme_ctrl *ctrl);
|
2016-02-24 16:15:56 +00:00
|
|
|
void nvme_kill_queues(struct nvme_ctrl *ctrl);
|
2019-05-14 20:46:09 +00:00
|
|
|
void nvme_sync_queues(struct nvme_ctrl *ctrl);
|
2017-03-01 19:22:12 +00:00
|
|
|
void nvme_unfreeze(struct nvme_ctrl *ctrl);
|
|
|
|
void nvme_wait_freeze(struct nvme_ctrl *ctrl);
|
|
|
|
void nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout);
|
|
|
|
void nvme_start_freeze(struct nvme_ctrl *ctrl);
|
2015-12-24 14:26:59 +00:00
|
|
|
|
2016-06-13 14:45:23 +00:00
|
|
|
#define NVME_QID_ANY -1
|
2015-11-20 08:00:02 +00:00
|
|
|
struct request *nvme_alloc_request(struct request_queue *q,
|
2017-11-09 18:49:59 +00:00
|
|
|
struct nvme_command *cmd, blk_mq_req_flags_t flags, int qid);
|
2018-07-29 21:15:33 +00:00
|
|
|
void nvme_cleanup_cmd(struct request *req);
|
2017-06-03 07:38:05 +00:00
|
|
|
blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req,
|
2016-04-12 19:10:14 +00:00
|
|
|
struct nvme_command *cmd);
|
2015-10-03 13:46:41 +00:00
|
|
|
int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
|
|
|
|
void *buf, unsigned bufflen);
|
|
|
|
int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
|
2016-11-10 15:32:33 +00:00
|
|
|
union nvme_result *result, void *buffer, unsigned bufflen,
|
2017-11-09 18:49:59 +00:00
|
|
|
unsigned timeout, int qid, int at_head,
|
2018-12-14 19:06:07 +00:00
|
|
|
blk_mq_req_flags_t flags, bool poll);
|
2019-05-26 16:29:01 +00:00
|
|
|
int nvme_set_features(struct nvme_ctrl *dev, unsigned int fid,
|
|
|
|
unsigned int dword11, void *buffer, size_t buflen,
|
|
|
|
u32 *result);
|
|
|
|
int nvme_get_features(struct nvme_ctrl *dev, unsigned int fid,
|
|
|
|
unsigned int dword11, void *buffer, size_t buflen,
|
|
|
|
u32 *result);
|
2015-11-26 10:09:06 +00:00
|
|
|
int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count);
|
2016-06-13 14:45:28 +00:00
|
|
|
void nvme_stop_keep_alive(struct nvme_ctrl *ctrl);
|
2017-06-15 13:41:08 +00:00
|
|
|
int nvme_reset_ctrl(struct nvme_ctrl *ctrl);
|
2018-01-14 10:39:00 +00:00
|
|
|
int nvme_reset_ctrl_sync(struct nvme_ctrl *ctrl);
|
2019-09-04 16:06:11 +00:00
|
|
|
int nvme_try_sched_reset(struct nvme_ctrl *ctrl);
|
2017-10-29 08:44:29 +00:00
|
|
|
int nvme_delete_ctrl(struct nvme_ctrl *ctrl);
|
2015-10-03 13:46:41 +00:00
|
|
|
|
2018-06-06 12:39:00 +00:00
|
|
|
int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp,
|
|
|
|
void *log, size_t size, u64 offset);
|
2018-03-21 19:27:07 +00:00
|
|
|
|
2018-09-28 06:17:20 +00:00
|
|
|
extern const struct attribute_group *nvme_ns_id_attr_groups[];
|
2017-11-02 11:59:30 +00:00
|
|
|
extern const struct block_device_operations nvme_ns_head_ops;
|
|
|
|
|
|
|
|
#ifdef CONFIG_NVME_MULTIPATH
|
2019-07-23 05:41:20 +00:00
|
|
|
static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
return ctrl->ana_log_buf != NULL;
|
|
|
|
}
|
|
|
|
|
2019-07-31 18:00:26 +00:00
|
|
|
void nvme_mpath_unfreeze(struct nvme_subsystem *subsys);
|
|
|
|
void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys);
|
|
|
|
void nvme_mpath_start_freeze(struct nvme_subsystem *subsys);
|
2018-04-26 20:22:41 +00:00
|
|
|
void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
|
|
|
|
struct nvme_ctrl *ctrl, int *flags);
|
2017-11-02 11:59:30 +00:00
|
|
|
void nvme_failover_req(struct request *req);
|
|
|
|
void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl);
|
|
|
|
int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl,struct nvme_ns_head *head);
|
2018-05-14 06:48:54 +00:00
|
|
|
void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id);
|
2017-11-02 11:59:30 +00:00
|
|
|
void nvme_mpath_remove_disk(struct nvme_ns_head *head);
|
2018-05-14 06:48:54 +00:00
|
|
|
int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id);
|
|
|
|
void nvme_mpath_uninit(struct nvme_ctrl *ctrl);
|
|
|
|
void nvme_mpath_stop(struct nvme_ctrl *ctrl);
|
2019-07-25 18:56:57 +00:00
|
|
|
bool nvme_mpath_clear_current_path(struct nvme_ns *ns);
|
|
|
|
void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl);
|
2017-11-02 11:59:30 +00:00
|
|
|
struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);
|
2017-12-21 13:07:27 +00:00
|
|
|
|
|
|
|
static inline void nvme_mpath_check_last_path(struct nvme_ns *ns)
|
|
|
|
{
|
|
|
|
struct nvme_ns_head *head = ns->head;
|
|
|
|
|
|
|
|
if (head->disk && list_empty(&head->list))
|
|
|
|
kblockd_schedule_work(&head->requeue_work);
|
|
|
|
}
|
|
|
|
|
2019-07-24 13:47:55 +00:00
|
|
|
static inline void nvme_trace_bio_complete(struct request *req,
|
|
|
|
blk_status_t status)
|
|
|
|
{
|
|
|
|
struct nvme_ns *ns = req->q->queuedata;
|
|
|
|
|
|
|
|
if (req->cmd_flags & REQ_NVME_MPATH)
|
|
|
|
trace_block_bio_complete(ns->head->disk->queue,
|
|
|
|
req->bio, status);
|
|
|
|
}
|
|
|
|
|
2018-05-14 06:48:54 +00:00
|
|
|
extern struct device_attribute dev_attr_ana_grpid;
|
|
|
|
extern struct device_attribute dev_attr_ana_state;
|
2019-02-18 10:43:26 +00:00
|
|
|
extern struct device_attribute subsys_attr_iopolicy;
|
2018-05-14 06:48:54 +00:00
|
|
|
|
2017-11-02 11:59:30 +00:00
|
|
|
#else
|
2018-05-14 06:48:54 +00:00
|
|
|
static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2018-04-26 20:22:41 +00:00
|
|
|
/*
|
|
|
|
* Without the multipath code enabled, multiple controller per subsystems are
|
|
|
|
* visible as devices and thus we cannot use the subsystem instance.
|
|
|
|
*/
|
|
|
|
static inline void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
|
|
|
|
struct nvme_ctrl *ctrl, int *flags)
|
|
|
|
{
|
|
|
|
sprintf(disk_name, "nvme%dn%d", ctrl->instance, ns->head->instance);
|
|
|
|
}
|
|
|
|
|
2017-11-02 11:59:30 +00:00
|
|
|
static inline void nvme_failover_req(struct request *req)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl,
|
|
|
|
struct nvme_ns_head *head)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2018-05-14 06:48:54 +00:00
|
|
|
static inline void nvme_mpath_add_disk(struct nvme_ns *ns,
|
|
|
|
struct nvme_id_ns *id)
|
2017-11-02 11:59:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline void nvme_mpath_remove_disk(struct nvme_ns_head *head)
|
|
|
|
{
|
|
|
|
}
|
2019-07-25 18:56:57 +00:00
|
|
|
static inline bool nvme_mpath_clear_current_path(struct nvme_ns *ns)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
static inline void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl)
|
2017-12-21 13:07:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline void nvme_mpath_check_last_path(struct nvme_ns *ns)
|
2017-11-02 11:59:30 +00:00
|
|
|
{
|
|
|
|
}
|
2019-07-24 13:47:55 +00:00
|
|
|
static inline void nvme_trace_bio_complete(struct request *req,
|
|
|
|
blk_status_t status)
|
|
|
|
{
|
|
|
|
}
|
2018-05-14 06:48:54 +00:00
|
|
|
static inline int nvme_mpath_init(struct nvme_ctrl *ctrl,
|
|
|
|
struct nvme_id_ctrl *id)
|
|
|
|
{
|
2018-11-20 15:57:54 +00:00
|
|
|
if (ctrl->subsys->cmic & (1 << 3))
|
|
|
|
dev_warn(ctrl->device,
|
|
|
|
"Please enable CONFIG_NVME_MULTIPATH for full support of multi-port devices.\n");
|
2018-05-14 06:48:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline void nvme_mpath_stop(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
}
|
2019-07-31 18:00:26 +00:00
|
|
|
static inline void nvme_mpath_unfreeze(struct nvme_subsystem *subsys)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline void nvme_mpath_start_freeze(struct nvme_subsystem *subsys)
|
|
|
|
{
|
|
|
|
}
|
2017-11-02 11:59:30 +00:00
|
|
|
#endif /* CONFIG_NVME_MULTIPATH */
|
|
|
|
|
2015-11-28 15:49:22 +00:00
|
|
|
#ifdef CONFIG_NVM
|
2016-11-28 21:38:53 +00:00
|
|
|
int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node);
|
2016-09-16 12:25:07 +00:00
|
|
|
void nvme_nvm_unregister(struct nvme_ns *ns);
|
2018-09-28 06:17:20 +00:00
|
|
|
extern const struct attribute_group nvme_nvm_attr_group;
|
2017-01-31 12:17:16 +00:00
|
|
|
int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, unsigned long arg);
|
2015-11-28 15:49:22 +00:00
|
|
|
#else
|
2016-09-16 12:25:07 +00:00
|
|
|
static inline int nvme_nvm_register(struct nvme_ns *ns, char *disk_name,
|
2016-11-28 21:38:53 +00:00
|
|
|
int node)
|
2015-11-28 15:49:22 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-09-16 12:25:07 +00:00
|
|
|
static inline void nvme_nvm_unregister(struct nvme_ns *ns) {};
|
2017-01-31 12:17:16 +00:00
|
|
|
static inline int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd,
|
|
|
|
unsigned long arg)
|
|
|
|
{
|
|
|
|
return -ENOTTY;
|
|
|
|
}
|
2016-11-28 21:38:53 +00:00
|
|
|
#endif /* CONFIG_NVM */
|
|
|
|
|
2016-09-16 12:25:08 +00:00
|
|
|
static inline struct nvme_ns *nvme_get_ns_from_dev(struct device *dev)
|
|
|
|
{
|
|
|
|
return dev_to_disk(dev)->private_data;
|
|
|
|
}
|
2015-10-29 08:57:29 +00:00
|
|
|
|
2015-10-03 13:46:41 +00:00
|
|
|
#endif /* _NVME_H */
|