libstorage-ng
 
Loading...
Searching...
No Matches
storage::LvmLv Class Reference

A Logical Volume of the Logical Volume Manager (LVM). More...

#include <LvmLv.h>

Inheritance diagram for storage::LvmLv:
[legend]
Collaboration diagram for storage::LvmLv:
[legend]

Public Member Functions

const std::string & get_lv_name () const
 Get the logical volume name.
 
void set_lv_name (const std::string &lv_name)
 Set the logical volume name.
 
LvType get_lv_type () const
 Return the logical volume type.
 
unsigned int get_stripes () const
 Get the number of stripes.
 
void set_stripes (unsigned int stripes)
 Set the number of stripes.
 
unsigned long long get_stripe_size () const
 Get the stripe size.
 
void set_stripe_size (unsigned long long stripe_size)
 Set the stripe size.
 
unsigned long long get_chunk_size () const
 Get the chunk size.
 
void set_chunk_size (unsigned long long chunk_size)
 Set the chunk size.
 
const LvmVgget_lvm_vg () const
 Return volume group this logical volume belongs to.
 
const LvmLvget_thin_pool () const
 Return the thin pool for a thin logical volume.
 
bool has_snapshots () const
 Check whether the logical volume has snapshots.
 
std::vector< LvmLv * > get_snapshots ()
 Get snapshots of the logical volume.
 
std::vector< const LvmLv * > get_snapshots () const
 Get snapshots of the logical volume.
 
bool has_origin () const
 Check whether the logical volume has an origin.
 
LvmLvget_origin ()
 Get the origin of the logical volume if it has one.
 
const LvmLvget_origin () const
 Get the origin of the logical volume if it has one.
 
unsigned long long max_size_for_lvm_lv (LvType lv_type) const
 Return the max size in bytes for a new logical volume of type lv_type.
 
LvmLvcreate_lvm_lv (const std::string &lv_name, LvType lv_type, unsigned long long size)
 Create a logical volume with name lv_name and type lv_type in the thin pool.
 
LvmLvget_lvm_lv (const std::string &lv_name)
 
std::vector< LvmLv * > get_lvm_lvs ()
 
std::vector< const LvmLv * > get_lvm_lvs () const
 
Impl & get_impl ()
 
const Impl & get_impl () const
 
virtual LvmLvclone () const override
 
 LvmLv (Impl *impl)
 
- Public Member Functions inherited from storage::BlkDevice
const std::string & get_name () const
 
void set_name (const std::string &name)
 
const Regionget_region () const
 
void set_region (const Region &region)
 
unsigned long long get_size () const
 Returns the size of the block device.
 
void set_size (unsigned long long size)
 Set the size of the block device.
 
std::string get_size_string () const
 Returns the size of the block device as a localised string.
 
const Topologyget_topology () const
 Get the topology.
 
void set_topology (const Topology &topology)
 Set the topology.
 
bool is_active () const
 
bool is_read_only () const
 Return whether the block device is read-only.
 
const std::string & get_sysfs_name () const
 
const std::string & get_sysfs_path () const
 
const std::vector< std::string > & get_udev_paths () const
 Return the names of the udev by-path links of the blk device.
 
const std::vector< std::string > & get_udev_ids () const
 Return the names of the udev by-id links of the blk device.
 
bool is_usable_as_blk_device () const
 Checks whether the blk device is in general usable as a blk device.
 
RemoveInfo detect_remove_info () const
 Check whether the device can be removed.
 
const std::string & get_dm_table_name () const
 Return device-mapper table name (dm-table-name for short).
 
void set_dm_table_name (const std::string &dm_table_name)
 Set the device-mapper table name (dm-table-name for short).
 
BlkFilesystemcreate_blk_filesystem (FsType fs_type)
 Creates a block filesystem on the block device.
 
bool has_blk_filesystem () const
 Return whether the block device has a block filesystem.
 
BlkFilesystemget_blk_filesystem ()
 Return the block filesystem of the block device.
 
const BlkFilesystemget_blk_filesystem () const
 Return the block filesystem of the block device.
 
BlkFilesystemcreate_filesystem (FsType fs_type) ST_DEPRECATED
 Creates a block filesystem on the block device.
 
bool has_filesystem () const ST_DEPRECATED
 Return whether the block device has a block filesystem.
 
BlkFilesystemget_filesystem () ST_DEPRECATED
 Return the block filesystem of the block device.
 
const BlkFilesystemget_filesystem () const ST_DEPRECATED
 Return the block filesystem of the block device.
 
Encryptioncreate_encryption (const std::string &dm_table_name) ST_DEPRECATED
 Creates an encryption device on the blk device.
 
Encryptioncreate_encryption (const std::string &dm_table_name, EncryptionType type)
 Creates an encryption device on the blk device.
 
void remove_encryption ()
 Removes an encryption device on the blk device.
 
bool has_encryption () const
 Return whether the block device has an Encryption.
 
Encryptionget_encryption ()
 Return the Encryption of the block device.
 
const Encryptionget_encryption () const
 Return the Encryption of the block device.
 
Bcachecreate_bcache (const std::string &name)
 Creates a Bcache on the blk device.
 
bool has_bcache () const
 Return whether the block device has a BCache.
 
Bcacheget_bcache ()
 Return the Bcache of the block device.
 
const Bcacheget_bcache () const
 Return the Bcache of the block device.
 
BcacheCsetcreate_bcache_cset ()
 Creates a BcacheCset on the blk device.
 
bool has_bcache_cset () const
 Return whether the block device has a BcacheCset.
 
BcacheCsetget_bcache_cset ()
 Return the BcacheCset of the block device.
 
const BcacheCsetget_bcache_cset () const
 Return the BcacheCset of the block device.
 
std::vector< MountByTypepossible_mount_bys () const
 Returns the possible mount-by methods to reference the block device.
 
Impl & get_impl ()
 
const Impl & get_impl () const
 
- Public Member Functions inherited from storage::Device
sid_t get_sid () const
 Return the storage id (sid) of the device.
 
bool operator== (const Device &rhs) const
 
bool operator!= (const Device &rhs) const
 
Devicecopy_to_devicegraph (Devicegraph *devicegraph) const
 Copies the device to the devicegraph.
 
bool exists_in_devicegraph (const Devicegraph *devicegraph) const
 Checks if the device exists in the devicegraph.
 
bool exists_in_probed () const
 Checks if the device exists in the probed devicegraph.
 
bool exists_in_staging () const
 Checks if the device exists in the staging devicegraph.
 
bool exists_in_system () const
 Checks if the device exists in the system devicegraph.
 
std::string get_displayname () const
 
ResizeInfo detect_resize_info () const
 Detect the resize info of the device.
 
bool has_children () const
 
size_t num_children () const
 
bool has_parents () const
 
size_t num_parents () const
 
std::vector< Device * > get_children ()
 
std::vector< const Device * > get_children () const
 
std::vector< Device * > get_children (View view)
 Get all children of the device.
 
std::vector< const Device * > get_children (View view) const
 Get all children of the device.
 
std::vector< Device * > get_parents ()
 
std::vector< const Device * > get_parents () const
 
std::vector< Device * > get_parents (View view)
 Get all parents of the device.
 
std::vector< const Device * > get_parents (View view) const
 Get all parents of the device.
 
std::vector< Device * > get_siblings (bool itself)
 
std::vector< const Device * > get_siblings (bool itself) const
 
std::vector< Device * > get_descendants (bool itself)
 
std::vector< const Device * > get_descendants (bool itself) const
 
std::vector< Device * > get_descendants (bool itself, View view)
 
std::vector< const Device * > get_descendants (bool itself, View view) const
 
std::vector< Device * > get_ancestors (bool itself)
 
std::vector< const Device * > get_ancestors (bool itself) const
 
std::vector< Device * > get_leaves (bool itself)
 
std::vector< const Device * > get_leaves (bool itself) const
 
std::vector< Device * > get_roots (bool itself)
 
std::vector< const Device * > get_roots (bool itself) const
 
std::vector< Holder * > get_in_holders ()
 
std::vector< const Holder * > get_in_holders () const
 
std::vector< Holder * > get_out_holders ()
 
std::vector< const Holder * > get_out_holders () const
 
void remove_descendants () ST_DEPRECATED
 
void remove_descendants (View view)
 Remove all descendants of the device.
 
const std::map< std::string, std::string > & get_userdata () const
 Return the userdata of the device.
 
void set_userdata (const std::map< std::string, std::string > &userdata)
 Set the userdata of the device.
 
std::string get_name_sort_key () const
 Get a sort-key based on the device name.
 
Devicegraphget_devicegraph ()
 Return the devicegraph the device belongs to.
 
const Devicegraphget_devicegraph () const
 Return the devicegraph the device belongs to.
 
Impl & get_impl ()
 
const Impl & get_impl () const
 
void save (xmlNode *node) const ST_DEPRECATED
 

Static Public Member Functions

static LvmLvcreate (Devicegraph *devicegraph, const std::string &vg_name, const std::string &lv_name, LvType lv_type)
 Create a device of type LvmLv.
 
static LvmLvload (Devicegraph *devicegraph, const xmlNode *node)
 
static std::vector< LvmLv * > get_all (Devicegraph *devicegraph)
 Get all LvmLvs.
 
static std::vector< const LvmLv * > get_all (const Devicegraph *devicegraph)
 Get all LvmLvs.
 
static bool is_valid_lv_name (const std::string &lv_name)
 Check whether a (new and public) logical volume name is valid.
 
static bool compare_by_lv_name (const LvmLv *lhs, const LvmLv *rhs)
 Compare (less than) two LvmLvs by lv-name.
 
- Static Public Member Functions inherited from storage::BlkDevice
static std::vector< BlkDevice * > get_all (Devicegraph *devicegraph)
 Get all BlkDevices.
 
static std::vector< const BlkDevice * > get_all (const Devicegraph *devicegraph)
 Get all BlkDevices.
 
static BlkDevicefind_by_name (Devicegraph *devicegraph, const std::string &name)
 Find a block device by its name.
 
static const BlkDevicefind_by_name (const Devicegraph *devicegraph, const std::string &name)
 Find a block device by its name.
 
static bool exists_by_any_name (const Devicegraph *devicegraph, const std::string &name, SystemInfo &system_info)
 Check if a block device by any name including any symbolic links in /dev.
 
static BlkDevicefind_by_any_name (Devicegraph *devicegraph, const std::string &name) ST_DEPRECATED
 Find a block device by any name including any symbolic links in /dev.
 
static BlkDevicefind_by_any_name (Devicegraph *devicegraph, const std::string &name, SystemInfo &system_info)
 Find a block device by any name including any symbolic links in /dev.
 
static const BlkDevicefind_by_any_name (const Devicegraph *devicegraph, const std::string &name) ST_DEPRECATED
 Find a block device by any name including any symbolic links in /dev.
 
static const BlkDevicefind_by_any_name (const Devicegraph *devicegraph, const std::string &name, SystemInfo &system_info)
 Find a block device by any name including any symbolic links in /dev.
 
static bool compare_by_dm_table_name (const BlkDevice *lhs, const BlkDevice *rhs)
 Compare (less than) two BlkDevices by DM table name.
 
- Static Public Member Functions inherited from storage::Device
static std::vector< Device * > get_all (Devicegraph *devicegraph)
 Get all Devices.
 
static std::vector< const Device * > get_all (const Devicegraph *devicegraph)
 Get all Devices.
 
static bool compare_by_sid (const Device *lhs, const Device *rhs)
 Compare (less than) two Devices by sid.
 
static bool compare_by_name (const Device *lhs, const Device *rhs)
 Compare (less than) two Devices by name.
 

Additional Inherited Members

- Protected Member Functions inherited from storage::BlkDevice
 BlkDevice (Impl *impl)
 
- Protected Member Functions inherited from storage::Device
 Device (Impl *impl)
 
void create (Devicegraph *devicegraph) ST_DEPRECATED
 Create a device in the devicegraph.
 
void load (Devicegraph *devicegraph) ST_DEPRECATED
 

Detailed Description

A Logical Volume of the Logical Volume Manager (LVM).

Member Function Documentation

◆ clone()

virtual LvmLv * storage::LvmLv::clone ( ) const
overridevirtual

Implements storage::Device.

◆ compare_by_lv_name()

static bool storage::LvmLv::compare_by_lv_name ( const LvmLv * lhs,
const LvmLv * rhs )
static

Compare (less than) two LvmLvs by lv-name.

The comparison is locale unaware.

See also
get_lv_name()

◆ create()

static LvmLv * storage::LvmLv::create ( Devicegraph * devicegraph,
const std::string & vg_name,
const std::string & lv_name,
LvType lv_type )
static

Create a device of type LvmLv.

Usually this function is not called directly. Instead LvmVg::create_lvm_lv() or LvmLv::create_lvm_lv() are called.

See also
Device::create(Devicegraph*)

◆ create_lvm_lv()

LvmLv * storage::LvmLv::create_lvm_lv ( const std::string & lv_name,
LvType lv_type,
unsigned long long size )

Create a logical volume with name lv_name and type lv_type in the thin pool.

See also
LvType
Exceptions
Exception

◆ get_all()

static std::vector< const LvmLv * > storage::LvmLv::get_all ( const Devicegraph * devicegraph)
static

Get all LvmLvs.

◆ get_chunk_size()

unsigned long long storage::LvmLv::get_chunk_size ( ) const

Get the chunk size.

Only thin pools can have a chunk size.

◆ get_lv_name()

const std::string & storage::LvmLv::get_lv_name ( ) const

Get the logical volume name.

This does not include the name of the volume group. The logical volume name is different from block device name returned by get_name().

For the logical volume name "root" the block device name maybe be "/dev/system/root".

◆ get_lv_type()

LvType storage::LvmLv::get_lv_type ( ) const

Return the logical volume type.

See also
LvType

◆ get_lvm_lv()

LvmLv * storage::LvmLv::get_lvm_lv ( const std::string & lv_name)
Exceptions
Exception

◆ get_lvm_vg()

const LvmVg * storage::LvmLv::get_lvm_vg ( ) const

Return volume group this logical volume belongs to.

Exceptions
Exception

◆ get_origin() [1/2]

LvmLv * storage::LvmLv::get_origin ( )

Get the origin of the logical volume if it has one.

See also
has_origin()
Exceptions
Exception

◆ get_origin() [2/2]

const LvmLv * storage::LvmLv::get_origin ( ) const

Get the origin of the logical volume if it has one.

See also
has_origin()
Exceptions
Exception

◆ get_snapshots() [1/2]

std::vector< LvmLv * > storage::LvmLv::get_snapshots ( )

Get snapshots of the logical volume.

See also
has_snapshots()

◆ get_snapshots() [2/2]

std::vector< const LvmLv * > storage::LvmLv::get_snapshots ( ) const

Get snapshots of the logical volume.

See also
has_snapshots()

◆ get_thin_pool()

const LvmLv * storage::LvmLv::get_thin_pool ( ) const

Return the thin pool for a thin logical volume.

Exceptions
Exception

◆ has_origin()

bool storage::LvmLv::has_origin ( ) const

Check whether the logical volume has an origin.

In other words, whether it is a snapshot. It can be either a thick or thin snapshot.

See also
has_snapshots()

◆ has_snapshots()

bool storage::LvmLv::has_snapshots ( ) const

Check whether the logical volume has snapshots.

These can be either thick or thin snapshots.

◆ max_size_for_lvm_lv()

unsigned long long storage::LvmLv::max_size_for_lvm_lv ( LvType lv_type) const

Return the max size in bytes for a new logical volume of type lv_type.

The size may be limited by other parameters, e.g. the filesystem on it.

The max size for thin logical volumes is in general theoretic since a thin pool logical volume should never be overcommited so much.

◆ set_chunk_size()

void storage::LvmLv::set_chunk_size ( unsigned long long chunk_size)

Set the chunk size.

Only thin pools can have a chunk size.

Exceptions
InvalidChunkSize,Exception

◆ set_lv_name()

void storage::LvmLv::set_lv_name ( const std::string & lv_name)

Set the logical volume name.

The library does not support to rename logical volumes on disk.

See also
get_lv_name()

◆ set_stripe_size()

void storage::LvmLv::set_stripe_size ( unsigned long long stripe_size)

Set the stripe size.

See also
set_stripes(unsigned int)
Exceptions
InvalidStripeSize,Exception

◆ set_stripes()

void storage::LvmLv::set_stripes ( unsigned int stripes)

Set the number of stripes.

The size of the LV must be a multiple of the number of stripes and the stripe size. Thin LVs cannot be striped.

Exceptions
Exception

The documentation for this class was generated from the following file: