Loading...
Searching...
No Matches
lvol.h File Reference

Logical Volume Interface. More...

Data Structures

struct  spdk_lvs_opts
 Parameters for lvolstore initialization. More...
 

Macros

#define SPDK_LVS_NAME_MAX   64
 
#define SPDK_LVOL_NAME_MAX   64
 

Typedefs

typedef void(* spdk_lvs_op_with_handle_complete) (void *cb_arg, struct spdk_lvol_store *lvol_store, int lvserrno)
 Callback definition for lvolstore operations, including handle to lvs.
 
typedef void(* spdk_lvs_op_complete) (void *cb_arg, int lvserrno)
 Callback definition for lvolstore operations without handle.
 
typedef void(* spdk_lvol_op_with_handle_complete) (void *cb_arg, struct spdk_lvol *lvol, int lvolerrno)
 Callback definition for lvol operations with handle to lvol.
 
typedef void(* spdk_lvol_op_complete) (void *cb_arg, int lvolerrno)
 Callback definition for lvol operations without handle to lvol.
 
typedef int(* spdk_lvol_iter_cb) (void *cb_arg, struct spdk_lvol *lvol)
 Callback definition for spdk_lvol_iter_clones.
 

Enumerations

enum  lvol_clear_method { LVOL_CLEAR_WITH_DEFAULT = BLOB_CLEAR_WITH_DEFAULT , LVOL_CLEAR_WITH_NONE = BLOB_CLEAR_WITH_NONE , LVOL_CLEAR_WITH_UNMAP = BLOB_CLEAR_WITH_UNMAP , LVOL_CLEAR_WITH_WRITE_ZEROES = BLOB_CLEAR_WITH_WRITE_ZEROES }
 
enum  lvs_clear_method { LVS_CLEAR_WITH_UNMAP = BS_CLEAR_WITH_UNMAP , LVS_CLEAR_WITH_WRITE_ZEROES = BS_CLEAR_WITH_WRITE_ZEROES , LVS_CLEAR_WITH_NONE = BS_CLEAR_WITH_NONE }
 

Functions

 SPDK_STATIC_ASSERT (sizeof(struct spdk_lvs_opts)==88, "Incorrect size")
 
void spdk_lvs_opts_init (struct spdk_lvs_opts *opts)
 Initialize an spdk_lvs_opts structure to the defaults.
 
int spdk_lvs_init (struct spdk_bs_dev *bs_dev, struct spdk_lvs_opts *o, spdk_lvs_op_with_handle_complete cb_fn, void *cb_arg)
 Initialize lvolstore on given bs_bdev.
 
void spdk_lvs_rename (struct spdk_lvol_store *lvs, const char *new_name, spdk_lvs_op_complete cb_fn, void *cb_arg)
 Rename the given lvolstore.
 
int spdk_lvs_unload (struct spdk_lvol_store *lvol_store, spdk_lvs_op_complete cb_fn, void *cb_arg)
 Unload lvolstore.
 
int spdk_lvs_destroy (struct spdk_lvol_store *lvol_store, spdk_lvs_op_complete cb_fn, void *cb_arg)
 Destroy lvolstore.
 
int spdk_lvol_create (struct spdk_lvol_store *lvs, const char *name, uint64_t sz, bool thin_provisioned, enum lvol_clear_method clear_method, spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg)
 Create lvol on given lvolstore with specified size.
 
void spdk_lvol_create_snapshot (struct spdk_lvol *lvol, const char *snapshot_name, spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg)
 Create snapshot of given lvol.
 
void spdk_lvol_create_clone (struct spdk_lvol *lvol, const char *clone_name, spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg)
 Create clone of given snapshot.
 
int spdk_lvol_create_esnap_clone (const void *esnap_id, uint32_t id_len, uint64_t size_bytes, struct spdk_lvol_store *lvs, const char *clone_name, spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg)
 
void spdk_lvol_rename (struct spdk_lvol *lvol, const char *new_name, spdk_lvol_op_complete cb_fn, void *cb_arg)
 Rename lvol with new_name.
 
bool spdk_lvol_deletable (struct spdk_lvol *lvol)
 Returns if it is possible to delete an lvol (i.e.
 
void spdk_lvol_destroy (struct spdk_lvol *lvol, spdk_lvol_op_complete cb_fn, void *cb_arg)
 Close lvol and remove information about lvol from its lvolstore.
 
void spdk_lvol_close (struct spdk_lvol *lvol, spdk_lvol_op_complete cb_fn, void *cb_arg)
 Close lvol, but information is kept on lvolstore.
 
int spdk_lvol_iter_immediate_clones (struct spdk_lvol *lvol, spdk_lvol_iter_cb cb_fn, void *cb_arg)
 Iterate clones of an lvol.
 
struct spdk_lvol * spdk_lvol_get_by_uuid (const struct spdk_uuid *uuid)
 Get the lvol that has a particular UUID.
 
struct spdk_lvol * spdk_lvol_get_by_names (const char *lvs_name, const char *lvol_name)
 Get the lvol that has the specified name in the specified lvolstore.
 
struct spdk_io_channel * spdk_lvol_get_io_channel (struct spdk_lvol *lvol)
 Get I/O channel of bdev associated with specified lvol.
 
void spdk_lvs_load (struct spdk_bs_dev *bs_dev, spdk_lvs_op_with_handle_complete cb_fn, void *cb_arg)
 Load lvolstore from the given blobstore device.
 
void spdk_lvs_load_ext (struct spdk_bs_dev *bs_dev, const struct spdk_lvs_opts *lvs_opts, spdk_lvs_op_with_handle_complete cb_fn, void *cb_arg)
 Load lvolstore from the given blobstore device with options.
 
void spdk_lvs_grow (struct spdk_bs_dev *bs_dev, spdk_lvs_op_with_handle_complete cb_fn, void *cb_arg)
 Grow a lvstore to fill the underlying device.
 
void spdk_lvs_grow_live (struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn, void *cb_arg)
 Grow a loaded lvstore to fill the underlying device.
 
void spdk_lvol_open (struct spdk_lvol *lvol, spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg)
 Open a lvol.
 
void spdk_lvol_inflate (struct spdk_lvol *lvol, spdk_lvol_op_complete cb_fn, void *cb_arg)
 Inflate lvol.
 
void spdk_lvol_decouple_parent (struct spdk_lvol *lvol, spdk_lvol_op_complete cb_fn, void *cb_arg)
 Decouple parent of lvol.
 
bool spdk_lvol_is_degraded (const struct spdk_lvol *lvol)
 Determine if an lvol is degraded.
 
int spdk_lvol_shallow_copy (struct spdk_lvol *lvol, struct spdk_bs_dev *ext_dev, spdk_blob_shallow_copy_status status_cb_fn, void *status_cb_arg, spdk_lvol_op_complete cb_fn, void *cb_arg)
 Make a shallow copy of lvol on given bs_dev.
 
void spdk_lvol_set_parent (struct spdk_lvol *lvol, struct spdk_lvol *snapshot, spdk_lvol_op_complete cb_fn, void *cb_arg)
 Set a snapshot as the parent of a lvol.
 
void spdk_lvol_set_external_parent (struct spdk_lvol *lvol, const void *esnap_id, uint32_t esnap_id_len, spdk_lvol_op_complete cb_fn, void *cb_arg)
 Set an external snapshot as the parent of a lvol.
 

Detailed Description

Logical Volume Interface.

Typedef Documentation

◆ spdk_lvol_iter_cb

typedef int(* spdk_lvol_iter_cb) (void *cb_arg, struct spdk_lvol *lvol)

Callback definition for spdk_lvol_iter_clones.

Parameters
lvolAn iterated lvol.
cb_argOpaque context passed to spdk_lvol_iter_clone().
Returns
0 to continue iterating, any other value to stop iterating.

◆ spdk_lvol_op_complete

typedef void(* spdk_lvol_op_complete) (void *cb_arg, int lvolerrno)

Callback definition for lvol operations without handle to lvol.

Parameters
cb_argCustom arguments
lvolerrnoError

◆ spdk_lvol_op_with_handle_complete

typedef void(* spdk_lvol_op_with_handle_complete) (void *cb_arg, struct spdk_lvol *lvol, int lvolerrno)

Callback definition for lvol operations with handle to lvol.

Parameters
cb_argCustom arguments
lvolHandle to lvol or NULL when lvserrno is set
lvolerrnoError

◆ spdk_lvs_op_complete

typedef void(* spdk_lvs_op_complete) (void *cb_arg, int lvserrno)

Callback definition for lvolstore operations without handle.

Parameters
cb_argCustom arguments
lvserrnoError

◆ spdk_lvs_op_with_handle_complete

typedef void(* spdk_lvs_op_with_handle_complete) (void *cb_arg, struct spdk_lvol_store *lvol_store, int lvserrno)

Callback definition for lvolstore operations, including handle to lvs.

Parameters
cb_argCustom arguments
lvol_storeHandle to lvol_store or NULL when lvserrno is set
lvserrnoError

Function Documentation

◆ spdk_lvol_close()

void spdk_lvol_close ( struct spdk_lvol * lvol,
spdk_lvol_op_complete cb_fn,
void * cb_arg )

Close lvol, but information is kept on lvolstore.

Parameters
lvolHandle to lvol.
cb_fnCompletion callback.
cb_argCompletion callback custom arguments.

◆ spdk_lvol_create()

int spdk_lvol_create ( struct spdk_lvol_store * lvs,
const char * name,
uint64_t sz,
bool thin_provisioned,
enum lvol_clear_method clear_method,
spdk_lvol_op_with_handle_complete cb_fn,
void * cb_arg )

Create lvol on given lvolstore with specified size.

Parameters
lvsHandle to lvolstore.
nameName of lvol.
szsize of lvol in bytes.
thin_provisionedEnables thin provisioning.
clear_methodChanges default data clusters clear method
cb_fnCompletion callback.
cb_argCompletion callback custom arguments.
Returns
0 on success, negative errno on failure.

◆ spdk_lvol_create_clone()

void spdk_lvol_create_clone ( struct spdk_lvol * lvol,
const char * clone_name,
spdk_lvol_op_with_handle_complete cb_fn,
void * cb_arg )

Create clone of given snapshot.

Parameters
lvolHandle to lvol snapshot.
clone_nameName of created clone.
cb_fnCompletion callback.
cb_argCompletion callback custom arguments.

◆ spdk_lvol_create_snapshot()

void spdk_lvol_create_snapshot ( struct spdk_lvol * lvol,
const char * snapshot_name,
spdk_lvol_op_with_handle_complete cb_fn,
void * cb_arg )

Create snapshot of given lvol.

Parameters
lvolHandle to lvol.
snapshot_nameName of created snapshot.
cb_fnCompletion callback.
cb_argCompletion callback custom arguments.

◆ spdk_lvol_decouple_parent()

void spdk_lvol_decouple_parent ( struct spdk_lvol * lvol,
spdk_lvol_op_complete cb_fn,
void * cb_arg )

Decouple parent of lvol.

Parameters
lvolHandle to lvol
cb_fnCompletion callback
cb_argCompletion callback custom arguments

◆ spdk_lvol_deletable()

bool spdk_lvol_deletable ( struct spdk_lvol * lvol)

Returns if it is possible to delete an lvol (i.e.

lvol is not a snapshot that have at least one clone).

Parameters
lvolHandle to lvol

◆ spdk_lvol_destroy()

void spdk_lvol_destroy ( struct spdk_lvol * lvol,
spdk_lvol_op_complete cb_fn,
void * cb_arg )

Close lvol and remove information about lvol from its lvolstore.

Parameters
lvolHandle to lvol.
cb_fnCompletion callback.
cb_argCompletion callback custom arguments.

◆ spdk_lvol_get_by_names()

struct spdk_lvol * spdk_lvol_get_by_names ( const char * lvs_name,
const char * lvol_name )

Get the lvol that has the specified name in the specified lvolstore.

Parameters
lvs_nameName of the lvolstore.
lvol_nameName of the lvol.
Returns
A pointer to the requested lvol on success, else NULL.

◆ spdk_lvol_get_by_uuid()

struct spdk_lvol * spdk_lvol_get_by_uuid ( const struct spdk_uuid * uuid)

Get the lvol that has a particular UUID.

Parameters
uuidThe lvol's UUID.
Returns
A pointer to the requested lvol on success, else NULL.

◆ spdk_lvol_get_io_channel()

struct spdk_io_channel * spdk_lvol_get_io_channel ( struct spdk_lvol * lvol)

Get I/O channel of bdev associated with specified lvol.

Parameters
lvolHandle to lvol.
Returns
a pointer to the I/O channel.

◆ spdk_lvol_inflate()

void spdk_lvol_inflate ( struct spdk_lvol * lvol,
spdk_lvol_op_complete cb_fn,
void * cb_arg )

Inflate lvol.

Parameters
lvolHandle to lvol
cb_fnCompletion callback
cb_argCompletion callback custom arguments

◆ spdk_lvol_is_degraded()

bool spdk_lvol_is_degraded ( const struct spdk_lvol * lvol)

Determine if an lvol is degraded.

A degraded lvol cannot perform IO.

Parameters
lvolHandle to lvol
Returns
true if the lvol has no open blob or the lvol's blob is degraded, else false.

◆ spdk_lvol_iter_immediate_clones()

int spdk_lvol_iter_immediate_clones ( struct spdk_lvol * lvol,
spdk_lvol_iter_cb cb_fn,
void * cb_arg )

Iterate clones of an lvol.

Iteration stops if cb_fn(cb_arg, clone_lvol) returns non-zero.

Parameters
lvolHandle to lvol.
cb_fnFunction to call for each lvol that clones this lvol.
cb_argContext to pass with cb_fn.
Returns
-ENOMEM if memory allocation failed, non-zero return from cb_fn(), or 0.

◆ spdk_lvol_open()

void spdk_lvol_open ( struct spdk_lvol * lvol,
spdk_lvol_op_with_handle_complete cb_fn,
void * cb_arg )

Open a lvol.

Parameters
lvolHandle to lvol.
cb_fnCompletion callback.
cb_argCompletion callback custom arguments.

◆ spdk_lvol_rename()

void spdk_lvol_rename ( struct spdk_lvol * lvol,
const char * new_name,
spdk_lvol_op_complete cb_fn,
void * cb_arg )

Rename lvol with new_name.

Parameters
lvolHandle to lvol.
new_namenew name for lvol.
cb_fnCompletion callback.
cb_argCompletion callback custom arguments.

◆ spdk_lvol_set_external_parent()

void spdk_lvol_set_external_parent ( struct spdk_lvol * lvol,
const void * esnap_id,
uint32_t esnap_id_len,
spdk_lvol_op_complete cb_fn,
void * cb_arg )

Set an external snapshot as the parent of a lvol.

This call set an external snapshot as the parent of a lvol, making the lvol a clone of this external snapshot. The previous parent of the lvol, if any, can be another external snapshot or a snapshot; if the lvol is not a clone, it must be thin-provisioned. The size of the external snapshot device must be an integer multiple of cluster size of lvol's lvolstore.

Parameters
lvolHandle to lvol
esnap_idThe identifier of the external snapshot.
esnap_id_lenThe length of esnap_id, in bytes.
cb_fnCompletion callback
cb_argCompletion callback custom arguments

◆ spdk_lvol_set_parent()

void spdk_lvol_set_parent ( struct spdk_lvol * lvol,
struct spdk_lvol * snapshot,
spdk_lvol_op_complete cb_fn,
void * cb_arg )

Set a snapshot as the parent of a lvol.

This call set a snapshot as the parent of a lvol, making the lvol a clone of this snapshot. The previous parent of the lvol, if any, can be another snapshot or an external snapshot; if the lvol is not a clone, it must be thin-provisioned. Lvol and parent snapshot must have the same size and must belong to the same lvol store.

Parameters
lvolHandle to lvol
snapshotHandle to the parent snapshot
cb_fnCompletion callback
cb_argCompletion callback custom arguments

◆ spdk_lvol_shallow_copy()

int spdk_lvol_shallow_copy ( struct spdk_lvol * lvol,
struct spdk_bs_dev * ext_dev,
spdk_blob_shallow_copy_status status_cb_fn,
void * status_cb_arg,
spdk_lvol_op_complete cb_fn,
void * cb_arg )

Make a shallow copy of lvol on given bs_dev.

Lvol must be read only and lvol size must be less or equal than bs_dev size.

Parameters
lvolHandle to lvol
ext_devThe bs_dev to copy on. This is created on the given bdev by using spdk_bdev_create_bs_dev_ext() beforehand
status_cb_fnCalled repeatedly during operation with status updates
status_cb_argArgument passed to function status_cb_fn.
cb_fnCompletion callback
cb_argCompletion callback custom arguments
Returns
0 if operation starts correctly, negative errno on failure.

◆ spdk_lvs_destroy()

int spdk_lvs_destroy ( struct spdk_lvol_store * lvol_store,
spdk_lvs_op_complete cb_fn,
void * cb_arg )

Destroy lvolstore.

All lvols have to be closed beforehand, when doing destroy.

Parameters
lvol_storeHandle to lvolstore.
cb_fnCompletion callback.
cb_argCompletion callback custom arguments.
Returns
0 on success, negative errno on failure.

◆ spdk_lvs_grow()

void spdk_lvs_grow ( struct spdk_bs_dev * bs_dev,
spdk_lvs_op_with_handle_complete cb_fn,
void * cb_arg )

Grow a lvstore to fill the underlying device.

Cannot be used on loaded lvstore.

Parameters
bs_devPointer to the blobstore device.
cb_fnCompletion callback.
cb_argCompletion callback custom arguments.

◆ spdk_lvs_grow_live()

void spdk_lvs_grow_live ( struct spdk_lvol_store * lvs,
spdk_lvs_op_complete cb_fn,
void * cb_arg )

Grow a loaded lvstore to fill the underlying device.

Parameters
lvsPointer to lvolstore.
cb_fnCompletion callback.
cb_argCompletion callback custom arguments.

◆ spdk_lvs_init()

int spdk_lvs_init ( struct spdk_bs_dev * bs_dev,
struct spdk_lvs_opts * o,
spdk_lvs_op_with_handle_complete cb_fn,
void * cb_arg )

Initialize lvolstore on given bs_bdev.

Parameters
bs_devThis is created on the given bdev by using spdk_bdev_create_bs_dev() beforehand.
oOptions for lvolstore.
cb_fnCompletion callback.
cb_argCompletion callback custom arguments.
Returns
0 on success, negative errno on failure.

◆ spdk_lvs_load()

void spdk_lvs_load ( struct spdk_bs_dev * bs_dev,
spdk_lvs_op_with_handle_complete cb_fn,
void * cb_arg )

Load lvolstore from the given blobstore device.

Parameters
bs_devPointer to the blobstore device.
cb_fnCompletion callback.
cb_argCompletion callback custom arguments.

◆ spdk_lvs_load_ext()

void spdk_lvs_load_ext ( struct spdk_bs_dev * bs_dev,
const struct spdk_lvs_opts * lvs_opts,
spdk_lvs_op_with_handle_complete cb_fn,
void * cb_arg )

Load lvolstore from the given blobstore device with options.

If lvs_opts is not NULL, it should be initialized with spdk_lvs_opts_init().

Parameters
bs_devPointer to the blobstore device.
lvs_optslvolstore options.
cb_fnCompletion callback.
cb_argCompletion callback custom arguments. blobstore.

◆ spdk_lvs_opts_init()

void spdk_lvs_opts_init ( struct spdk_lvs_opts * opts)

Initialize an spdk_lvs_opts structure to the defaults.

Parameters
optsPointer to the spdk_lvs_opts structure to initialize.

◆ spdk_lvs_rename()

void spdk_lvs_rename ( struct spdk_lvol_store * lvs,
const char * new_name,
spdk_lvs_op_complete cb_fn,
void * cb_arg )

Rename the given lvolstore.

Parameters
lvsPointer to lvolstore.
new_nameNew name of lvs.
cb_fnCompletion callback.
cb_argCompletion callback custom arguments.

◆ spdk_lvs_unload()

int spdk_lvs_unload ( struct spdk_lvol_store * lvol_store,
spdk_lvs_op_complete cb_fn,
void * cb_arg )

Unload lvolstore.

All lvols have to be closed beforehand, when doing unload.

Parameters
lvol_storeHandle to lvolstore.
cb_fnCompletion callback.
cb_argCompletion callback custom arguments.
Returns
0 on success, negative errno on failure.