|
FreeBSD ZFS
The Zettabyte File System
|
ZFS volume emulation driver. More...
#include <sys/types.h>#include <sys/param.h>#include <sys/kernel.h>#include <sys/errno.h>#include <sys/uio.h>#include <sys/bio.h>#include <sys/buf.h>#include <sys/kmem.h>#include <sys/conf.h>#include <sys/cmn_err.h>#include <sys/stat.h>#include <sys/zap.h>#include <sys/spa.h>#include <sys/zio.h>#include <sys/dmu_traverse.h>#include <sys/dnode.h>#include <sys/dsl_dataset.h>#include <sys/dsl_prop.h>#include <sys/dkio.h>#include <sys/byteorder.h>#include <sys/sunddi.h>#include <sys/dirent.h>#include <sys/policy.h>#include <sys/fs/zfs.h>#include <sys/zfs_ioctl.h>#include <sys/zil.h>#include <sys/refcount.h>#include <sys/zfs_znode.h>#include <sys/zfs_rlock.h>#include <sys/vdev_impl.h>#include <sys/zvol.h>#include <sys/zil_impl.h>#include <geom/geom.h>#include "zfs_namecheck.h"
Go to the source code of this file.
Data Structures | |
| struct | zvol_extent |
| struct | zvol_state |
| The in-core state of each volume. More... | |
| struct | maparg |
| extent mapping arg More... | |
Defines | |
| #define | ZVOL_DUMPSIZE "dumpsize" |
| #define | ZVOL_RDONLY 0x1 |
| #define | ZVOL_DUMPIFIED 0x2 |
| #define | ZVOL_EXCL 0x4 |
| #define | ZVOL_WCE 0x8 |
Typedefs | |
| typedef struct zvol_extent | zvol_extent_t |
| typedef struct zvol_state | zvol_state_t |
| The in-core state of each volume. | |
Functions | |
| DECLARE_GEOM_CLASS (zfs_zvol_class, zfs_zvol) | |
| int | zfs_set_prop_nvlist (const char *, zprop_source_t, nvlist_t *, nvlist_t **) |
| This function is best effort. | |
| static int | zvol_remove_zv (zvol_state_t *zv) |
| Remove minor node for the specified volume. | |
| static int | zvol_get_data (void *arg, lr_write_t *lr, char *buf, zio_t *zio) |
| Get data to generate a TX_WRITE intent log record. | |
| static int | zvol_dumpify (zvol_state_t *zv) |
| static int | zvol_dump_fini (zvol_state_t *zv) |
| static int | zvol_dump_init (zvol_state_t *zv, boolean_t resize) |
| static zvol_state_t * | zvol_geom_create (const char *name) |
| static void | zvol_geom_run (zvol_state_t *zv) |
| static void | zvol_geom_destroy (zvol_state_t *zv) |
| static int | zvol_geom_access (struct g_provider *pp, int acr, int acw, int ace) |
| static void | zvol_geom_start (struct bio *bp) |
| static void | zvol_geom_worker (void *arg) |
| static void | zvol_size_changed (zvol_state_t *zv) |
| int | zvol_check_volsize (uint64_t volsize, uint64_t blocksize) |
| int | zvol_check_volblocksize (uint64_t volblocksize) |
| int | zvol_get_stats (objset_t *os, nvlist_t *nv) |
| static zvol_state_t * | zvol_minor_lookup (const char *name) |
| static int | zvol_map_block (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 void | zvol_free_extents (zvol_state_t *zv) |
| static int | zvol_get_lbas (zvol_state_t *zv) |
| void | zvol_create_cb (objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx) |
| static int | zvol_replay_write (zvol_state_t *zv, lr_write_t *lr, boolean_t byteswap) |
| Replay a TX_WRITE ZIL transaction that didn't get committed after a system failure. | |
| static int | zvol_replay_err (zvol_state_t *zv, lr_t *lr, boolean_t byteswap) |
| int | zvol_create_minor (const char *name) |
| Create a minor node (plus a whole lot more) for the specified volume. | |
| int | zvol_remove_minor (const char *name) |
| int | zvol_first_open (zvol_state_t *zv) |
| void | zvol_last_close (zvol_state_t *zv) |
| int | zvol_update_volsize (objset_t *os, uint64_t volsize) |
| void | zvol_remove_minors (const char *name) |
| int | zvol_set_volsize (const char *name, major_t maj, uint64_t volsize) |
| static int | zvol_open (struct g_provider *pp, int flag, int count) |
| static int | zvol_close (struct g_provider *pp, int flag, int count) |
| static void | zvol_get_done (zgd_t *zgd, int error) |
| static void | zvol_log_write (zvol_state_t *zv, dmu_tx_t *tx, offset_t off, ssize_t resid, boolean_t sync) |
| handles synchronous writes using TX_WRITE ZIL transactions. | |
| int | zvol_strategy (struct bio *bp) |
| int | zvol_busy (void) |
| void | zvol_init (void) |
| void | zvol_fini (void) |
| boolean_t | dataset_name_hidden (const char *name) |
| static int | zvol_create_snapshots (objset_t *os, const char *name) |
| int | zvol_create_minors (const char *name) |
| static void | zvol_rename_minor (struct g_geom *gp, const char *newname) |
| void | zvol_rename_minors (const char *oldname, const char *newname) |
Variables | |
| struct g_class | zfs_zvol_class |
| void * | zfsdev_state |
| The zfsdev_state structure is protected by spa_namespace_lock from being modified while it's being used, e.g. | |
| static char * | zvol_tag = "zvol_tag" |
| static uint32_t | zvol_minors |
| int | zvol_maxphys = DMU_MAX_ACCESS/2 |
| zvol maximum transfer size in one DMU tx. | |
| zil_replay_func_t * | zvol_replay_vector [TX_MAX_TYPE] |
| Callback vectors for replaying records. | |
| ssize_t | zvol_immediate_write_sz = 32768 |
ZFS volume emulation driver.
Makes a DMU object look like a volume of arbitrary size, up to 2^64 bytes. Volumes are accessed through the symbolic links named:
/dev/zvol/dsk/<pool_name>/<dataset_name> /dev/zvol/rdsk/<pool_name>/<dataset_name>
These links are created by the /dev filesystem (sdev_zvolops.c). Volumes are persistent through reboot. No user command needs to be run before opening and using a device.
FreeBSD notes. On FreeBSD ZVOLs are simply GEOM providers like any other storage device in the system.
Definition in file zvol.c.
| typedef struct zvol_extent zvol_extent_t |
| typedef struct zvol_state zvol_state_t |
The in-core state of each volume.
| boolean_t dataset_name_hidden | ( | const char * | name | ) |
Definition at line 1975 of file zfs_ioctl.c.
| DECLARE_GEOM_CLASS | ( | zfs_zvol_class | , |
| zfs_zvol | |||
| ) |
| int zfs_set_prop_nvlist | ( | const char * | dsname, |
| zprop_source_t | source, | ||
| nvlist_t * | nvl, | ||
| nvlist_t ** | errlist | ||
| ) |
This function is best effort.
If it fails to set any of the given properties, it continues to set as many as it can and returns the first error encountered. If the caller provides a non-NULL errlist, it also gives the complete list of names of all the properties it failed to set along with the corresponding error numbers. The caller is responsible for freeing the returned errlist.
If every property is set successfully, zero is returned and the list pointed at by errlist is NULL.
Definition at line 2281 of file zfs_ioctl.c.
| int zvol_check_volsize | ( | uint64_t | volsize, |
| uint64_t | blocksize | ||
| ) |
| static int zvol_close | ( | struct g_provider * | pp, |
| int | flag, | ||
| int | count | ||
| ) | [static] |
| int zvol_create_minor | ( | const char * | name | ) |
| static int zvol_create_snapshots | ( | objset_t * | os, |
| const char * | name | ||
| ) | [static] |
| static int zvol_dump_fini | ( | zvol_state_t * | zv | ) | [static] |
| static int zvol_dump_init | ( | zvol_state_t * | zv, |
| boolean_t | resize | ||
| ) | [static] |
| static int zvol_dumpify | ( | zvol_state_t * | zv | ) | [static] |
| int zvol_first_open | ( | zvol_state_t * | zv | ) |
| static void zvol_free_extents | ( | zvol_state_t * | zv | ) | [static] |
| static int zvol_geom_access | ( | struct g_provider * | pp, |
| int | acr, | ||
| int | acw, | ||
| int | ace | ||
| ) | [static] |
| static zvol_state_t * zvol_geom_create | ( | const char * | name | ) | [static] |
| static void zvol_geom_destroy | ( | zvol_state_t * | zv | ) | [static] |
| static void zvol_geom_run | ( | zvol_state_t * | zv | ) | [static] |
| static int zvol_get_data | ( | void * | arg, |
| lr_write_t * | lr, | ||
| char * | buf, | ||
| zio_t * | zio | ||
| ) | [static] |
| static void zvol_get_done | ( | zgd_t * | zgd, |
| int | error | ||
| ) | [static] |
| static int zvol_get_lbas | ( | zvol_state_t * | zv | ) | [static] |
| void zvol_last_close | ( | zvol_state_t * | zv | ) |
| static void zvol_log_write | ( | zvol_state_t * | zv, |
| dmu_tx_t * | tx, | ||
| offset_t | off, | ||
| ssize_t | resid, | ||
| boolean_t | sync | ||
| ) | [static] |
handles synchronous writes using TX_WRITE ZIL transactions.
We store data in the log buffers if it's small enough. Otherwise we will later flush the data out via dmu_sync().
| static int zvol_map_block | ( | 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] |
| static zvol_state_t* zvol_minor_lookup | ( | const char * | name | ) | [static] |
| static int zvol_open | ( | struct g_provider * | pp, |
| int | flag, | ||
| int | count | ||
| ) | [static] |
| static int zvol_remove_zv | ( | zvol_state_t * | zv | ) | [static] |
| static void zvol_rename_minor | ( | struct g_geom * | gp, |
| const char * | newname | ||
| ) | [static] |
| void zvol_rename_minors | ( | const char * | oldname, |
| const char * | newname | ||
| ) |
| static int zvol_replay_err | ( | zvol_state_t * | zv, |
| lr_t * | lr, | ||
| boolean_t | byteswap | ||
| ) | [static] |
| static int zvol_replay_write | ( | zvol_state_t * | zv, |
| lr_write_t * | lr, | ||
| boolean_t | byteswap | ||
| ) | [static] |
| int zvol_set_volsize | ( | const char * | name, |
| major_t | maj, | ||
| uint64_t | volsize | ||
| ) |
| static void zvol_size_changed | ( | zvol_state_t * | zv | ) | [static] |
| struct g_class zfs_zvol_class |
| void* zfsdev_state |
The zfsdev_state structure is protected by spa_namespace_lock from being modified while it's being used, e.g.
an open that comes in before a create finishes. It's also protected from temporary opens of the dataset so that, e.g., an open doesn't get a spurious EBUSY.
| ssize_t zvol_immediate_write_sz = 32768 |
| int zvol_maxphys = DMU_MAX_ACCESS/2 |
uint32_t zvol_minors [static] |
| zil_replay_func_t* zvol_replay_vector[TX_MAX_TYPE] |
{
zvol_replay_err,
zvol_replay_err,
zvol_replay_err,
zvol_replay_err,
zvol_replay_err,
zvol_replay_err,
zvol_replay_err,
zvol_replay_err,
zvol_replay_err,
zvol_replay_write,
zvol_replay_err,
zvol_replay_err,
zvol_replay_err,
zvol_replay_err,
zvol_replay_err,
zvol_replay_err,
zvol_replay_err,
zvol_replay_err,
zvol_replay_err,
zvol_replay_err,
}
Callback vectors for replaying records.
Only TX_WRITE is needed for zvol.
1.7.3