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>
|
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>
|
2020-05-19 14:05:51 +00:00
|
|
|
#include <linux/t10-pi.h>
|
2023-12-18 16:59:53 +00:00
|
|
|
#include <linux/ratelimit_types.h>
|
2015-10-03 13:46:41 +00:00
|
|
|
|
2019-07-24 13:47:55 +00:00
|
|
|
#include <trace/events/block.h>
|
|
|
|
|
2023-04-07 20:05:42 +00:00
|
|
|
extern const struct pr_ops nvme_pr_ops;
|
|
|
|
|
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;
|
2020-11-10 00:33:45 +00:00
|
|
|
#define NVME_ADMIN_TIMEOUT (admin_timeout * HZ)
|
2015-11-26 08:08:36 +00:00
|
|
|
|
2016-06-13 14:45:28 +00:00
|
|
|
#define NVME_DEFAULT_KATO 5
|
|
|
|
|
2019-11-24 16:38:30 +00:00
|
|
|
#ifdef CONFIG_ARCH_NO_SG_CHAIN
|
|
|
|
#define NVME_INLINE_SG_CNT 0
|
2020-05-19 14:05:54 +00:00
|
|
|
#define NVME_INLINE_METADATA_SG_CNT 0
|
2019-11-24 16:38:30 +00:00
|
|
|
#else
|
|
|
|
#define NVME_INLINE_SG_CNT 2
|
2020-05-19 14:05:54 +00:00
|
|
|
#define NVME_INLINE_METADATA_SG_CNT 1
|
2019-11-24 16:38:30 +00:00
|
|
|
#endif
|
|
|
|
|
2020-07-17 00:51:37 +00:00
|
|
|
/*
|
|
|
|
* Default to a 4K page size, with the intention to update this
|
|
|
|
* path in the future to accommodate architectures with differing
|
|
|
|
* kernel and IO page sizes.
|
|
|
|
*/
|
|
|
|
#define NVME_CTRL_PAGE_SHIFT 12
|
|
|
|
#define NVME_CTRL_PAGE_SIZE (1 << NVME_CTRL_PAGE_SHIFT)
|
|
|
|
|
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;
|
2024-06-25 12:26:05 +00:00
|
|
|
extern struct mutex nvme_subsystems_lock;
|
2017-06-07 18:31:55 +00:00
|
|
|
|
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
|
|
|
|
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),
|
2019-11-14 15:40:01 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't change the value of the temperature threshold feature
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_NO_TEMP_THRESH_CHANGE = (1 << 14),
|
2020-07-28 11:09:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The controller doesn't handle the Identify Namespace
|
|
|
|
* Identification Descriptor list subcommand despite claiming
|
|
|
|
* NVMe 1.3 compliance.
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_NO_NS_DESC_LIST = (1 << 15),
|
2021-02-10 00:39:42 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The controller does not properly handle DMA addresses over
|
|
|
|
* 48 bits.
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_DMA_ADDRESS_BITS_48 = (1 << 16),
|
2021-09-27 15:43:06 +00:00
|
|
|
|
|
|
|
/*
|
2022-06-04 14:32:54 +00:00
|
|
|
* The controller requires the command_id value be limited, so skip
|
2021-09-27 15:43:06 +00:00
|
|
|
* encoding the generation sequence number.
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_SKIP_CID_GEN = (1 << 17),
|
2022-04-11 06:05:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Reports garbage in the namespace identifiers (eui64, nguid, uuid).
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_BOGUS_NID = (1 << 18),
|
2023-04-25 19:58:54 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* No temperature thresholds for channels other than 0 (Composite).
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_NO_SECONDARY_TEMP_THRESH = (1 << 19),
|
2023-09-20 08:52:10 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Disables simple suspend/resume path.
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_FORCE_NO_SIMPLE_SUSPEND = (1 << 20),
|
2024-04-22 16:28:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* MSI (but not MSI-X) interrupts are broken and never fire.
|
|
|
|
*/
|
|
|
|
NVME_QUIRK_BROKEN_MSI = (1 << 21),
|
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;
|
2021-06-16 21:19:36 +00:00
|
|
|
u8 genctr;
|
2017-04-05 17:18:11 +00:00
|
|
|
u8 retries;
|
2017-04-20 14:02:57 +00:00
|
|
|
u8 flags;
|
|
|
|
u16 status;
|
2022-11-29 14:43:19 +00:00
|
|
|
#ifdef CONFIG_NVME_MULTIPATH
|
|
|
|
unsigned long start_time;
|
|
|
|
#endif
|
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),
|
2022-11-29 14:43:19 +00:00
|
|
|
NVME_MPATH_IO_STATS = (1 << 2),
|
2024-06-25 12:26:05 +00:00
|
|
|
NVME_MPATH_CNT_ACTIVE = (1 << 3),
|
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)
|
|
|
|
{
|
2020-10-15 18:36:29 +00:00
|
|
|
if (!req->q->queuedata)
|
2018-06-29 22:50:01 +00:00
|
|
|
return 0;
|
2020-10-27 08:15:16 +00:00
|
|
|
|
|
|
|
return req->mq_hctx->queue_num + 1;
|
2018-06-29 22:50:01 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2020-07-22 23:32:18 +00:00
|
|
|
/*
|
|
|
|
* enum nvme_ctrl_state: Controller state
|
|
|
|
*
|
|
|
|
* @NVME_CTRL_NEW: New controller just allocated, initial state
|
|
|
|
* @NVME_CTRL_LIVE: Controller is connected and I/O capable
|
|
|
|
* @NVME_CTRL_RESETTING: Controller is resetting (or scheduled reset)
|
|
|
|
* @NVME_CTRL_CONNECTING: Controller is disconnected, now connecting the
|
|
|
|
* transport
|
|
|
|
* @NVME_CTRL_DELETING: Controller is deleting (or scheduled deletion)
|
2020-07-22 23:32:19 +00:00
|
|
|
* @NVME_CTRL_DELETING_NOIO: Controller is deleting and I/O is not
|
|
|
|
* disabled/failed immediately. This state comes
|
|
|
|
* after all async event processing took place and
|
|
|
|
* before ns removal and the controller deletion
|
|
|
|
* progress
|
2020-07-22 23:32:18 +00:00
|
|
|
* @NVME_CTRL_DEAD: Controller is non-present/unresponsive during
|
|
|
|
* shutdown or removal. In this case we forcibly
|
|
|
|
* kill all inflight I/O as they have no chance to
|
|
|
|
* complete
|
|
|
|
*/
|
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,
|
2020-07-22 23:32:19 +00:00
|
|
|
NVME_CTRL_DELETING_NOIO,
|
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
|
|
|
|
};
|
|
|
|
|
2022-09-22 08:15:36 +00:00
|
|
|
enum nvme_ctrl_flags {
|
|
|
|
NVME_CTRL_FAILFAST_EXPIRED = 0,
|
|
|
|
NVME_CTRL_ADMIN_Q_STOPPED = 1,
|
2022-09-22 08:15:37 +00:00
|
|
|
NVME_CTRL_STARTED_ONCE = 2,
|
2022-11-01 15:00:50 +00:00
|
|
|
NVME_CTRL_STOPPED = 3,
|
2023-05-30 15:18:20 +00:00
|
|
|
NVME_CTRL_SKIP_ID_CNS_CS = 4,
|
2023-06-15 09:49:03 +00:00
|
|
|
NVME_CTRL_DIRTY_CAPABILITY = 5,
|
2023-11-30 02:13:37 +00:00
|
|
|
NVME_CTRL_FROZEN = 6,
|
2022-09-22 08:15:36 +00:00
|
|
|
};
|
|
|
|
|
2015-11-26 09:06:56 +00:00
|
|
|
struct nvme_ctrl {
|
2018-11-02 17:28:15 +00:00
|
|
|
bool comp_seen;
|
2017-02-22 20:32:36 +00:00
|
|
|
bool identified;
|
2024-01-30 00:19:38 +00:00
|
|
|
bool passthru_err_log_enabled;
|
2023-05-01 12:40:26 +00:00
|
|
|
enum nvme_ctrl_state state;
|
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;
|
2024-05-21 13:41:45 +00:00
|
|
|
struct mutex namespaces_lock;
|
|
|
|
struct srcu_struct srcu;
|
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 */
|
2021-01-19 06:43:18 +00:00
|
|
|
#ifdef CONFIG_NVME_HWMON
|
|
|
|
struct device *hwmon_device;
|
|
|
|
#endif
|
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
|
|
|
|
2017-07-12 10:40:40 +00:00
|
|
|
u16 mtfa;
|
2023-05-01 12:40:26 +00:00
|
|
|
u32 ctrl_config;
|
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-10-03 13:46:41 +00:00
|
|
|
u32 max_hw_sectors;
|
2018-06-21 15:49:37 +00:00
|
|
|
u32 max_segments;
|
2020-05-19 14:05:52 +00:00
|
|
|
u32 max_integrity_segments;
|
2021-03-24 23:18:05 +00:00
|
|
|
u32 max_zeroes_sectors;
|
2020-06-29 19:06:41 +00:00
|
|
|
#ifdef CONFIG_BLK_DEV_ZONED
|
|
|
|
u32 max_zone_append;
|
|
|
|
#endif
|
2018-11-27 16:40:57 +00:00
|
|
|
u16 crdt[3];
|
2015-10-03 13:46:41 +00:00
|
|
|
u16 oncs;
|
2023-12-26 08:58:44 +00:00
|
|
|
u8 dmrl;
|
2022-04-29 04:52:43 +00:00
|
|
|
u32 dmrsl;
|
2017-02-17 12:59:40 +00:00
|
|
|
u16 oacs;
|
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;
|
2019-11-06 14:35:18 +00:00
|
|
|
u16 wctemp;
|
|
|
|
u16 cctemp;
|
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;
|
2020-09-22 21:05:29 +00:00
|
|
|
struct xarray cels;
|
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;
|
2020-11-24 18:34:59 +00:00
|
|
|
struct delayed_work failfast_work;
|
2018-01-11 21:38:15 +00:00
|
|
|
struct nvme_command ka_cmd;
|
nvme: check IO start time when deciding to defer KA
When a command completes, we set a flag which will skip sending a
keep alive at the next run of nvme_keep_alive_work when TBKAS is on.
However, if the command was submitted long ago, it's possible that
the controller may have also restarted its keep alive timer (as a
result of receiving the command) long ago. The following trace
demonstrates the issue, assuming TBKAS is on and KATO = 8 for
simplicity:
1. t = 0: submit I/O commands A, B, C, D, E
2. t = 0.5: commands A, B, C, D, E reach controller, restart its keep
alive timer
3. t = 1: A completes
4. t = 2: run nvme_keep_alive_work, see recent completion, do nothing
5. t = 3: B completes
6. t = 4: run nvme_keep_alive_work, see recent completion, do nothing
7. t = 5: C completes
8. t = 6: run nvme_keep_alive_work, see recent completion, do nothing
9. t = 7: D completes
10. t = 8: run nvme_keep_alive_work, see recent completion, do nothing
11. t = 9: E completes
At this point, 8.5 seconds have passed without restarting the
controller's keep alive timer, so the controller will detect a keep
alive timeout.
Fix this by checking the IO start time when deciding to defer sending a
keep alive command. Only set comp_seen if the command started after the
most recent run of nvme_keep_alive_work. With this change, the
completions of B, C, and D will not set comp_seen and the run of
nvme_keep_alive_work at t = 4 will send a keep alive.
Reported-by: Costa Sapuntzakis <costa@purestorage.com>
Reported-by: Randy Jennings <randyj@purestorage.com>
Signed-off-by: Uday Shankar <ushankar@purestorage.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
2023-05-25 18:22:03 +00:00
|
|
|
unsigned long ka_last_check_time;
|
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;
|
2024-06-25 12:26:05 +00:00
|
|
|
atomic_t nr_active;
|
2018-05-14 06:48:54 +00:00
|
|
|
#endif
|
|
|
|
|
2023-10-12 12:22:48 +00:00
|
|
|
#ifdef CONFIG_NVME_HOST_AUTH
|
2022-06-27 09:52:02 +00:00
|
|
|
struct work_struct dhchap_auth_work;
|
|
|
|
struct mutex dhchap_auth_mutex;
|
2022-11-13 11:24:20 +00:00
|
|
|
struct nvme_dhchap_queue_context *dhchap_ctxs;
|
2022-06-27 09:52:02 +00:00
|
|
|
struct nvme_dhchap_key *host_key;
|
|
|
|
struct nvme_dhchap_key *ctrl_key;
|
|
|
|
u16 transaction;
|
|
|
|
#endif
|
2024-07-22 12:02:19 +00:00
|
|
|
key_serial_t tls_pskid;
|
2022-06-27 09:52:02 +00:00
|
|
|
|
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: */
|
2023-05-01 12:40:26 +00:00
|
|
|
u16 hmmaxd;
|
2017-05-12 15:16:10 +00:00
|
|
|
u32 hmpre;
|
|
|
|
u32 hmmin;
|
2017-09-11 16:09:28 +00:00
|
|
|
u32 hmminds;
|
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;
|
2020-11-24 18:34:59 +00:00
|
|
|
unsigned long flags;
|
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;
|
2022-02-08 19:33:46 +00:00
|
|
|
|
|
|
|
enum nvme_ctrl_type cntrltype;
|
|
|
|
enum nvme_dctype dctype;
|
2015-10-03 13:46:41 +00:00
|
|
|
};
|
|
|
|
|
2023-10-30 15:13:09 +00:00
|
|
|
static inline enum nvme_ctrl_state nvme_ctrl_state(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
return READ_ONCE(ctrl->state);
|
|
|
|
}
|
|
|
|
|
2019-02-18 10:43:26 +00:00
|
|
|
enum nvme_iopolicy {
|
|
|
|
NVME_IOPOLICY_NUMA,
|
|
|
|
NVME_IOPOLICY_RR,
|
2024-06-25 12:26:05 +00:00
|
|
|
NVME_IOPOLICY_QD,
|
2019-02-18 10:43:26 +00:00
|
|
|
};
|
|
|
|
|
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;
|
2021-09-22 06:35:23 +00:00
|
|
|
enum nvme_subsys_type subtype;
|
2017-11-09 12:48:55 +00:00
|
|
|
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;
|
2020-06-29 19:06:39 +00:00
|
|
|
u8 csi;
|
2017-11-09 12:50:16 +00:00
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
struct nvme_ns_ids ids;
|
|
|
|
struct list_head entry;
|
|
|
|
struct kref ref;
|
2020-04-09 16:09:02 +00:00
|
|
|
bool shared;
|
2024-02-06 17:47:21 +00:00
|
|
|
bool passthru_err_log_enabled;
|
2017-11-09 12:50:43 +00:00
|
|
|
int instance;
|
2020-06-29 19:06:40 +00:00
|
|
|
struct nvme_effects_log *effects;
|
2023-12-18 16:59:54 +00:00
|
|
|
u64 nuse;
|
|
|
|
unsigned ns_id;
|
2023-12-18 16:59:49 +00:00
|
|
|
int lba_shift;
|
|
|
|
u16 ms;
|
|
|
|
u16 pi_size;
|
|
|
|
u8 pi_type;
|
2024-02-01 13:01:26 +00:00
|
|
|
u8 pi_offset;
|
2023-12-18 16:59:49 +00:00
|
|
|
u8 guard_type;
|
|
|
|
#ifdef CONFIG_BLK_DEV_ZONED
|
|
|
|
u64 zsze;
|
|
|
|
#endif
|
|
|
|
unsigned long features;
|
2021-04-21 07:45:04 +00:00
|
|
|
|
2023-12-18 16:59:53 +00:00
|
|
|
struct ratelimit_state rs_nuse;
|
2021-04-21 07:45:04 +00:00
|
|
|
|
|
|
|
struct cdev cdev;
|
|
|
|
struct device cdev_device;
|
|
|
|
|
2018-09-11 07:51:29 +00:00
|
|
|
struct gendisk *disk;
|
2021-04-07 15:49:29 +00:00
|
|
|
#ifdef CONFIG_NVME_MULTIPATH
|
2018-09-11 07:51:29 +00:00
|
|
|
struct bio_list requeue_list;
|
|
|
|
spinlock_t requeue_lock;
|
|
|
|
struct work_struct requeue_work;
|
|
|
|
struct mutex lock;
|
2020-06-24 08:53:11 +00:00
|
|
|
unsigned long flags;
|
|
|
|
#define NVME_NSHEAD_DISK_LIVE 0
|
2018-09-11 07:51:29 +00:00
|
|
|
struct nvme_ns __rcu *current_path[];
|
|
|
|
#endif
|
2017-11-09 12:50:43 +00:00
|
|
|
};
|
|
|
|
|
2021-04-07 15:49:29 +00:00
|
|
|
static inline bool nvme_ns_head_multipath(struct nvme_ns_head *head)
|
|
|
|
{
|
|
|
|
return IS_ENABLED(CONFIG_NVME_MULTIPATH) && head->disk;
|
|
|
|
}
|
|
|
|
|
2020-05-19 14:05:49 +00:00
|
|
|
enum nvme_ns_features {
|
|
|
|
NVME_NS_EXT_LBAS = 1 << 0, /* support extended LBA format */
|
2020-05-19 14:05:50 +00:00
|
|
|
NVME_NS_METADATA_SUPPORTED = 1 << 1, /* support getting generated md */
|
2024-06-17 13:11:44 +00:00
|
|
|
NVME_NS_DEAC = 1 << 2, /* DEAC bit in Write Zeores supported */
|
2020-05-19 14:05:49 +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;
|
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
|
|
|
|
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_ANA_PENDING 2
|
2020-12-01 12:02:21 +00:00
|
|
|
#define NVME_NS_FORCE_RO 3
|
2021-08-24 14:57:42 +00:00
|
|
|
#define NVME_NS_READY 4
|
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
|
|
|
|
2021-04-21 07:45:04 +00:00
|
|
|
struct cdev cdev;
|
|
|
|
struct device cdev_device;
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2020-05-19 14:05:51 +00:00
|
|
|
/* NVMe ns supports metadata actions by the controller (generate/strip) */
|
2023-12-18 16:59:50 +00:00
|
|
|
static inline bool nvme_ns_has_pi(struct nvme_ns_head *head)
|
2020-05-19 14:05:51 +00:00
|
|
|
{
|
2023-12-18 16:59:50 +00:00
|
|
|
return head->pi_type && head->ms == head->pi_size;
|
2020-05-19 14:05:51 +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)
|
2022-11-30 16:19:50 +00:00
|
|
|
#define NVME_F_BLOCKING (1 << 2)
|
|
|
|
|
2022-10-27 09:34:13 +00:00
|
|
|
const struct attribute_group **dev_attr_groups;
|
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);
|
2024-06-24 15:56:17 +00:00
|
|
|
int (*subsystem_reset)(struct nvme_ctrl *ctrl);
|
2017-10-29 08:44:29 +00:00
|
|
|
void (*delete_ctrl)(struct nvme_ctrl *ctrl);
|
2022-06-23 06:45:39 +00:00
|
|
|
void (*stop_ctrl)(struct nvme_ctrl *ctrl);
|
2016-06-13 14:45:24 +00:00
|
|
|
int (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size);
|
2022-06-07 15:30:29 +00:00
|
|
|
void (*print_device_info)(struct nvme_ctrl *ctrl);
|
2022-07-08 16:51:00 +00:00
|
|
|
bool (*supports_pci_p2pdma)(struct nvme_ctrl *ctrl);
|
2015-10-03 13:46:41 +00:00
|
|
|
};
|
|
|
|
|
2021-06-16 21:19:36 +00:00
|
|
|
/*
|
|
|
|
* nvme command_id is constructed as such:
|
|
|
|
* | xxxx | xxxxxxxxxxxx |
|
|
|
|
* gen request tag
|
|
|
|
*/
|
|
|
|
#define nvme_genctr_mask(gen) (gen & 0xf)
|
|
|
|
#define nvme_cid_install_genctr(gen) (nvme_genctr_mask(gen) << 12)
|
|
|
|
#define nvme_genctr_from_cid(cid) ((cid & 0xf000) >> 12)
|
|
|
|
#define nvme_tag_from_cid(cid) (cid & 0xfff)
|
|
|
|
|
|
|
|
static inline u16 nvme_cid(struct request *rq)
|
|
|
|
{
|
|
|
|
return nvme_cid_install_genctr(nvme_req(rq)->genctr) | rq->tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct request *nvme_find_rq(struct blk_mq_tags *tags,
|
|
|
|
u16 command_id)
|
|
|
|
{
|
|
|
|
u8 genctr = nvme_genctr_from_cid(command_id);
|
|
|
|
u16 tag = nvme_tag_from_cid(command_id);
|
|
|
|
struct request *rq;
|
|
|
|
|
|
|
|
rq = blk_mq_tag_to_rq(tags, tag);
|
|
|
|
if (unlikely(!rq)) {
|
|
|
|
pr_err("could not locate request for tag %#x\n",
|
|
|
|
tag);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (unlikely(nvme_genctr_mask(nvme_req(rq)->genctr) != genctr)) {
|
|
|
|
dev_err(nvme_req(rq)->ctrl->device,
|
|
|
|
"request %#x genctr mismatch (got %#x expected %#x)\n",
|
|
|
|
tag, genctr, nvme_genctr_mask(nvme_req(rq)->genctr));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return rq;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct request *nvme_cid_to_rq(struct blk_mq_tags *tags,
|
|
|
|
u16 command_id)
|
|
|
|
{
|
|
|
|
return blk_mq_tag_to_rq(tags, nvme_tag_from_cid(command_id));
|
|
|
|
}
|
|
|
|
|
2022-06-07 15:30:29 +00:00
|
|
|
/*
|
|
|
|
* Return the length of the string without the space padding
|
|
|
|
*/
|
|
|
|
static inline int nvme_strlen(char *s, int len)
|
|
|
|
{
|
|
|
|
while (s[len - 1] == ' ')
|
|
|
|
len--;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void nvme_print_device_info(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
struct nvme_subsystem *subsys = ctrl->subsys;
|
|
|
|
|
|
|
|
if (ctrl->ops->print_device_info) {
|
|
|
|
ctrl->ops->print_device_info(ctrl);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev_err(ctrl->device,
|
|
|
|
"VID:%04x model:%.*s firmware:%.*s\n", subsys->vendor_id,
|
|
|
|
nvme_strlen(subsys->model, sizeof(subsys->model)),
|
|
|
|
subsys->model, nvme_strlen(subsys->firmware_rev,
|
|
|
|
sizeof(subsys->firmware_rev)),
|
|
|
|
subsys->firmware_rev);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
2022-09-22 15:13:47 +00:00
|
|
|
bool nvme_wait_reset(struct nvme_ctrl *ctrl);
|
|
|
|
int nvme_try_sched_reset(struct nvme_ctrl *ctrl);
|
|
|
|
|
2015-11-28 14:40:19 +00:00
|
|
|
static inline int nvme_reset_subsystem(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
2024-06-24 15:56:17 +00:00
|
|
|
if (!ctrl->subsystem || !ctrl->ops->subsystem_reset)
|
2015-11-28 14:40:19 +00:00
|
|
|
return -ENOTTY;
|
2024-06-24 15:56:17 +00:00
|
|
|
return ctrl->ops->subsystem_reset(ctrl);
|
2015-11-28 14:40:19 +00:00
|
|
|
}
|
|
|
|
|
2019-10-21 03:40:03 +00:00
|
|
|
/*
|
|
|
|
* Convert a 512B sector number to a device logical block number.
|
|
|
|
*/
|
2023-12-18 16:59:50 +00:00
|
|
|
static inline u64 nvme_sect_to_lba(struct nvme_ns_head *head, sector_t sector)
|
2015-10-03 13:46:41 +00:00
|
|
|
{
|
2023-12-18 16:59:50 +00:00
|
|
|
return sector >> (head->lba_shift - SECTOR_SHIFT);
|
2015-10-03 13:46:41 +00:00
|
|
|
}
|
|
|
|
|
2019-10-21 03:40:04 +00:00
|
|
|
/*
|
|
|
|
* Convert a device logical block number to a 512B sector number.
|
|
|
|
*/
|
2023-12-18 16:59:50 +00:00
|
|
|
static inline sector_t nvme_lba_to_sect(struct nvme_ns_head *head, u64 lba)
|
2015-10-03 13:46:41 +00:00
|
|
|
{
|
2023-12-18 16:59:50 +00:00
|
|
|
return lba << (head->lba_shift - SECTOR_SHIFT);
|
2015-10-03 13:46:41 +00:00
|
|
|
}
|
|
|
|
|
2020-04-03 16:24:01 +00:00
|
|
|
/*
|
|
|
|
* Convert byte length to nvme's 0-based num dwords
|
|
|
|
*/
|
|
|
|
static inline u32 nvme_bytes_to_numd(size_t len)
|
|
|
|
{
|
|
|
|
return (len >> 2) - 1;
|
|
|
|
}
|
|
|
|
|
2020-08-18 07:11:30 +00:00
|
|
|
static inline bool nvme_is_ana_error(u16 status)
|
|
|
|
{
|
2024-06-03 12:57:00 +00:00
|
|
|
switch (status & NVME_SCT_SC_MASK) {
|
2020-08-18 07:11:30 +00:00
|
|
|
case NVME_SC_ANA_TRANSITION:
|
|
|
|
case NVME_SC_ANA_INACCESSIBLE:
|
|
|
|
case NVME_SC_ANA_PERSISTENT_LOSS:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool nvme_is_path_error(u16 status)
|
|
|
|
{
|
2020-08-18 07:11:31 +00:00
|
|
|
/* check for a status code type of 'path related status' */
|
2024-06-03 12:57:00 +00:00
|
|
|
return (status & NVME_SCT_MASK) == NVME_SCT_PATH;
|
2020-08-18 07:11:30 +00:00
|
|
|
}
|
|
|
|
|
2020-08-18 07:11:29 +00:00
|
|
|
/*
|
|
|
|
* Fill in the status and result information from the CQE, and then figure out
|
|
|
|
* if blk-mq will need to use IPI magic to complete the request, and if yes do
|
|
|
|
* so. If not let the caller complete the request without an indirect function
|
|
|
|
* call.
|
|
|
|
*/
|
|
|
|
static inline bool nvme_try_complete_req(struct request *req, __le16 status,
|
2017-04-20 14:02:57 +00:00
|
|
|
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);
|
2021-12-13 17:08:47 +00:00
|
|
|
struct nvme_ctrl *ctrl = rq->ctrl;
|
|
|
|
|
|
|
|
if (!(ctrl->quirks & NVME_QUIRK_SKIP_CID_GEN))
|
|
|
|
rq->genctr++;
|
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);
|
2020-06-11 06:44:52 +00:00
|
|
|
if (unlikely(blk_should_fake_timeout(req->q)))
|
|
|
|
return true;
|
|
|
|
return blk_mq_complete_request_remote(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);
|
|
|
|
}
|
|
|
|
|
2019-10-13 16:57:31 +00:00
|
|
|
static inline bool nvme_is_aen_req(u16 qid, __u16 command_id)
|
|
|
|
{
|
2021-06-16 21:19:36 +00:00
|
|
|
return !qid &&
|
|
|
|
nvme_tag_from_cid(command_id) >= NVME_AQ_BLK_MQ_DEPTH;
|
2019-10-13 16:57:31 +00:00
|
|
|
}
|
|
|
|
|
2024-04-25 14:03:00 +00:00
|
|
|
/*
|
|
|
|
* Returns true for sink states that can't ever transition back to live.
|
|
|
|
*/
|
|
|
|
static inline bool nvme_state_terminal(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
switch (nvme_ctrl_state(ctrl)) {
|
|
|
|
case NVME_CTRL_NEW:
|
|
|
|
case NVME_CTRL_LIVE:
|
|
|
|
case NVME_CTRL_RESETTING:
|
|
|
|
case NVME_CTRL_CONNECTING:
|
|
|
|
return false;
|
|
|
|
case NVME_CTRL_DELETING:
|
|
|
|
case NVME_CTRL_DELETING_NOIO:
|
|
|
|
case NVME_CTRL_DEAD:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
WARN_ONCE(1, "Unhandled ctrl state:%d", ctrl->state);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-21 18:02:28 +00:00
|
|
|
void nvme_end_req(struct request *req);
|
2017-03-30 11:41:32 +00:00
|
|
|
void nvme_complete_rq(struct request *req);
|
2021-10-08 11:59:37 +00:00
|
|
|
void nvme_complete_batch_req(struct request *req);
|
|
|
|
|
|
|
|
static __always_inline void nvme_complete_batch(struct io_comp_batch *iob,
|
|
|
|
void (*fn)(struct request *rq))
|
|
|
|
{
|
|
|
|
struct request *req;
|
|
|
|
|
|
|
|
rq_list_for_each(&iob->req_list, req) {
|
|
|
|
fn(req);
|
|
|
|
nvme_complete_batch_req(req);
|
|
|
|
}
|
|
|
|
blk_mq_end_request_batch(iob);
|
|
|
|
}
|
|
|
|
|
2021-02-04 07:55:11 +00:00
|
|
|
blk_status_t nvme_host_path_error(struct request *req);
|
2022-07-06 12:03:53 +00:00
|
|
|
bool nvme_cancel_request(struct request *req, void *data);
|
2021-01-21 03:32:36 +00:00
|
|
|
void nvme_cancel_tagset(struct nvme_ctrl *ctrl);
|
|
|
|
void nvme_cancel_admin_tagset(struct nvme_ctrl *ctrl);
|
2016-04-26 11:51:57 +00:00
|
|
|
bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
|
|
|
|
enum nvme_ctrl_state new_state);
|
2022-11-08 10:20:12 +00:00
|
|
|
int nvme_disable_ctrl(struct nvme_ctrl *ctrl, bool shutdown);
|
2019-07-23 00:06:53 +00:00
|
|
|
int nvme_enable_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);
|
2024-06-04 18:59:08 +00:00
|
|
|
int nvme_add_ctrl(struct nvme_ctrl *ctrl);
|
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);
|
2022-11-08 14:48:27 +00:00
|
|
|
int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl, bool was_suspended);
|
2022-09-04 12:18:30 +00:00
|
|
|
int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
|
2022-11-30 16:19:50 +00:00
|
|
|
const struct blk_mq_ops *ops, unsigned int cmd_size);
|
2022-09-04 12:18:30 +00:00
|
|
|
void nvme_remove_admin_tag_set(struct nvme_ctrl *ctrl);
|
|
|
|
int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
|
2022-11-30 16:19:50 +00:00
|
|
|
const struct blk_mq_ops *ops, unsigned int nr_maps,
|
|
|
|
unsigned int cmd_size);
|
2022-09-04 12:18:30 +00:00
|
|
|
void nvme_remove_io_tag_set(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
|
|
|
|
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
|
|
|
|
2022-11-15 10:22:14 +00:00
|
|
|
void nvme_quiesce_io_queues(struct nvme_ctrl *ctrl);
|
|
|
|
void nvme_unquiesce_io_queues(struct nvme_ctrl *ctrl);
|
|
|
|
void nvme_quiesce_admin_queue(struct nvme_ctrl *ctrl);
|
|
|
|
void nvme_unquiesce_admin_queue(struct nvme_ctrl *ctrl);
|
2022-11-01 15:00:43 +00:00
|
|
|
void nvme_mark_namespaces_dead(struct nvme_ctrl *ctrl);
|
2019-05-14 20:46:09 +00:00
|
|
|
void nvme_sync_queues(struct nvme_ctrl *ctrl);
|
2020-10-22 02:15:00 +00:00
|
|
|
void nvme_sync_io_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);
|
2020-07-30 20:24:45 +00:00
|
|
|
int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout);
|
2017-03-01 19:22:12 +00:00
|
|
|
void nvme_start_freeze(struct nvme_ctrl *ctrl);
|
2015-12-24 14:26:59 +00:00
|
|
|
|
2022-07-14 18:07:03 +00:00
|
|
|
static inline enum req_op nvme_req_op(struct nvme_command *cmd)
|
2022-03-15 14:53:59 +00:00
|
|
|
{
|
|
|
|
return nvme_is_write(cmd) ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN;
|
|
|
|
}
|
|
|
|
|
2016-06-13 14:45:23 +00:00
|
|
|
#define NVME_QID_ANY -1
|
2022-03-15 14:53:59 +00:00
|
|
|
void nvme_init_request(struct request *req, struct nvme_command *cmd);
|
2018-07-29 21:15:33 +00:00
|
|
|
void nvme_cleanup_cmd(struct request *req);
|
2021-03-17 20:37:03 +00:00
|
|
|
blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req);
|
2021-04-26 02:53:10 +00:00
|
|
|
blk_status_t nvme_fail_nonready_command(struct nvme_ctrl *ctrl,
|
|
|
|
struct request *req);
|
|
|
|
bool __nvme_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
|
2024-01-24 17:27:27 +00:00
|
|
|
bool queue_live, enum nvme_ctrl_state state);
|
2021-04-26 02:53:10 +00:00
|
|
|
|
|
|
|
static inline bool nvme_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
|
|
|
|
bool queue_live)
|
|
|
|
{
|
2024-01-24 17:27:27 +00:00
|
|
|
enum nvme_ctrl_state state = nvme_ctrl_state(ctrl);
|
|
|
|
|
|
|
|
if (likely(state == NVME_CTRL_LIVE))
|
2021-04-26 02:53:10 +00:00
|
|
|
return true;
|
2024-01-24 17:27:27 +00:00
|
|
|
if (ctrl->ops->flags & NVME_F_FABRICS && state == NVME_CTRL_DELETING)
|
2021-11-04 07:13:32 +00:00
|
|
|
return queue_live;
|
2024-01-24 17:27:27 +00:00
|
|
|
return __nvme_check_ready(ctrl, rq, queue_live, state);
|
2021-04-26 02:53:10 +00:00
|
|
|
}
|
2022-03-14 11:05:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* NSID shall be unique for all shared namespaces, or if at least one of the
|
|
|
|
* following conditions is met:
|
|
|
|
* 1. Namespace Management is supported by the controller
|
|
|
|
* 2. ANA is supported by the controller
|
|
|
|
* 3. NVM Set are supported by the controller
|
|
|
|
*
|
|
|
|
* In other case, private namespace are not required to report a unique NSID.
|
|
|
|
*/
|
|
|
|
static inline bool nvme_is_unique_nsid(struct nvme_ctrl *ctrl,
|
|
|
|
struct nvme_ns_head *head)
|
|
|
|
{
|
|
|
|
return head->shared ||
|
|
|
|
(ctrl->oacs & NVME_CTRL_OACS_NS_MNGT_SUPP) ||
|
|
|
|
(ctrl->subsys->cmic & NVME_CTRL_CMIC_ANA) ||
|
|
|
|
(ctrl->ctratt & NVME_CTRL_CTRATT_NVM_SETS);
|
|
|
|
}
|
|
|
|
|
2024-01-29 06:39:46 +00:00
|
|
|
/*
|
|
|
|
* Flags for __nvme_submit_sync_cmd()
|
|
|
|
*/
|
|
|
|
typedef __u32 __bitwise nvme_submit_flags_t;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
/* Insert request at the head of the queue */
|
|
|
|
NVME_SUBMIT_AT_HEAD = (__force nvme_submit_flags_t)(1 << 0),
|
|
|
|
/* Set BLK_MQ_REQ_NOWAIT when allocating request */
|
|
|
|
NVME_SUBMIT_NOWAIT = (__force nvme_submit_flags_t)(1 << 1),
|
|
|
|
/* Set BLK_MQ_REQ_RESERVED when allocating request */
|
|
|
|
NVME_SUBMIT_RESERVED = (__force nvme_submit_flags_t)(1 << 2),
|
2024-06-03 12:57:01 +00:00
|
|
|
/* Retry command when NVME_STATUS_DNR is not set in the result */
|
2024-01-29 06:39:48 +00:00
|
|
|
NVME_SUBMIT_RETRY = (__force nvme_submit_flags_t)(1 << 3),
|
2024-01-29 06:39:46 +00:00
|
|
|
};
|
|
|
|
|
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,
|
2024-01-29 06:39:46 +00:00
|
|
|
int qid, nvme_submit_flags_t flags);
|
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);
|
2021-04-10 06:42:03 +00:00
|
|
|
int nvme_reset_ctrl_sync(struct nvme_ctrl *ctrl);
|
2017-10-29 08:44:29 +00:00
|
|
|
int nvme_delete_ctrl(struct nvme_ctrl *ctrl);
|
2021-04-10 06:42:03 +00:00
|
|
|
void nvme_queue_scan(struct nvme_ctrl *ctrl);
|
2020-06-29 19:06:40 +00:00
|
|
|
int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,
|
2018-06-06 12:39:00 +00:00
|
|
|
void *log, size_t size, u64 offset);
|
2021-04-07 12:22:12 +00:00
|
|
|
bool nvme_tryget_ns_head(struct nvme_ns_head *head);
|
|
|
|
void nvme_put_ns_head(struct nvme_ns_head *head);
|
2021-04-21 07:45:04 +00:00
|
|
|
int nvme_cdev_add(struct cdev *cdev, struct device *cdev_device,
|
|
|
|
const struct file_operations *fops, struct module *owner);
|
|
|
|
void nvme_cdev_del(struct cdev *cdev, struct device *cdev_device);
|
2023-06-08 11:02:55 +00:00
|
|
|
int nvme_ioctl(struct block_device *bdev, blk_mode_t mode,
|
2021-04-10 06:42:03 +00:00
|
|
|
unsigned int cmd, unsigned long arg);
|
2021-04-21 07:45:04 +00:00
|
|
|
long nvme_ns_chr_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
|
2023-06-08 11:02:55 +00:00
|
|
|
int nvme_ns_head_ioctl(struct block_device *bdev, blk_mode_t mode,
|
2021-04-10 06:42:03 +00:00
|
|
|
unsigned int cmd, unsigned long arg);
|
2021-04-21 07:45:04 +00:00
|
|
|
long nvme_ns_head_chr_ioctl(struct file *file, unsigned int cmd,
|
|
|
|
unsigned long arg);
|
2021-04-10 06:42:03 +00:00
|
|
|
long nvme_dev_ioctl(struct file *file, unsigned int cmd,
|
|
|
|
unsigned long arg);
|
2022-09-02 21:18:05 +00:00
|
|
|
int nvme_ns_chr_uring_cmd_iopoll(struct io_uring_cmd *ioucmd,
|
|
|
|
struct io_comp_batch *iob, unsigned int poll_flags);
|
2022-05-11 05:47:48 +00:00
|
|
|
int nvme_ns_chr_uring_cmd(struct io_uring_cmd *ioucmd,
|
|
|
|
unsigned int issue_flags);
|
|
|
|
int nvme_ns_head_chr_uring_cmd(struct io_uring_cmd *ioucmd,
|
|
|
|
unsigned int issue_flags);
|
2023-12-18 16:59:53 +00:00
|
|
|
int nvme_identify_ns(struct nvme_ctrl *ctrl, unsigned nsid,
|
|
|
|
struct nvme_id_ns **id);
|
2021-04-07 12:22:12 +00:00
|
|
|
int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo);
|
2022-05-20 09:06:30 +00:00
|
|
|
int nvme_dev_uring_cmd(struct io_uring_cmd *ioucmd, unsigned int issue_flags);
|
2018-03-21 19:27:07 +00:00
|
|
|
|
2023-12-18 16:59:52 +00:00
|
|
|
extern const struct attribute_group *nvme_ns_attr_groups[];
|
2021-04-07 12:22:12 +00:00
|
|
|
extern const struct pr_ops nvme_pr_ops;
|
2017-11-02 11:59:30 +00:00
|
|
|
extern const struct block_device_operations nvme_ns_head_ops;
|
2022-10-27 09:34:13 +00:00
|
|
|
extern const struct attribute_group nvme_dev_attrs_group;
|
2023-04-24 21:12:42 +00:00
|
|
|
extern const struct attribute_group *nvme_subsys_attrs_groups[];
|
|
|
|
extern const struct attribute_group *nvme_dev_attr_groups[];
|
|
|
|
extern const struct block_device_operations nvme_bdev_ops;
|
2017-11-02 11:59:30 +00:00
|
|
|
|
2023-04-24 21:12:42 +00:00
|
|
|
void nvme_delete_ctrl_sync(struct nvme_ctrl *ctrl);
|
2021-05-19 07:22:35 +00:00
|
|
|
struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);
|
2017-11-02 11:59:30 +00:00
|
|
|
#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);
|
2021-12-20 12:51:45 +00:00
|
|
|
void nvme_mpath_default_iopolicy(struct nvme_subsystem *subsys);
|
2020-08-18 07:11:30 +00:00
|
|
|
void nvme_failover_req(struct request *req);
|
2017-11-02 11:59:30 +00:00
|
|
|
void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl);
|
|
|
|
int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl,struct nvme_ns_head *head);
|
2022-06-28 19:10:15 +00:00
|
|
|
void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid);
|
2017-11-02 11:59:30 +00:00
|
|
|
void nvme_mpath_remove_disk(struct nvme_ns_head *head);
|
2021-04-29 12:18:53 +00:00
|
|
|
int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id);
|
|
|
|
void nvme_mpath_init_ctrl(struct nvme_ctrl *ctrl);
|
2022-03-24 19:05:11 +00:00
|
|
|
void nvme_mpath_update(struct nvme_ctrl *ctrl);
|
2018-05-14 06:48:54 +00:00
|
|
|
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);
|
2021-08-24 14:57:42 +00:00
|
|
|
void nvme_mpath_revalidate_paths(struct nvme_ns *ns);
|
2019-07-25 18:56:57 +00:00
|
|
|
void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl);
|
2021-07-16 11:30:35 +00:00
|
|
|
void nvme_mpath_shutdown_disk(struct nvme_ns_head *head);
|
2022-11-29 14:43:19 +00:00
|
|
|
void nvme_mpath_start_request(struct request *rq);
|
|
|
|
void nvme_mpath_end_request(struct request *rq);
|
2017-12-21 13:07:27 +00:00
|
|
|
|
2021-01-05 10:34:02 +00:00
|
|
|
static inline void nvme_trace_bio_complete(struct request *req)
|
2019-07-24 13:47:55 +00:00
|
|
|
{
|
|
|
|
struct nvme_ns *ns = req->q->queuedata;
|
|
|
|
|
2022-12-22 01:57:21 +00:00
|
|
|
if ((req->cmd_flags & REQ_NVME_MPATH) && req->bio)
|
2020-06-03 05:14:43 +00:00
|
|
|
trace_block_bio_complete(ns->head->disk->queue, req->bio);
|
2019-07-24 13:47:55 +00:00
|
|
|
}
|
|
|
|
|
2022-03-15 11:58:06 +00:00
|
|
|
extern bool multipath;
|
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
|
|
|
|
2023-12-27 09:31:06 +00:00
|
|
|
static inline bool nvme_disk_is_ns_head(struct gendisk *disk)
|
|
|
|
{
|
|
|
|
return disk->fops == &nvme_ns_head_ops;
|
|
|
|
}
|
2017-11-02 11:59:30 +00:00
|
|
|
#else
|
2022-03-15 11:58:06 +00:00
|
|
|
#define multipath false
|
2018-05-14 06:48:54 +00:00
|
|
|
static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2020-08-18 07:11:30 +00:00
|
|
|
static inline void nvme_failover_req(struct request *req)
|
2017-11-02 11:59:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
2022-06-28 19:10:15 +00:00
|
|
|
static inline void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid)
|
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;
|
|
|
|
}
|
2021-08-24 14:57:42 +00:00
|
|
|
static inline void nvme_mpath_revalidate_paths(struct nvme_ns *ns)
|
|
|
|
{
|
|
|
|
}
|
2019-07-25 18:56:57 +00:00
|
|
|
static inline void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl)
|
2017-12-21 13:07:27 +00:00
|
|
|
{
|
|
|
|
}
|
2021-07-16 11:30:35 +00:00
|
|
|
static inline void nvme_mpath_shutdown_disk(struct nvme_ns_head *head)
|
2017-11-02 11:59:30 +00:00
|
|
|
{
|
|
|
|
}
|
2021-01-05 10:34:02 +00:00
|
|
|
static inline void nvme_trace_bio_complete(struct request *req)
|
2019-07-24 13:47:55 +00:00
|
|
|
{
|
|
|
|
}
|
2021-04-29 12:18:53 +00:00
|
|
|
static inline void nvme_mpath_init_ctrl(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline int nvme_mpath_init_identify(struct nvme_ctrl *ctrl,
|
2018-05-14 06:48:54 +00:00
|
|
|
struct nvme_id_ctrl *id)
|
|
|
|
{
|
2021-03-08 19:18:03 +00:00
|
|
|
if (ctrl->subsys->cmic & NVME_CTRL_CMIC_ANA)
|
2018-11-20 15:57:54 +00:00
|
|
|
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;
|
|
|
|
}
|
2022-03-24 19:05:11 +00:00
|
|
|
static inline void nvme_mpath_update(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
}
|
2018-05-14 06:48:54 +00:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
}
|
2021-12-20 12:51:45 +00:00
|
|
|
static inline void nvme_mpath_default_iopolicy(struct nvme_subsystem *subsys)
|
|
|
|
{
|
|
|
|
}
|
2022-11-29 14:43:19 +00:00
|
|
|
static inline void nvme_mpath_start_request(struct request *rq)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline void nvme_mpath_end_request(struct request *rq)
|
|
|
|
{
|
|
|
|
}
|
2023-12-27 09:31:06 +00:00
|
|
|
static inline bool nvme_disk_is_ns_head(struct gendisk *disk)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-11-02 11:59:30 +00:00
|
|
|
#endif /* CONFIG_NVME_MULTIPATH */
|
|
|
|
|
2024-07-05 16:46:26 +00:00
|
|
|
int nvme_ns_get_unique_id(struct nvme_ns *ns, u8 id[16],
|
|
|
|
enum blk_unique_id type);
|
|
|
|
|
2024-04-02 14:47:54 +00:00
|
|
|
struct nvme_zone_info {
|
|
|
|
u64 zone_size;
|
|
|
|
unsigned int max_open_zones;
|
|
|
|
unsigned int max_active_zones;
|
|
|
|
};
|
|
|
|
|
2021-05-19 07:17:06 +00:00
|
|
|
int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
|
|
|
|
unsigned int nr_zones, report_zones_cb cb, void *data);
|
2024-04-02 14:47:54 +00:00
|
|
|
int nvme_query_zone_info(struct nvme_ns *ns, unsigned lbaf,
|
|
|
|
struct nvme_zone_info *zi);
|
|
|
|
void nvme_update_zone_info(struct nvme_ns *ns, struct queue_limits *lim,
|
|
|
|
struct nvme_zone_info *zi);
|
2020-06-29 19:06:41 +00:00
|
|
|
#ifdef CONFIG_BLK_DEV_ZONED
|
|
|
|
blk_status_t nvme_setup_zone_mgmt_send(struct nvme_ns *ns, struct request *req,
|
|
|
|
struct nvme_command *cmnd,
|
|
|
|
enum nvme_zone_mgmt_action action);
|
|
|
|
#else
|
|
|
|
static inline blk_status_t nvme_setup_zone_mgmt_send(struct nvme_ns *ns,
|
|
|
|
struct request *req, struct nvme_command *cmnd,
|
|
|
|
enum nvme_zone_mgmt_action action)
|
|
|
|
{
|
|
|
|
return BLK_STS_NOTSUPP;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-09-16 12:25:08 +00:00
|
|
|
static inline struct nvme_ns *nvme_get_ns_from_dev(struct device *dev)
|
|
|
|
{
|
2023-12-27 09:31:06 +00:00
|
|
|
struct gendisk *disk = dev_to_disk(dev);
|
|
|
|
|
|
|
|
WARN_ON(nvme_disk_is_ns_head(disk));
|
|
|
|
return disk->private_data;
|
2016-09-16 12:25:08 +00:00
|
|
|
}
|
2015-10-29 08:57:29 +00:00
|
|
|
|
2019-11-06 14:35:18 +00:00
|
|
|
#ifdef CONFIG_NVME_HWMON
|
2020-09-17 15:50:25 +00:00
|
|
|
int nvme_hwmon_init(struct nvme_ctrl *ctrl);
|
2021-01-19 06:43:18 +00:00
|
|
|
void nvme_hwmon_exit(struct nvme_ctrl *ctrl);
|
2019-11-06 14:35:18 +00:00
|
|
|
#else
|
2020-09-17 15:50:25 +00:00
|
|
|
static inline int nvme_hwmon_init(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2021-01-19 06:43:18 +00:00
|
|
|
|
|
|
|
static inline void nvme_hwmon_exit(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
}
|
2019-11-06 14:35:18 +00:00
|
|
|
#endif
|
|
|
|
|
2022-10-03 09:43:43 +00:00
|
|
|
static inline void nvme_start_request(struct request *rq)
|
|
|
|
{
|
2022-11-29 14:43:19 +00:00
|
|
|
if (rq->cmd_flags & REQ_NVME_MPATH)
|
|
|
|
nvme_mpath_start_request(rq);
|
2022-10-03 09:43:43 +00:00
|
|
|
blk_mq_start_request(rq);
|
|
|
|
}
|
|
|
|
|
2021-06-10 01:28:23 +00:00
|
|
|
static inline bool nvme_ctrl_sgl_supported(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
return ctrl->sgls & ((1 << 0) | (1 << 1));
|
|
|
|
}
|
|
|
|
|
2023-10-12 12:22:48 +00:00
|
|
|
#ifdef CONFIG_NVME_HOST_AUTH
|
2022-11-15 16:08:06 +00:00
|
|
|
int __init nvme_init_auth(void);
|
|
|
|
void __exit nvme_exit_auth(void);
|
2022-11-13 11:24:10 +00:00
|
|
|
int nvme_auth_init_ctrl(struct nvme_ctrl *ctrl);
|
2022-06-27 09:52:02 +00:00
|
|
|
void nvme_auth_stop(struct nvme_ctrl *ctrl);
|
|
|
|
int nvme_auth_negotiate(struct nvme_ctrl *ctrl, int qid);
|
|
|
|
int nvme_auth_wait(struct nvme_ctrl *ctrl, int qid);
|
|
|
|
void nvme_auth_free(struct nvme_ctrl *ctrl);
|
|
|
|
#else
|
2022-11-13 11:24:10 +00:00
|
|
|
static inline int nvme_auth_init_ctrl(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2022-11-15 16:08:06 +00:00
|
|
|
static inline int __init nvme_init_auth(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline void __exit nvme_exit_auth(void)
|
|
|
|
{
|
|
|
|
}
|
2022-06-27 09:52:02 +00:00
|
|
|
static inline void nvme_auth_stop(struct nvme_ctrl *ctrl) {};
|
|
|
|
static inline int nvme_auth_negotiate(struct nvme_ctrl *ctrl, int qid)
|
|
|
|
{
|
|
|
|
return -EPROTONOSUPPORT;
|
|
|
|
}
|
|
|
|
static inline int nvme_auth_wait(struct nvme_ctrl *ctrl, int qid)
|
|
|
|
{
|
2024-04-30 13:19:26 +00:00
|
|
|
return -EPROTONOSUPPORT;
|
2022-06-27 09:52:02 +00:00
|
|
|
}
|
|
|
|
static inline void nvme_auth_free(struct nvme_ctrl *ctrl) {};
|
|
|
|
#endif
|
|
|
|
|
2020-07-24 17:25:13 +00:00
|
|
|
u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
|
|
|
|
u8 opcode);
|
2022-12-14 09:13:16 +00:00
|
|
|
u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u8 opcode);
|
|
|
|
int nvme_execute_rq(struct request *rq, bool at_head);
|
2023-05-26 17:06:56 +00:00
|
|
|
void nvme_passthru_end(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u32 effects,
|
2022-09-19 19:36:46 +00:00
|
|
|
struct nvme_command *cmd, int status);
|
2020-09-17 01:11:02 +00:00
|
|
|
struct nvme_ctrl *nvme_ctrl_from_file(struct file *file);
|
2020-07-24 17:25:16 +00:00
|
|
|
struct nvme_ns *nvme_find_get_ns(struct nvme_ctrl *ctrl, unsigned nsid);
|
2024-05-21 13:41:45 +00:00
|
|
|
bool nvme_get_ns(struct nvme_ns *ns);
|
2020-07-24 17:25:16 +00:00
|
|
|
void nvme_put_ns(struct nvme_ns *ns);
|
2020-07-24 17:25:13 +00:00
|
|
|
|
2021-08-26 21:15:45 +00:00
|
|
|
static inline bool nvme_multi_css(struct nvme_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
return (ctrl->ctrl_config & NVME_CC_CSS_MASK) == NVME_CC_CSS_CSI;
|
|
|
|
}
|
|
|
|
|
2022-02-03 08:11:53 +00:00
|
|
|
#ifdef CONFIG_NVME_VERBOSE_ERRORS
|
2024-01-31 16:43:11 +00:00
|
|
|
const char *nvme_get_error_status_str(u16 status);
|
|
|
|
const char *nvme_get_opcode_str(u8 opcode);
|
|
|
|
const char *nvme_get_admin_opcode_str(u8 opcode);
|
|
|
|
const char *nvme_get_fabrics_opcode_str(u8 opcode);
|
2022-02-03 08:11:53 +00:00
|
|
|
#else /* CONFIG_NVME_VERBOSE_ERRORS */
|
2024-01-31 16:43:11 +00:00
|
|
|
static inline const char *nvme_get_error_status_str(u16 status)
|
2022-02-03 08:11:53 +00:00
|
|
|
{
|
|
|
|
return "I/O Error";
|
|
|
|
}
|
2024-01-31 16:43:11 +00:00
|
|
|
static inline const char *nvme_get_opcode_str(u8 opcode)
|
2022-02-03 08:11:53 +00:00
|
|
|
{
|
|
|
|
return "I/O Cmd";
|
|
|
|
}
|
2024-01-31 16:43:11 +00:00
|
|
|
static inline const char *nvme_get_admin_opcode_str(u8 opcode)
|
2022-02-03 08:11:53 +00:00
|
|
|
{
|
|
|
|
return "Admin Cmd";
|
|
|
|
}
|
2022-12-12 19:40:35 +00:00
|
|
|
|
2024-01-31 16:43:11 +00:00
|
|
|
static inline const char *nvme_get_fabrics_opcode_str(u8 opcode)
|
2022-12-12 19:40:35 +00:00
|
|
|
{
|
|
|
|
return "Fabrics Cmd";
|
|
|
|
}
|
2022-02-03 08:11:53 +00:00
|
|
|
#endif /* CONFIG_NVME_VERBOSE_ERRORS */
|
|
|
|
|
2024-01-31 16:43:14 +00:00
|
|
|
static inline const char *nvme_opcode_str(int qid, u8 opcode)
|
2022-12-12 19:40:35 +00:00
|
|
|
{
|
|
|
|
return qid ? nvme_get_opcode_str(opcode) :
|
|
|
|
nvme_get_admin_opcode_str(opcode);
|
|
|
|
}
|
2024-01-31 16:43:14 +00:00
|
|
|
|
|
|
|
static inline const char *nvme_fabrics_opcode_str(
|
|
|
|
int qid, const struct nvme_command *cmd)
|
|
|
|
{
|
|
|
|
if (nvme_is_fabrics(cmd))
|
|
|
|
return nvme_get_fabrics_opcode_str(cmd->fabrics.fctype);
|
|
|
|
|
|
|
|
return nvme_opcode_str(qid, cmd->common.opcode);
|
|
|
|
}
|
2015-10-03 13:46:41 +00:00
|
|
|
#endif /* _NVME_H */
|