public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
* [RFC 0/1] nvme: Add NVMe LBA Fault Injection
@ 2024-01-16 23:27 Alan Adamson
  2024-01-16 23:27 ` [RFC 1/1] " Alan Adamson
  2024-01-18  7:24 ` [RFC 0/1] " Christoph Hellwig
  0 siblings, 2 replies; 12+ messages in thread
From: Alan Adamson @ 2024-01-16 23:27 UTC (permalink / raw)
  To: linux-nvme; +Cc: alan.adamson, kbusch, hch, sagi

I originally submitted this just before the Holidays so many probably missed it, so
I'm reposting.

It has been requested that the NVMe fault injector be able to inject faults when accessing
specific Logical Block Addresses (LBA).  This patch is built onto the existing fault
injector to provide that ability to specify a LBA when setting up an injection fault.

If the fault injector is enabled, and the nvme driver is ready to send an IO or Admin command
to NVMe hardware, the function should_fail() is called to determine if a fault should
be injected instead of it being allowed to normally be issued.  The should_fail() function
uses the fault injector attributes: probability, times, space, and interval to determine
if a fault should be injected.  If it is determined a fault is to be injected, the request
is immediately completed using the attribute: status.  If no fault is to be injected,
the request is allowed to be issued to the hardware and completed normally.

If a LBA fault is setup, should_fail() is only called if the LBA falls within the range of
blocks of a NVMe READ or WRITE command. If it does not fall with the range, should_fail()
is not called and no fault would be injected.  If the LBA does fall within the range,
should_fail() is called to determine if a fault should be injected.

The LBA fault injector could be extended to also check command types (READ/WRITE).

Steps to setup a fault on a LBA access.

1. Setup the attributes: probability, times, and status according to
the original NVMe fault injector.

echo 100 > /sys/kernel/debug/nvme0n1/fault_inject/probability
echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/times
echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/status

2. Specify one or more LBAs: To configure a LBA, set the lba-inject-set
attribute to the LBA.

echo 0x22 > /sys/kernel/debug/nvme0n1/fault_inject/lba-inject-set

3. Enable the LBA injector: by setting the lba-inject-enable attribute
to on.

echo on > /sys/kernel/debug/nvme0n1/fault_inject/lba-inject-enable

To display the LBAs configured:

cat /sys/kernel/debug/nvme0n1/fault_inject/lba-inject-show
LBA  Status
22   1

To stop injecting a fault on a LBA:

echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/lba-inject-clear
echo 0x22 > /sys/kernel/debug/nvme0n1/fault_inject/lba-inject-set

Alan Adamson (1):
  nvme: Add NVMe LBA Fault Injection

 .../fault-injection/nvme-fault-injection.rst  |  28 ++++
 drivers/nvme/host/core.c                      |   4 +-
 drivers/nvme/host/fault_inject.c              | 145 ++++++++++++++++--
 drivers/nvme/host/nvme.h                      |  16 +-
 4 files changed, 178 insertions(+), 15 deletions(-)

-- 
2.39.3



^ permalink raw reply	[flat|nested] 12+ messages in thread
* [RFC 0/1] nvme: Add NVMe LBA Fault Injection
@ 2023-12-21 23:10 Alan Adamson
  0 siblings, 0 replies; 12+ messages in thread
From: Alan Adamson @ 2023-12-21 23:10 UTC (permalink / raw)
  To: linux-nvme; +Cc: alan.adamson, kch, kbusch, hch, sagi

It has been requested that the NVMe fault injector be able to inject faults when accessing
specific Logical Block Addresses (LBA).  This patch is built onto the existing fault
injector to provide that ability to specify a LBA when setting up an injection fault.

If the fault injector is enabled, and the nvme driver is ready to send an IO or Admin command
to NVMe hardware, the function should_fail() is called to determine if a fault should
be injected instead of it being allowed to normally be issued.  The should_fail() function
uses the fault injector attributes: probability, times, space, and interval to determine
if a fault should be injected.  If it is determined a fault is to be injected, the request
is immediately completed using the attribute: status.  If no fault is to be injected,
the request is allowed to be issued to the hardware and completed normally.

If a LBA fault is setup, should_fail() is only called if the LBA falls within the range of
blocks of a NVMe READ or WRITE command. If it does not fall with the range, should_fail()
is not called and no fault would be injected.  If the LBA does fall within the range,
should_fail() is called to determine if a fault should be injected.

The LBA fault injector could be extended to also check command types (READ/WRITE).

Steps to setup a fault on a LBA access.

1. Setup the attributes: probability, times, and status according to
the original NVMe fault injector.

echo 100 > /sys/kernel/debug/nvme0n1/fault_inject/probability
echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/times
echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/status

2. Specify one or more LBAs: To configure a LBA, set the lba-inject-set
attribute to the LBA.

echo 0x22 > /sys/kernel/debug/nvme0n1/fault_inject/lba-inject-set

3. Enable the LBA injector: by setting the lba-inject-enable attribute
to on.

echo on > /sys/kernel/debug/nvme0n1/fault_inject/lba-inject-enable

To display the LBAs configured:

cat /sys/kernel/debug/nvme0n1/fault_inject/lba-inject-show
LBA  Status
22   1

To stop injecting a fault on a LBA:

echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/lba-inject-clear
echo 0x22 > /sys/kernel/debug/nvme0n1/fault_inject/lba-inject-set

Alan Adamson (1):
  nvme: Add NVMe LBA Fault Injection

 .../fault-injection/nvme-fault-injection.rst  |  28 ++++
 drivers/nvme/host/core.c                      |   4 +-
 drivers/nvme/host/fault_inject.c              | 145 ++++++++++++++++--
 drivers/nvme/host/nvme.h                      |  16 +-
 4 files changed, 178 insertions(+), 15 deletions(-)

-- 
2.39.3



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-01-24 17:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-16 23:27 [RFC 0/1] nvme: Add NVMe LBA Fault Injection Alan Adamson
2024-01-16 23:27 ` [RFC 1/1] " Alan Adamson
2024-01-18  7:24 ` [RFC 0/1] " Christoph Hellwig
2024-01-18 17:02   ` alan.adamson
2024-01-19  4:48     ` Keith Busch
2024-01-23  9:05     ` Christoph Hellwig
2024-01-23 17:25       ` alan.adamson
2024-01-24  9:04         ` Christoph Hellwig
2024-01-24 16:52           ` alan.adamson
2024-01-24 16:59             ` Keith Busch
2024-01-24 17:11               ` alan.adamson
  -- strict thread matches above, loose matches on Subject: below --
2023-12-21 23:10 Alan Adamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox