FreeBSD ZFS
The Zettabyte File System
Data Structures | Typedefs | Functions | Variables

zio_inject.c File Reference

ZFS fault injection. More...

#include <sys/arc.h>
#include <sys/zio_impl.h>
#include <sys/zfs_ioctl.h>
#include <sys/vdev_impl.h>
#include <sys/dmu_objset.h>
#include <sys/fs/zfs.h>
Include dependency graph for zio_inject.c:

Go to the source code of this file.

Data Structures

struct  inject_handler

Typedefs

typedef struct inject_handler inject_handler_t

Functions

static boolean_t zio_match_handler (zbookmark_t *zb, uint64_t type, zinject_record_t *record, int error)
 Returns true if the given record matches the I/O in progress.
void zio_handle_panic_injection (spa_t *spa, char *tag, uint64_t type)
 Panic the system when a config change happens in the function specified by tag.
int zio_handle_fault_injection (zio_t *zio, int error)
 Determine if the I/O in question should return failure.
int zio_handle_label_injection (zio_t *zio, int error)
 Determine if the zio is part of a label update and has an injection handler associated with that portion of the label.
int zio_handle_device_injection (vdev_t *vd, zio_t *zio, int error)
void zio_handle_ignored_writes (zio_t *zio)
 Simulate hardware that ignores cache flushes.
void spa_handle_ignored_writes (spa_t *spa)
 Called from spa_sync(), but primarily an injection handler.
int zio_inject_fault (char *name, int flags, int *id, zinject_record_t *record)
 Create a new handler for the given record.
int zio_inject_list_next (int *id, char *name, size_t buflen, zinject_record_t *record)
 Returns the next record with an ID greater than that supplied to the function.
int zio_clear_fault (int id)
 Clear the fault handler with the given identifier, or return ENOENT if none exists.
void zio_inject_init (void)
void zio_inject_fini (void)

Variables

uint32_t zio_injection_enabled
static list_t inject_handlers
static krwlock_t inject_lock
static int inject_next_id = 1

Detailed Description

ZFS fault injection.

To handle fault injection, we keep track of a series of zinject_record_t structures which describe which logical block(s) should be injected with a fault. These are kept in a global list. Each record corresponds to a given spa_t and maintains a special hold on the spa_t so that it cannot be deleted or exported while the injection record exists.

Device level injection is done using the 'zi_guid' field. If this is set, it means that the error is destined for a particular device, not a piece of data.

This is a rather poor data structure and algorithm, but we don't expect more than a few faults at any one time, so it should be sufficient for our needs.

Definition in file zio_inject.c.


Typedef Documentation


Function Documentation

void spa_handle_ignored_writes ( spa_t spa)

Called from spa_sync(), but primarily an injection handler.

Definition at line 347 of file zio_inject.c.

int zio_clear_fault ( int  id)

Clear the fault handler with the given identifier, or return ENOENT if none exists.

Definition at line 477 of file zio_inject.c.

int zio_handle_device_injection ( vdev_t vd,
zio_t zio,
int  error 
)

Definition at line 228 of file zio_inject.c.

int zio_handle_fault_injection ( zio_t zio,
int  error 
)

Determine if the I/O in question should return failure.

Returns the errno to be returned to the caller.

Definition at line 129 of file zio_inject.c.

void zio_handle_ignored_writes ( zio_t zio)

Simulate hardware that ignores cache flushes.

For requested number of seconds nix the actual writing to disk.

Definition at line 310 of file zio_inject.c.

int zio_handle_label_injection ( zio_t zio,
int  error 
)

Determine if the zio is part of a label update and has an injection handler associated with that portion of the label.

Currently, we allow error injection in either the nvlist or the uberblock region of of the vdev label.

Definition at line 182 of file zio_inject.c.

void zio_handle_panic_injection ( spa_t spa,
char *  tag,
uint64_t  type 
)

Panic the system when a config change happens in the function specified by tag.

Definition at line 104 of file zio_inject.c.

int zio_inject_fault ( char *  name,
int  flags,
int *  id,
zinject_record_t record 
)

Create a new handler for the given record.

We add it to the list, adding a reference to the spa_t in the process. We increment zio_injection_enabled, which is the switch to trigger all fault injection.

Definition at line 389 of file zio_inject.c.

void zio_inject_fini ( void  )

Definition at line 512 of file zio_inject.c.

void zio_inject_init ( void  )

Definition at line 504 of file zio_inject.c.

int zio_inject_list_next ( int *  id,
char *  name,
size_t  buflen,
zinject_record_t record 
)

Returns the next record with an ID greater than that supplied to the function.

Used to iterate over all handlers in the system.

Definition at line 443 of file zio_inject.c.

static boolean_t zio_match_handler ( zbookmark_t zb,
uint64_t  type,
zinject_record_t record,
int  error 
) [static]

Returns true if the given record matches the I/O in progress.

Definition at line 67 of file zio_inject.c.


Variable Documentation

list_t inject_handlers [static]

Definition at line 59 of file zio_inject.c.

krwlock_t inject_lock [static]

Definition at line 60 of file zio_inject.c.

int inject_next_id = 1 [static]

Definition at line 61 of file zio_inject.c.

Definition at line 50 of file zio_inject.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines