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

spa.c File Reference

Storage Pool Allocator. More...

#include <sys/zfs_context.h>
#include <sys/fm/fs/zfs.h>
#include <sys/spa_impl.h>
#include <sys/zio.h>
#include <sys/zio_checksum.h>
#include <sys/dmu.h>
#include <sys/dmu_tx.h>
#include <sys/zap.h>
#include <sys/zil.h>
#include <sys/ddt.h>
#include <sys/vdev_impl.h>
#include <sys/metaslab.h>
#include <sys/metaslab_impl.h>
#include <sys/uberblock_impl.h>
#include <sys/txg.h>
#include <sys/avl.h>
#include <sys/dmu_traverse.h>
#include <sys/dmu_objset.h>
#include <sys/unique.h>
#include <sys/dsl_pool.h>
#include <sys/dsl_dataset.h>
#include <sys/dsl_dir.h>
#include <sys/dsl_prop.h>
#include <sys/dsl_synctask.h>
#include <sys/fs/zfs.h>
#include <sys/arc.h>
#include <sys/callb.h>
#include <sys/spa_boot.h>
#include <sys/zfs_ioctl.h>
#include <sys/dsl_scan.h>
#include <sys/zfeature.h>
#include <sys/zvol.h>
#include <sys/trim_map.h>
#include <sys/cpupart.h>
#include <sys/zone.h>
#include "zfs_prop.h"
#include "zfs_comutil.h"
Include dependency graph for spa.c:

Go to the source code of this file.

Data Structures

struct  zio_taskq_info
struct  spa_load_error

Defines

#define ZTI_FIX(n)   { zti_mode_fixed, (n) }
#define ZTI_PCT(n)   { zti_mode_online_percent, (n) }
#define ZTI_BATCH   { zti_mode_batch, 0 }
#define ZTI_NULL   { zti_mode_null, 0 }
#define ZTI_ONE   ZTI_FIX(1)
#define TRYIMPORT_NAME   "$import"
 This (illegal) pool name is used when temporarily importing a spa_t in order to get the vdev stats associated with the imported devices.

Typedefs

typedef enum zti_modes zti_modes_t
typedef struct zio_taskq_info zio_taskq_info_t
typedef struct spa_load_error spa_load_error_t

Enumerations

enum  zti_modes {
  zti_mode_fixed, zti_mode_online_percent, zti_mode_batch, zti_mode_null,
  zti_nmodes
}

Functions

 SYSCTL_DECL (_vfs_zfs)
 TUNABLE_INT ("vfs.zfs.check_hostid",&check_hostid)
 SYSCTL_INT (_vfs_zfs, OID_AUTO, check_hostid, CTLFLAG_RW,&check_hostid, 0,"Check hostid on import?")
 TUNABLE_INT ("vfs.zfs.ccw_retry_interval",&zfs_ccw_retry_interval)
 SYSCTL_INT (_vfs_zfs, OID_AUTO, ccw_retry_interval, CTLFLAG_RW,&zfs_ccw_retry_interval, 0,"Configuration cache file write, retry after failure, interval (seconds)")
static boolean_t spa_has_active_shared_spare (spa_t *spa)
 Check if a pool has an active shared spare device.
static int spa_load_impl (spa_t *spa, uint64_t pool_guid, nvlist_t *config, spa_load_state_t state, spa_import_type_t type, boolean_t mosconfig, char **ereport)
 Load an existing storage pool, using the pool's builtin spa_config as a source of configuration information.
static void spa_vdev_resilver_done (spa_t *spa)
static void spa_prop_add_list (nvlist_t *nvl, zpool_prop_t prop, char *strval, uint64_t intval, zprop_source_t src)
 Add a (source=src, propname=propval) list to an nvlist.
static void spa_prop_get_config (spa_t *spa, nvlist_t **nvp)
 Get property values from the spa configuration.
int spa_prop_get (spa_t *spa, nvlist_t **nvp)
 Get zpool property values.
static int spa_prop_validate (spa_t *spa, nvlist_t *props)
 Validate the given pool properties nvlist and modify the list for the property values to be set.
void spa_configfile_set (spa_t *spa, nvlist_t *nvp, boolean_t need_sync)
int spa_prop_set (spa_t *spa, nvlist_t *nvp)
void spa_prop_clear_bootfs (spa_t *spa, uint64_t dsobj, dmu_tx_t *tx)
 If the bootfs property value is dsobj, clear it.
static int spa_change_guid_check (void *arg1, void *arg2, dmu_tx_t *tx)
static void spa_change_guid_sync (void *arg1, void *arg2, dmu_tx_t *tx)
int spa_change_guid (spa_t *spa)
 Change the GUID for the pool.
static int spa_error_entry_compare (const void *a, const void *b)
void spa_get_errlists (spa_t *spa, avl_tree_t *last, avl_tree_t *scrub)
 Utility function which retrieves copies of the current logs and re-initializes them in the process.
static taskq_t * spa_taskq_create (spa_t *spa, const char *name, enum zti_modes mode, uint_t value)
static void spa_create_zio_taskqs (spa_t *spa)
static void spa_activate (spa_t *spa, int mode)
 Activate an uninitialized pool.
static void spa_deactivate (spa_t *spa)
 Opposite of spa_activate().
static int spa_config_parse (spa_t *spa, vdev_t **vdp, nvlist_t *nv, vdev_t *parent, uint_t id, int atype)
 Verify a pool configuration, and construct the vdev tree appropriately.
static void spa_unload (spa_t *spa)
 Opposite of spa_load().
static void spa_load_spares (spa_t *spa)
 Load (or re-load) the current list of vdevs describing the active spares for this pool.
static void spa_load_l2cache (spa_t *spa)
 Load (or re-load) the current list of vdevs describing the active l2cache for this pool.
static int load_nvlist (spa_t *spa, uint64_t obj, nvlist_t **value)
static void spa_check_removed (vdev_t *vd)
 Checks to see if the given vdev could not be opened, in which case we post a sysevent to notify the autoreplace code that the device has been removed.
static boolean_t spa_config_valid (spa_t *spa, nvlist_t *config)
 Validate the current config against the MOS config.
static int spa_check_logs (spa_t *spa)
 Check for missing log devices.
static boolean_t spa_passivate_log (spa_t *spa)
static void spa_activate_log (spa_t *spa)
int spa_offline_log (spa_t *spa)
static void spa_aux_check_removed (spa_aux_vdev_t *sav)
void spa_claim_notify (zio_t *zio)
 Log claim callback.
static void spa_load_verify_done (zio_t *zio)
static int spa_load_verify_cb (spa_t *spa, zilog_t *zilog, const blkptr_t *bp, arc_buf_t *pbuf, const zbookmark_t *zb, const dnode_phys_t *dnp, void *arg)
static int spa_load_verify (spa_t *spa)
static void spa_prop_find (spa_t *spa, zpool_prop_t prop, uint64_t *val)
 Find a value in the pool props object.
static int spa_dir_prop (spa_t *spa, const char *name, uint64_t *val)
 Find a value in the pool directory object.
static int spa_vdev_err (vdev_t *vdev, vdev_aux_t aux, int err)
static void spa_try_repair (spa_t *spa, nvlist_t *config)
 Fix up config after a partly-completed split.
static int spa_load (spa_t *spa, spa_load_state_t state, spa_import_type_t type, boolean_t mosconfig)
static int spa_load_retry (spa_t *spa, spa_load_state_t state, int mosconfig)
static int spa_load_best (spa_t *spa, spa_load_state_t state, int mosconfig, uint64_t max_request, int rewind_flags)
 If spa_load() fails this function will try loading prior txg's.
static int spa_open_common (const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy, nvlist_t **config)
 Pool Open/Import.
int spa_open_rewind (const char *name, spa_t **spapp, void *tag, nvlist_t *policy, nvlist_t **config)
int spa_open (const char *name, spa_t **spapp, void *tag)
spa_tspa_inject_addref (char *name)
 Increment a SPA's inject count.
void spa_inject_delref (spa_t *spa)
static void spa_add_spares (spa_t *spa, nvlist_t *config)
 Add spares device information to the nvlist.
static void spa_add_l2cache (spa_t *spa, nvlist_t *config)
 Add l2cache device information to the nvlist, including vdev stats.
static void spa_add_feature_stats (spa_t *spa, nvlist_t *config)
int spa_get_stats (const char *name, nvlist_t **config, char *altroot, size_t buflen)
static int spa_validate_aux_devs (spa_t *spa, nvlist_t *nvroot, uint64_t crtxg, int mode, spa_aux_vdev_t *sav, const char *config, uint64_t version, vdev_labeltype_t label)
 Validate that the auxiliary device array is well formed.
static int spa_validate_aux (spa_t *spa, nvlist_t *nvroot, uint64_t crtxg, int mode)
static void spa_set_aux_vdevs (spa_aux_vdev_t *sav, nvlist_t **devs, int ndevs, const char *config)
void spa_l2cache_drop (spa_t *spa)
 Stop and drop level 2 ARC devices.
int spa_create (const char *pool, nvlist_t *nvroot, nvlist_t *props, const char *history_str, nvlist_t *zplprops)
 Pool Creation.
int vdev_geom_read_pool_label (const char *name, nvlist_t **config)
static nvlist_t * spa_generate_rootconf (const char *name)
int spa_import_rootpool (const char *name)
int spa_import (const char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags)
 Import a non-root pool into the system.
nvlist_t * spa_tryimport (nvlist_t *tryconfig)
static int spa_export_common (char *pool, int new_state, nvlist_t **oldconfig, boolean_t force, boolean_t hardforce)
 Pool export/destroy.
int spa_destroy (char *pool)
 Destroy a storage pool.
int spa_export (char *pool, nvlist_t **oldconfig, boolean_t force, boolean_t hardforce)
 Export a storage pool.
int spa_reset (char *pool)
 Reset a storage pool.
int spa_vdev_add (spa_t *spa, nvlist_t *nvroot)
 Add a device to a storage pool.
int spa_vdev_attach (spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing)
 Attach a device to a mirror.
int spa_vdev_detach (spa_t *spa, uint64_t guid, uint64_t pguid, int replace_done)
 Detach a device from a mirror or replacing vdev.
int spa_vdev_split_mirror (spa_t *spa, char *newname, nvlist_t *config, nvlist_t *props, boolean_t exp)
 Split a set of devices from their mirrors, and create a new pool from them.
static nvlist_t * spa_nvlist_lookup_by_guid (nvlist_t **nvpp, int count, uint64_t target_guid)
static void spa_vdev_remove_aux (nvlist_t *config, char *name, nvlist_t **dev, int count, nvlist_t *dev_to_remove)
static int spa_vdev_remove_evacuate (spa_t *spa, vdev_t *vd)
 Evacuate the device.
static void spa_vdev_remove_from_namespace (spa_t *spa, vdev_t *vd)
 Complete the removal by cleaning up the namespace.
int spa_vdev_remove (spa_t *spa, uint64_t guid, boolean_t unspare)
 Remove a device from the pool.
static vdev_tspa_vdev_resilver_done_hunt (vdev_t *vd)
 Find any device that's done replacing, or a vdev marked 'unspare' that's current spared, so we can detach it.
int spa_vdev_set_common (spa_t *spa, uint64_t guid, const char *value, boolean_t ispath)
 Update the stored path or FRU for this vdev.
int spa_vdev_setpath (spa_t *spa, uint64_t guid, const char *newpath)
int spa_vdev_setfru (spa_t *spa, uint64_t guid, const char *newfru)
int spa_scan_stop (spa_t *spa)
int spa_scan (spa_t *spa, pool_scan_func_t func)
static void spa_async_remove (spa_t *spa, vdev_t *vd)
static void spa_async_probe (spa_t *spa, vdev_t *vd)
static void spa_async_autoexpand (spa_t *spa, vdev_t *vd)
static void spa_async_thread (void *arg)
void spa_async_suspend (spa_t *spa)
void spa_async_resume (spa_t *spa)
static int spa_async_tasks_pending (spa_t *spa)
static void spa_async_dispatch (spa_t *spa)
void spa_async_request (spa_t *spa, int task)
static int bpobj_enqueue_cb (void *arg, const blkptr_t *bp, dmu_tx_t *tx)
static int spa_free_sync_cb (void *arg, const blkptr_t *bp, dmu_tx_t *tx)
static void spa_sync_nvlist (spa_t *spa, uint64_t obj, nvlist_t *nv, dmu_tx_t *tx)
static void spa_sync_aux_dev (spa_t *spa, spa_aux_vdev_t *sav, dmu_tx_t *tx, const char *config, const char *entry)
static void spa_sync_config_object (spa_t *spa, dmu_tx_t *tx)
static void spa_sync_version (void *arg1, void *arg2, dmu_tx_t *tx)
static void spa_sync_props (void *arg1, void *arg2, dmu_tx_t *tx)
 Set zpool properties.
static void spa_sync_upgrades (spa_t *spa, dmu_tx_t *tx)
 Perform one-time upgrade on-disk changes.
void spa_sync (spa_t *spa, uint64_t txg)
 Sync the specified transaction group.
void spa_sync_allpools (void)
 Sync all pools.
void spa_evict_all (void)
 Remove all pools in the system.
vdev_tspa_lookup_by_guid (spa_t *spa, uint64_t guid, boolean_t aux)
void spa_upgrade (spa_t *spa, uint64_t version)
boolean_t spa_has_spare (spa_t *spa, uint64_t guid)
void spa_event_notify (spa_t *spa, vdev_t *vd, const char *name)
 Post a sysevent corresponding to the given event.

Variables

int check_hostid = 1
 Check hostid on import?
int zfs_ccw_retry_interval = 300
 The interval at which failed configuration cache file writes should be retried.
static const char *const zio_taskq_types [ZIO_TASKQ_TYPES]
const zio_taskq_info_t zio_taskqs [ZIO_TYPES][ZIO_TASKQ_TYPES]
 Define the taskq threads for the following I/O types: NULL, READ, WRITE, FREE, CLAIM, and IOCTL.
static dsl_syncfunc_t spa_sync_version
static dsl_syncfunc_t spa_sync_props
static dsl_checkfunc_t spa_change_guid_check
static dsl_syncfunc_t spa_change_guid_sync
uint_t zio_taskq_batch_pct = 100
 1 thread per cpu in pset
uint_t zio_taskq_basedc = 80
 base duty cycle
boolean_t spa_create_process = B_TRUE
 no process ==> no sysdc

Detailed Description

Storage Pool Allocator.

This file contains all the routines used when modifying on-disk SPA state. This includes opening, importing, destroying, exporting a pool, and syncing a pool.

Definition in file spa.c.


Define Documentation

#define TRYIMPORT_NAME   "$import"

This (illegal) pool name is used when temporarily importing a spa_t in order to get the vdev stats associated with the imported devices.

Definition at line 166 of file spa.c.

#define ZTI_BATCH   { zti_mode_batch, 0 }

Definition at line 113 of file spa.c.

#define ZTI_FIX (   n)    { zti_mode_fixed, (n) }

Definition at line 111 of file spa.c.

#define ZTI_NULL   { zti_mode_null, 0 }

Definition at line 114 of file spa.c.

#define ZTI_ONE   ZTI_FIX(1)

Definition at line 116 of file spa.c.

#define ZTI_PCT (   n)    { zti_mode_online_percent, (n) }

Definition at line 112 of file spa.c.


Typedef Documentation

typedef enum zti_modes zti_modes_t

Enumeration Type Documentation

enum zti_modes
Enumerator:
zti_mode_fixed 

value is # of threads (min 1)

zti_mode_online_percent 

value is % of online CPUs

zti_mode_batch 

cpu-intensive; value is ignored

zti_mode_null 

don't create a taskq

zti_nmodes 

Definition at line 103 of file spa.c.


Function Documentation

static int bpobj_enqueue_cb ( void *  arg,
const blkptr_t bp,
dmu_tx_t tx 
) [static]

Definition at line 5832 of file spa.c.

static int load_nvlist ( spa_t spa,
uint64_t  obj,
nvlist_t **  value 
) [static]

Definition at line 1515 of file spa.c.

static void spa_activate ( spa_t spa,
int  mode 
) [static]

Activate an uninitialized pool.

Definition at line 978 of file spa.c.

static void spa_activate_log ( spa_t spa) [static]

Definition at line 1720 of file spa.c.

static void spa_add_feature_stats ( spa_t spa,
nvlist_t *  config 
) [static]

Definition at line 3061 of file spa.c.

static void spa_add_l2cache ( spa_t spa,
nvlist_t *  config 
) [static]

Add l2cache device information to the nvlist, including vdev stats.

Definition at line 3009 of file spa.c.

static void spa_add_spares ( spa_t spa,
nvlist_t *  config 
) [static]

Add spares device information to the nvlist.

Definition at line 2960 of file spa.c.

static void spa_async_autoexpand ( spa_t spa,
vdev_t vd 
) [static]

Definition at line 5652 of file spa.c.

static void spa_async_dispatch ( spa_t spa) [static]

Definition at line 5804 of file spa.c.

static void spa_async_probe ( spa_t spa,
vdev_t vd 
) [static]

Definition at line 5640 of file spa.c.

static void spa_async_remove ( spa_t spa,
vdev_t vd 
) [static]

Definition at line 5615 of file spa.c.

void spa_async_request ( spa_t spa,
int  task 
)

Definition at line 5817 of file spa.c.

void spa_async_resume ( spa_t spa)

Definition at line 5775 of file spa.c.

void spa_async_suspend ( spa_t spa)

Definition at line 5765 of file spa.c.

static int spa_async_tasks_pending ( spa_t spa) [static]

Definition at line 5784 of file spa.c.

static void spa_async_thread ( void *  arg) [static]

Definition at line 5678 of file spa.c.

static void spa_aux_check_removed ( spa_aux_vdev_t sav) [static]

Definition at line 1754 of file spa.c.

int spa_change_guid ( spa_t spa)

Change the GUID for the pool.

This is done so that we can later re-import a pool built from a clone of our own vdevs. We will modify the root vdev's guid, our own pool guid, and then mark all of our vdevs dirty. Note that we must make sure that all our vdevs are online when we do this, or else any vdevs that weren't present would be orphaned from our pool. We are also going to issue a sysevent to update any watchers.

Definition at line 768 of file spa.c.

static int spa_change_guid_check ( void *  arg1,
void *  arg2,
dmu_tx_t tx 
) [static]

Definition at line 710 of file spa.c.

static void spa_change_guid_sync ( void *  arg1,
void *  arg2,
dmu_tx_t tx 
) [static]

Definition at line 730 of file spa.c.

static int spa_check_logs ( spa_t spa) [static]

Check for missing log devices.

Definition at line 1679 of file spa.c.

static void spa_check_removed ( vdev_t vd) [static]

Checks to see if the given vdev could not be opened, in which case we post a sysevent to notify the autoreplace code that the device has been removed.

Definition at line 1542 of file spa.c.

void spa_claim_notify ( zio_t zio)

Log claim callback.

Definition at line 1766 of file spa.c.

static int spa_config_parse ( spa_t spa,
vdev_t **  vdp,
nvlist_t *  nv,
vdev_t parent,
uint_t  id,
int  atype 
) [static]

Verify a pool configuration, and construct the vdev tree appropriately.

This will create all the necessary vdevs in the appropriate layout, with each vdev in the CLOSED state. This will prep the pool before open/creation/import. All vdev validation is done by the vdev_alloc() routine.

Definition at line 1128 of file spa.c.

static boolean_t spa_config_valid ( spa_t spa,
nvlist_t *  config 
) [static]

Validate the current config against the MOS config.

Definition at line 1557 of file spa.c.

void spa_configfile_set ( spa_t spa,
nvlist_t *  nvp,
boolean_t  need_sync 
)

Definition at line 612 of file spa.c.

int spa_create ( const char *  pool,
nvlist_t *  nvroot,
nvlist_t *  props,
const char *  history_str,
nvlist_t *  zplprops 
)

Pool Creation.

Definition at line 3346 of file spa.c.

static void spa_create_zio_taskqs ( spa_t spa) [static]

Definition at line 880 of file spa.c.

static void spa_deactivate ( spa_t spa) [static]

Opposite of spa_activate().

Definition at line 1049 of file spa.c.

int spa_destroy ( char *  pool)

Destroy a storage pool.

Definition at line 4285 of file spa.c.

static int spa_dir_prop ( spa_t spa,
const char *  name,
uint64_t *  val 
) [static]

Find a value in the pool directory object.

Definition at line 1887 of file spa.c.

static int spa_error_entry_compare ( const void *  a,
const void *  b 
) [static]

Definition at line 796 of file spa.c.

void spa_event_notify ( spa_t spa,
vdev_t vd,
const char *  name 
)

Post a sysevent corresponding to the given event.

Parameters:
[in]spaProvides information for the event payload
[in]vdOptional. If not null, provides informationfor the event payload
[in]namemust be one of the event definitions in sys/sysevent/eventdefs.h

This doesn't do anything in the userland libzpool, as we don't want consumers to misinterpret ztest or zdb as real changes.

Definition at line 6551 of file spa.c.

void spa_evict_all ( void  )

Remove all pools in the system.

Definition at line 6416 of file spa.c.

int spa_export ( char *  pool,
nvlist_t **  oldconfig,
boolean_t  force,
boolean_t  hardforce 
)

Export a storage pool.

Definition at line 4295 of file spa.c.

static int spa_export_common ( char *  pool,
int  new_state,
nvlist_t **  oldconfig,
boolean_t  force,
boolean_t  hardforce 
) [static]

Pool export/destroy.

The act of destroying or exporting a pool is very simple. We make sure there is no more pending I/O and any references to the pool are gone. Then, we update the pool state and sync all the labels to disk, removing the configuration from the cache afterwards. If the 'hardforce' flag is set, then we don't sync the labels or remove the configuration cache.

Definition at line 4182 of file spa.c.

static int spa_free_sync_cb ( void *  arg,
const blkptr_t bp,
dmu_tx_t tx 
) [static]

Definition at line 5840 of file spa.c.

static nvlist_t* spa_generate_rootconf ( const char *  name) [static]

Definition at line 3786 of file spa.c.

void spa_get_errlists ( spa_t spa,
avl_tree_t *  last,
avl_tree_t *  scrub 
)

Utility function which retrieves copies of the current logs and re-initializes them in the process.

Definition at line 818 of file spa.c.

int spa_get_stats ( const char *  name,
nvlist_t **  config,
char *  altroot,
size_t  buflen 
)

Definition at line 3102 of file spa.c.

static boolean_t spa_has_active_shared_spare ( spa_t spa) [static]

Check if a pool has an active shared spare device.

Note:
The reference count of an active spare is 2, as a spare and as a replace.

Definition at line 6522 of file spa.c.

boolean_t spa_has_spare ( spa_t spa,
uint64_t  guid 
)

Definition at line 6496 of file spa.c.

int spa_import ( const char *  pool,
nvlist_t *  config,
nvlist_t *  props,
uint64_t  flags 
)

Import a non-root pool into the system.

Definition at line 3894 of file spa.c.

int spa_import_rootpool ( const char *  name)

Definition at line 3824 of file spa.c.

spa_t* spa_inject_addref ( char *  name)

Increment a SPA's inject count.

Lookup the given spa_t, incrementing the inject count in the process, preventing it from being exported or destroyed.

Definition at line 2933 of file spa.c.

void spa_inject_delref ( spa_t spa)

Definition at line 2949 of file spa.c.

void spa_l2cache_drop ( spa_t spa)

Stop and drop level 2 ARC devices.

Definition at line 3324 of file spa.c.

static int spa_load ( spa_t spa,
spa_load_state_t  state,
spa_import_type_t  type,
boolean_t  mosconfig 
) [static]

Definition at line 1983 of file spa.c.

static int spa_load_best ( spa_t spa,
spa_load_state_t  state,
int  mosconfig,
uint64_t  max_request,
int  rewind_flags 
) [static]

If spa_load() fails this function will try loading prior txg's.

If 'state' is SPA_LOAD_RECOVER and one of these loads succeeds the pool will be rewound to that txg. If 'state' is not SPA_LOAD_RECOVER this function will not rewind the pool and will return the same error as spa_load().

Definition at line 2699 of file spa.c.

static int spa_load_impl ( spa_t spa,
uint64_t  pool_guid,
nvlist_t *  config,
spa_load_state_t  state,
spa_import_type_t  type,
boolean_t  mosconfig,
char **  ereport 
) [static]

Load an existing storage pool, using the pool's builtin spa_config as a source of configuration information.

Definition at line 2052 of file spa.c.

static void spa_load_l2cache ( spa_t spa) [static]

Load (or re-load) the current list of vdevs describing the active l2cache for this pool.

When this is called, we have some form of basic information in 'spa_l2cache.sav_config'. We parse this into vdevs, try to open them, and then re-generate a more complete list including status information. Devices which are already active have their details maintained, and are not re-opened.

Definition at line 1393 of file spa.c.

static int spa_load_retry ( spa_t spa,
spa_load_state_t  state,
int  mosconfig 
) [static]

Definition at line 2676 of file spa.c.

static void spa_load_spares ( spa_t spa) [static]

Load (or re-load) the current list of vdevs describing the active spares for this pool.

When this is called, we have some form of basic information in 'spa_spares.sav_config'. We parse this into vdevs, try to open them, and then re-generate a more complete list including status information.

Definition at line 1276 of file spa.c.

static int spa_load_verify ( spa_t spa) [static]

Definition at line 1821 of file spa.c.

static int spa_load_verify_cb ( spa_t spa,
zilog_t zilog,
const blkptr_t bp,
arc_buf_t pbuf,
const zbookmark_t zb,
const dnode_phys_t dnp,
void *  arg 
) [static]

Definition at line 1804 of file spa.c.

static void spa_load_verify_done ( zio_t zio) [static]

Definition at line 1785 of file spa.c.

vdev_t* spa_lookup_by_guid ( spa_t spa,
uint64_t  guid,
boolean_t  aux 
)

Definition at line 6447 of file spa.c.

static nvlist_t* spa_nvlist_lookup_by_guid ( nvlist_t **  nvpp,
int  count,
uint64_t  target_guid 
) [static]

Definition at line 5161 of file spa.c.

int spa_offline_log ( spa_t spa)

Definition at line 1736 of file spa.c.

int spa_open ( const char *  name,
spa_t **  spapp,
void *  tag 
)

Definition at line 2921 of file spa.c.

static int spa_open_common ( const char *  pool,
spa_t **  spapp,
void *  tag,
nvlist_t *  nvpolicy,
nvlist_t **  config 
) [static]

Pool Open/Import.

The import case is identical to an open except that the configuration is sent down from userland, instead of grabbed from the configuration cache. For the case of an open, the pool configuration will exist in the POOL_STATE_UNINITIALIZED state.

The stats information (gen/count/ustats) is used to gather vdev statistics at the same time open the pool, without having to keep around the spa_t in some ambiguous state.

Definition at line 2795 of file spa.c.

int spa_open_rewind ( const char *  name,
spa_t **  spapp,
void *  tag,
nvlist_t *  policy,
nvlist_t **  config 
)

Definition at line 2914 of file spa.c.

static boolean_t spa_passivate_log ( spa_t spa) [static]

Definition at line 1696 of file spa.c.

static void spa_prop_add_list ( nvlist_t *  nvl,
zpool_prop_t  prop,
char *  strval,
uint64_t  intval,
zprop_source_t  src 
) [static]

Add a (source=src, propname=propval) list to an nvlist.

Definition at line 178 of file spa.c.

void spa_prop_clear_bootfs ( spa_t spa,
uint64_t  dsobj,
dmu_tx_t tx 
)

If the bootfs property value is dsobj, clear it.

Definition at line 698 of file spa.c.

static void spa_prop_find ( spa_t spa,
zpool_prop_t  prop,
uint64_t *  val 
) [static]

Find a value in the pool props object.

Definition at line 1877 of file spa.c.

int spa_prop_get ( spa_t spa,
nvlist_t **  nvp 
)

Get zpool property values.

Definition at line 292 of file spa.c.

static void spa_prop_get_config ( spa_t spa,
nvlist_t **  nvp 
) [static]

Get property values from the spa configuration.

Definition at line 200 of file spa.c.

int spa_prop_set ( spa_t spa,
nvlist_t *  nvp 
)

Definition at line 637 of file spa.c.

static int spa_prop_validate ( spa_t spa,
nvlist_t *  props 
) [static]

Validate the given pool properties nvlist and modify the list for the property values to be set.

Definition at line 400 of file spa.c.

int spa_reset ( char *  pool)

Reset a storage pool.

Similar to spa_export(), this unloads the spa_t without actually removing it from the namespace in any way.

Definition at line 4309 of file spa.c.

int spa_scan ( spa_t spa,
pool_scan_func_t  func 
)

Definition at line 5588 of file spa.c.

int spa_scan_stop ( spa_t spa)

Definition at line 5579 of file spa.c.

static void spa_set_aux_vdevs ( spa_aux_vdev_t sav,
nvlist_t **  devs,
int  ndevs,
const char *  config 
) [static]

Definition at line 3275 of file spa.c.

void spa_sync ( spa_t spa,
uint64_t  txg 
)

Sync the specified transaction group.

New blocks may be dirtied as part of the process, so we iterate until it converges.

Only for DMU use

Definition at line 6160 of file spa.c.

void spa_sync_allpools ( void  )

Sync all pools.

We don't want to hold the namespace lock across these operations, so we take a reference on the spa_t and drop the lock during the sync.

Definition at line 6389 of file spa.c.

static void spa_sync_aux_dev ( spa_t spa,
spa_aux_vdev_t sav,
dmu_tx_t tx,
const char *  config,
const char *  entry 
) [static]

Definition at line 5882 of file spa.c.

static void spa_sync_config_object ( spa_t spa,
dmu_tx_t tx 
) [static]

Definition at line 5928 of file spa.c.

static void spa_sync_nvlist ( spa_t spa,
uint64_t  obj,
nvlist_t *  nv,
dmu_tx_t tx 
) [static]

Definition at line 5850 of file spa.c.

static void spa_sync_props ( void *  arg1,
void *  arg2,
dmu_tx_t tx 
) [static]

Set zpool properties.

Definition at line 5971 of file spa.c.

static void spa_sync_upgrades ( spa_t spa,
dmu_tx_t tx 
) [static]

Perform one-time upgrade on-disk changes.

spa_version() does not reflect the new version this txg, so there must be no changes this txg to anything that the upgrade code depends on after it executes. Therefore this must be called after dsl_pool_sync() does the sync tasks.

Definition at line 6120 of file spa.c.

static void spa_sync_version ( void *  arg1,
void *  arg2,
dmu_tx_t tx 
) [static]

Definition at line 5950 of file spa.c.

static taskq_t* spa_taskq_create ( spa_t spa,
const char *  name,
enum zti_modes  mode,
uint_t  value 
) [static]

Definition at line 834 of file spa.c.

static void spa_try_repair ( spa_t spa,
nvlist_t *  config 
) [static]

Fix up config after a partly-completed split.

This is done with the ZPOOL_CONFIG_SPLIT nvlist. Both the splitting pool and the split-off pool have that entry in their config, but only the splitting one contains a list of all the guids of the vdevs that are being split off.

This function determines what to do with that list: either rejoin all the disks to the pool, or complete the splitting process. To attempt the rejoin, each disk that is offlined is marked online again, and we do a reopen() call. If the vdev label for every disk that was marked online indicates it was successfully split off (VDEV_AUX_SPLIT_POOL) then we call vdev_split() on each disk, and complete the split.

Otherwise we leave the config alone, with all the vdevs in place in the original pool.

Definition at line 1917 of file spa.c.

nvlist_t* spa_tryimport ( nvlist_t *  tryconfig)

Definition at line 4081 of file spa.c.

static void spa_unload ( spa_t spa) [static]

Opposite of spa_load().

Definition at line 1172 of file spa.c.

void spa_upgrade ( spa_t spa,
uint64_t  version 
)

Definition at line 6473 of file spa.c.

static int spa_validate_aux ( spa_t spa,
nvlist_t *  nvroot,
uint64_t  crtxg,
int  mode 
) [static]

Definition at line 3257 of file spa.c.

static int spa_validate_aux_devs ( spa_t spa,
nvlist_t *  nvroot,
uint64_t  crtxg,
int  mode,
spa_aux_vdev_t sav,
const char *  config,
uint64_t  version,
vdev_labeltype_t  label 
) [static]

Validate that the auxiliary device array is well formed.

We must have an array of nvlists, each which describes a valid leaf vdev. If this is an import (mode is VDEV_ALLOC_SPARE), then we allow corrupted spares to be specified, as long as they are well-formed.

Definition at line 3176 of file spa.c.

int spa_vdev_add ( spa_t spa,
nvlist_t *  nvroot 
)

Add a device to a storage pool.

Definition at line 4325 of file spa.c.

int spa_vdev_attach ( spa_t spa,
uint64_t  guid,
nvlist_t *  nvroot,
int  replacing 
)

Attach a device to a mirror.

The arguments are the path to any device in the mirror, and the nvroot for the new device. If the path specifies a device that is not mirrored, we automatically insert the mirror vdev.

If 'replacing' is specified, the new device is intended to replace the existing device; in this case the two devices are made into their own mirror using the 'replacing' vdev, which is functionally identical to the mirror vdev (it actually reuses all the same ops) but has a few extra rules: you can't attach to it after it's been created, and upon completion of resilvering, the first disk (the one being replaced) is automatically detached.

Definition at line 4437 of file spa.c.

int spa_vdev_detach ( spa_t spa,
uint64_t  guid,
uint64_t  pguid,
int  replace_done 
)

Detach a device from a mirror or replacing vdev.

If 'replace_done' is specified, only detach if the parent is a replacing vdev.

Definition at line 4637 of file spa.c.

static int spa_vdev_err ( vdev_t vdev,
vdev_aux_t  aux,
int  err 
) [static]

Definition at line 1894 of file spa.c.

int spa_vdev_remove ( spa_t spa,
uint64_t  guid,
boolean_t  unspare 
)

Remove a device from the pool.

Removing a device from the vdev namespace requires several steps and can take a significant amount of time. As a result we use the spa_vdev_config_[enter/exit] functions which allow us to grab and release the spa_config_lock while still holding the namespace lock. During each step the configuration is synced out.

Currently, this supports removing only hot spares, slogs, and level 2 ARC devices.

Definition at line 5300 of file spa.c.

static void spa_vdev_remove_aux ( nvlist_t *  config,
char *  name,
nvlist_t **  dev,
int  count,
nvlist_t *  dev_to_remove 
) [static]

Definition at line 5177 of file spa.c.

static int spa_vdev_remove_evacuate ( spa_t spa,
vdev_t vd 
) [static]

Evacuate the device.

Definition at line 5205 of file spa.c.

static void spa_vdev_remove_from_namespace ( spa_t spa,
vdev_t vd 
) [static]

Complete the removal by cleaning up the namespace.

Definition at line 5248 of file spa.c.

static void spa_vdev_resilver_done ( spa_t spa) [static]

Definition at line 5485 of file spa.c.

static vdev_t* spa_vdev_resilver_done_hunt ( vdev_t vd) [static]

Find any device that's done replacing, or a vdev marked 'unspare' that's current spared, so we can detach it.

Definition at line 5410 of file spa.c.

int spa_vdev_set_common ( spa_t spa,
uint64_t  guid,
const char *  value,
boolean_t  ispath 
)

Update the stored path or FRU for this vdev.

Definition at line 5524 of file spa.c.

int spa_vdev_setfru ( spa_t spa,
uint64_t  guid,
const char *  newfru 
)

Definition at line 5567 of file spa.c.

int spa_vdev_setpath ( spa_t spa,
uint64_t  guid,
const char *  newpath 
)

Definition at line 5561 of file spa.c.

int spa_vdev_split_mirror ( spa_t spa,
char *  newname,
nvlist_t *  config,
nvlist_t *  props,
boolean_t  exp 
)

Split a set of devices from their mirrors, and create a new pool from them.

Definition at line 4875 of file spa.c.

SYSCTL_DECL ( _vfs_zfs  )
SYSCTL_INT ( _vfs_zfs  ,
OID_AUTO  ,
check_hostid  ,
CTLFLAG_RW  ,
check_hostid,
,
"Check hostid on import?"   
)
SYSCTL_INT ( _vfs_zfs  ,
OID_AUTO  ,
ccw_retry_interval  ,
CTLFLAG_RW  ,
zfs_ccw_retry_interval,
,
"Configuration cache file  write,
retry after  failure,
interval(seconds)"   
)
TUNABLE_INT ( "vfs.zfs.ccw_retry_interval"  ,
zfs_ccw_retry_interval 
)
TUNABLE_INT ( "vfs.zfs.check_hostid"  ,
check_hostid 
)
int vdev_geom_read_pool_label ( const char *  name,
nvlist_t **  config 
)

Definition at line 448 of file vdev_geom.c.


Variable Documentation

dsl_checkfunc_t spa_change_guid_check [static]

Definition at line 143 of file spa.c.

dsl_syncfunc_t spa_change_guid_sync [static]

Definition at line 144 of file spa.c.

boolean_t spa_create_process = B_TRUE

no process ==> no sysdc

Definition at line 160 of file spa.c.

dsl_syncfunc_t spa_sync_props [static]

Definition at line 142 of file spa.c.

dsl_syncfunc_t spa_sync_version [static]

Definition at line 141 of file spa.c.

uint_t zio_taskq_basedc = 80

base duty cycle

Definition at line 158 of file spa.c.

uint_t zio_taskq_batch_pct = 100

1 thread per cpu in pset

Definition at line 151 of file spa.c.

const char* const zio_taskq_types[ZIO_TASKQ_TYPES] [static]
Initial value:
 {
        "issue", "issue_high", "intr", "intr_high"
}

Definition at line 123 of file spa.c.

const zio_taskq_info_t zio_taskqs[ZIO_TYPES][ZIO_TASKQ_TYPES]
Initial value:
 {
        
        { ZTI_ONE,      ZTI_NULL,       ZTI_ONE,        ZTI_NULL },
        { ZTI_FIX(8),   ZTI_NULL,       ZTI_BATCH,      ZTI_NULL },
        { ZTI_BATCH,    ZTI_FIX(5),     ZTI_FIX(8),     ZTI_FIX(5) },
        { ZTI_FIX(100), ZTI_NULL,       ZTI_ONE,        ZTI_NULL },
        { ZTI_ONE,      ZTI_NULL,       ZTI_ONE,        ZTI_NULL },
        { ZTI_ONE,      ZTI_NULL,       ZTI_ONE,        ZTI_NULL },
}

Define the taskq threads for the following I/O types: NULL, READ, WRITE, FREE, CLAIM, and IOCTL.

Definition at line 131 of file spa.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines