DeviceMapper

DeviceMapper — plugin for basic operations with device mapper

Functions

Types and Values

Includes

#include <dm.h>

Description

A plugin for basic operations with device mapper.

Functions

bd_dm_close ()

void
bd_dm_close (void);

Cleans up after the plugin. **This function is called automatically by the library's functions that unload it.**


bd_dm_init ()

gboolean
bd_dm_init (void);

Initializes the plugin. **This function is called automatically by the library's initialization functions.**


bd_dm_error_quark ()

GQuark
bd_dm_error_quark (void);

[skip]


bd_dm_create_linear ()

gboolean
bd_dm_create_linear (const gchar *map_name,
                     const gchar *device,
                     guint64 length,
                     const gchar *uuid,
                     GError **error);

Parameters

map_name

name of the map

 

device

device to create map for

 

length

length of the mapping in sectors

 

uuid

UUID for the new dev mapper device or NULL if not specified.

[nullable]

error

place to store error (if any).

[out][optional]

Returns

whether the new linear mapping map_name was successfully created for the device or not

Tech category: BD_DM_TECH_MAP-BD_DM_TECH_MODE_CREATE_ACTIVATE


bd_dm_remove ()

gboolean
bd_dm_remove (const gchar *map_name,
              GError **error);

Parameters

map_name

name of the map to remove

 

error

place to store error (if any).

[out][optional]

Returns

whether the map_name map was successfully removed or not

Tech category: BD_DM_TECH_MAP-BD_DM_TECH_MODE_REMOVE_DEACTIVATE


bd_dm_name_from_node ()

gchar *
bd_dm_name_from_node (const gchar *dm_node,
                      GError **error);

Parameters

dm_node

name of the DM node (e.g. "dm-0")

 

error

place to store error (if any).

[out][optional]

Returns

map name of the map providing the dm_node device or NULL (error ) contains the error in such cases

Tech category: BD_DM_TECH_MAP-BD_DM_TECH_MODE_QUERY


bd_dm_node_from_name ()

gchar *
bd_dm_node_from_name (const gchar *map_name,
                      GError **error);

Parameters

map_name

name of the queried DM map

 

error

place to store error (if any).

[out][optional]

Returns

DM node name for the map_name map or NULL (error ) contains the error in such cases

Tech category: BD_DM_TECH_MAP-BD_DM_TECH_MODE_QUERY


bd_dm_map_exists ()

gboolean
bd_dm_map_exists (const gchar *map_name,
                  gboolean live_only,
                  gboolean active_only,
                  GError **error);

Parameters

map_name

name of the queried map

 

live_only

whether to go through the live maps only or not

 

active_only

whether to ignore suspended maps or not

 

error

place to store error (if any).

[out][optional]

Returns

whether the given map_name exists (and is live if live_only is TRUE (and is active if active_only is TRUE)). If FALSE is returned, error indicates whether error appeared (non-NULL) or not (NULL).

Tech category: BD_DM_TECH_MAP-BD_DM_TECH_MODE_QUERY


bd_dm_get_subsystem_from_name ()

gchar *
bd_dm_get_subsystem_from_name (const gchar *device_name,
                               GError **error);

Parameters

device_name

name of the device

 

error

place to store error (if any).

[out][optional]

Returns

subsystem of the given device

Tech category: BD_DM_TECH_MAP-BD_DM_TECH_MODE_QUERY


bd_dm_get_thin_pool_stats ()

BDDMThinPoolStats *
bd_dm_get_thin_pool_stats (const gchar *map_name,
                           GError **error);

Parameters

map_name

name of the DM map (thin pool) to get stats for

 

error

place to store error (if any).

[out][optional]

Returns

physical usage stats for the thin pool map_name or NULL in case of error (error is set). This works for any device mapper thin pool, it doesn't have to be managed by LVM.

Tech category: BD_DM_TECH_MAP-BD_DM_TECH_MODE_QUERY.

[transfer full]


bd_dm_thin_pool_stats_copy ()

BDDMThinPoolStats *
bd_dm_thin_pool_stats_copy (BDDMThinPoolStats *data);

Creates a new copy of data .

[skip]

Parameters

data

BDDMThinPoolStats to copy.

[nullable]

bd_dm_thin_pool_stats_free ()

void
bd_dm_thin_pool_stats_free (BDDMThinPoolStats *data);

Frees data .

[skip]

Parameters

data

BDDMThinPoolStats to free.

[nullable]

bd_dm_is_tech_avail ()

gboolean
bd_dm_is_tech_avail (BDDMTech tech,
                     guint64 mode,
                     GError **error);

Parameters

tech

the queried tech

 

mode

a bit mask of queried modes of operation (BDDMTechMode) for tech

 

error

place to store error (details about why the tech -mode combination is not available).

[out][optional]

Returns

whether the tech -mode combination is available -- supported by the plugin implementation and having all the runtime dependencies available

Types and Values

BD_DM_ERROR

#define             BD_DM_ERROR

enum BDDMError

Members

BD_DM_ERROR_TECH_UNAVAIL

   

BD_DM_ERROR_SYS

   

BD_DM_ERROR_NOT_ROOT

   

BD_DM_ERROR_TASK

   

BD_DM_ERROR_RAID_FAIL

   

BD_DM_ERROR_RAID_NO_DEVS

   

BD_DM_ERROR_RAID_NO_EXIST

   

BD_DM_ERROR_DEVICE_NOEXIST

   

BDDMThinPoolStats

typedef struct {
    guint64 used_metadata_blocks;
    guint64 total_metadata_blocks;
    guint64 used_data_blocks;
    guint64 total_data_blocks;
    gboolean read_only;
    gboolean fail;
    gboolean out_of_data_space;
    gboolean needs_check;
} BDDMThinPoolStats;

The block sizes are not reported by the device mapper thin pool status, only the numbers of blocks. To get the space usage as a percentage divide the used blocks by the total blocks.

Members

guint64 used_metadata_blocks;

number of used metadata blocks

 

guint64 total_metadata_blocks;

total number of metadata blocks

 

guint64 used_data_blocks;

number of used data blocks

 

guint64 total_data_blocks;

total number of data blocks

 

gboolean read_only;

whether the metadata may not be changed

 

gboolean fail;

whether the pool fails all I/O

 

gboolean out_of_data_space;

whether the pool ran out of data space

 

gboolean needs_check;

whether the metadata needs a check

 

enum BDDMTech

Members

BD_DM_TECH_MAP

   

enum BDDMTechMode

Members

BD_DM_TECH_MODE_CREATE_ACTIVATE

   

BD_DM_TECH_MODE_REMOVE_DEACTIVATE

   

BD_DM_TECH_MODE_QUERY