FreeBSD ZFS
The Zettabyte File System
Functions | Variables

spa_config.c File Reference

Pool configuration repository. More...

#include <sys/zfs_context.h>
#include <sys/fm/fs/zfs.h>
#include <sys/spa.h>
#include <sys/spa_impl.h>
#include <sys/nvpair.h>
#include <sys/uio.h>
#include <sys/fs/zfs.h>
#include <sys/vdev_impl.h>
#include <sys/zfs_ioctl.h>
#include <sys/utsname.h>
#include <sys/sunddi.h>
#include <sys/zfeature.h>
#include <sys/kobj.h>
#include <sys/zone.h>
Include dependency graph for spa_config.c:

Go to the source code of this file.

Functions

void spa_config_load (void)
 Called when the module is first loaded, this routine loads the configuration file into the SPA namespace.
static int spa_config_write (spa_config_dirent_t *dp, nvlist_t *nvl)
void spa_config_sync (spa_t *target, boolean_t removing, boolean_t postsysevent)
 Synchronize pool configuration to disk.
nvlist_t * spa_all_configs (uint64_t *generation)
 Sigh.
void spa_config_set (spa_t *spa, nvlist_t *config)
nvlist_t * spa_config_generate (spa_t *spa, vdev_t *vd, uint64_t txg, int getstats)
 Generate the pool's configuration based on the current in-core state.
void spa_config_update (spa_t *spa, int what)
 Update all disk labels, generate a fresh config based on the current in-core state, and sync the global config cache (do not sync the config cache if this is a booting rootpool).

Variables

static uint64_t spa_config_generation = 1
const char * spa_config_path = ZPOOL_CACHE
 This can be overridden in userland to preserve an alternate namespace for userland pools when doing testing.

Detailed Description

Pool configuration repository.

Pool configuration is stored as a packed nvlist on the filesystem. By default, all pools are stored in /etc/zfs/zpool.cache and loaded on boot (when the ZFS module is loaded). Pools can also have the 'cachefile' property set that allows them to be stored in an alternate location until the control of external software.

For each cache file, we have a single nvlist which holds all the configuration information. When the module loads, we read this information from /etc/zfs/zpool.cache and populate the SPA namespace. This namespace is maintained independently in spa.c. Whenever the namespace is modified, or the configuration of a pool is changed, we call spa_config_sync(), which walks through all the active pools and writes the configuration to disk.

Definition in file spa_config.c.


Function Documentation

nvlist_t* spa_all_configs ( uint64_t *  generation)

Sigh.

Inside a local zone, we don't have access to /etc/zfs/zpool.cache, and we don't want to allow the local zone to see all the pools anyway. So we have to invent the ZFS_IOC_CONFIG ioctl to grab the configuration information for all pool visible within the zone.

Definition at line 305 of file spa_config.c.

nvlist_t* spa_config_generate ( spa_t spa,
vdev_t vd,
uint64_t  txg,
int  getstats 
)

Generate the pool's configuration based on the current in-core state.

We infer whether to generate a complete config or just one top-level config based on whether vd is the root vdev.

Definition at line 348 of file spa_config.c.

void spa_config_load ( void  )

Called when the module is first loaded, this routine loads the configuration file into the SPA namespace.

It does not actually open or load the pools; it only populates the namespace.

Definition at line 77 of file spa_config.c.

void spa_config_set ( spa_t spa,
nvlist_t *  config 
)

Definition at line 332 of file spa_config.c.

void spa_config_sync ( spa_t target,
boolean_t  removing,
boolean_t  postsysevent 
)

Synchronize pool configuration to disk.

This must be called with the namespace lock held.

Definition at line 202 of file spa_config.c.

void spa_config_update ( spa_t spa,
int  what 
)

Update all disk labels, generate a fresh config based on the current in-core state, and sync the global config cache (do not sync the config cache if this is a booting rootpool).

Definition at line 490 of file spa_config.c.

static int spa_config_write ( spa_config_dirent_t dp,
nvlist_t *  nvl 
) [static]

Definition at line 145 of file spa_config.c.


Variable Documentation

uint64_t spa_config_generation = 1 [static]

Definition at line 63 of file spa_config.c.

const char* spa_config_path = ZPOOL_CACHE

This can be overridden in userland to preserve an alternate namespace for userland pools when doing testing.

Definition at line 69 of file spa_config.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines