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

A MD device. More...

#include <Md.h>

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

Public Member Functions

MdUseradd_device (BlkDevice *blk_device)
 Add another device to a RAID.
 
void remove_device (BlkDevice *blk_device)
 
std::vector< BlkDevice * > get_devices () ST_DEPRECATED
 
std::vector< const BlkDevice * > get_devices () const ST_DEPRECATED
 
std::vector< BlkDevice * > get_blk_devices ()
 Return blk devices used for the MD RAID.
 
std::vector< const BlkDevice * > get_blk_devices () const
 Return blk devices used for the MD RAID.
 
bool is_numeric () const
 Returns true if the name of the MD is numeric.
 
unsigned int get_number () const
 Returns the number of the MD.
 
MdLevel get_md_level () const
 Get the MD RAID level.
 
void set_md_level (MdLevel md_level)
 Set the MD RAID level.
 
MdParity get_md_parity () const
 Get the parity of the MD RAID.
 
void set_md_parity (MdParity md_parity)
 Set the parity of the MD RAID.
 
std::vector< MdParityget_allowed_md_parities () const
 Get the allowed parities for the MD RAID.
 
bool is_chunk_size_meaningful () const
 Is the chunk size meaningful for the RAID (so far only depends on RAID level)?
 
unsigned long get_chunk_size () const
 Get the chunk size of the MD RAID.
 
void set_chunk_size (unsigned long chunk_size)
 Set the chunk size of the MD RAID.
 
const std::string & get_uuid () const
 Get the UUID.
 
void set_uuid (const std::string &uuid)
 Set the UUID.
 
const std::string & get_metadata () const
 A string like "1.0" or "1.2" for Linux RAID, "imsm" or "ddf" for BIOS RAID containers and empty for BIOS RAID members.
 
void set_metadata (const std::string &metadata)
 Set metadata for new created Linux RAID.
 
unsigned int minimal_number_of_devices () const
 Return the minimal number of devices required by the RAID (without spare and journal devices).
 
bool supports_spare_devices () const
 Return whether the RAID supports spare devices.
 
bool supports_journal_device () const
 Return whether the RAID supports a journal device.
 
bool is_in_etc_mdadm () const
 Query whether the MD RAID is present (probed devicegraph) or will be present (staging devicegraph) in /etc/mdadm.conf.
 
void set_in_etc_mdadm (bool in_etc_mdadm)
 Set whether the MD RAID will be present in /etc/mdadm.conf.
 
Impl & get_impl ()
 
const Impl & get_impl () const
 
virtual Mdclone () const override
 
 Md (Impl *impl)
 
- Public Member Functions inherited from storage::Partitionable
const Topologyget_topology () const
 
void set_topology (const Topology &topology)
 
unsigned int get_range () const
 Query the range of device nodes available.
 
void set_range (unsigned int range)
 Set the range of device nodes available.
 
bool is_usable_as_partitionable () const
 Checks whether the partitionable is in general usable as a partitionable (can hold a partition table).
 
PtType get_default_partition_table_type () const
 Get the default partition table type for the partitionable.
 
std::vector< PtTypeget_possible_partition_table_types () const
 Get possible partition table types for the disk.
 
PartitionTablecreate_partition_table (PtType pt_type)
 Create a partition table on the partitionable.
 
bool has_partition_table () const
 Check whether the partitionable has a partition table.
 
PartitionTableget_partition_table ()
 Return the partition table of the partitionable.
 
virtual std::string partition_name (int number) const
 Return the name of the partition with the specified number.
 
const PartitionTableget_partition_table () const
 Return the partition table of the partitionable.
 
Impl & get_impl ()
 
const Impl & get_impl () const
 
- 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 Mdcreate (Devicegraph *devicegraph, const std::string &name)
 Create a MD in devicegraph with name.
 
static Mdload (Devicegraph *devicegraph, const xmlNode *node)
 
static std::vector< Md * > get_all (Devicegraph *devicegraph)
 Get all Mds.
 
static std::vector< const Md * > get_all (const Devicegraph *devicegraph)
 Get all Mds.
 
static std::vector< Md * > get_all_if (Devicegraph *devicegraph, std::function< bool(const Md *)> pred)
 Get all Mds for which the predicate pred returns true.
 
static std::vector< const Md * > get_all_if (const Devicegraph *devicegraph, std::function< bool(const Md *)> pred)
 Get all Mds for which the predicate pred returns true.
 
static Mdfind_by_name (Devicegraph *devicegraph, const std::string &name)
 Find a Md by its name.
 
static const Mdfind_by_name (const Devicegraph *devicegraph, const std::string &name)
 Find a Md by its name.
 
static std::string find_free_numeric_name (const Devicegraph *devicegraph)
 Find a free numeric name for a MD, e.g.
 
static unsigned long long calculate_underlying_size (MdLevel md_level, unsigned int number_of_devices, unsigned long long size)
 Calculate the required size of the underlying block devices to get an MD of the desired size.
 
static bool compare_by_number (const Md *lhs, const Md *rhs)
 Compare (less than) two Mds by number.
 
- Static Public Member Functions inherited from storage::Partitionable
static std::vector< Partitionable * > get_all (Devicegraph *devicegraph)
 Get all Partitionables.
 
static std::vector< const Partitionable * > get_all (const Devicegraph *devicegraph)
 Get all Partitionables.
 
static Partitionablefind_by_name (Devicegraph *devicegraph, const std::string &name)
 
static const Partitionablefind_by_name (const Devicegraph *devicegraph, const std::string &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::Partitionable
 Partitionable (Impl *impl)
 
- 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 MD device.

Member Function Documentation

◆ add_device()

MdUser * storage::Md::add_device ( BlkDevice * blk_device)

Add another device to a RAID.

For combining disks with different block sizes, see doc/md-raid.md.

Exceptions
WrongNumberOfChildren

◆ calculate_underlying_size()

static unsigned long long storage::Md::calculate_underlying_size ( MdLevel md_level,
unsigned int number_of_devices,
unsigned long long size )
static

Calculate the required size of the underlying block devices to get an MD of the desired size.

Calculation is not accurate. Does not consider details like alignment, chunk size, bitmap location or metadata version. It may also change in future versions.

Exceptions
Exception

◆ clone()

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

Implements storage::Device.

◆ compare_by_number()

static bool storage::Md::compare_by_number ( const Md * lhs,
const Md * rhs )
static

Compare (less than) two Mds by number.

See also
get_number()
Exceptions
Exception

◆ create()

static Md * storage::Md::create ( Devicegraph * devicegraph,
const std::string & name )
static

Create a MD in devicegraph with name.

Name must either be of the form "/dev/md<number>" or "/dev/md/<name>". The first form is called numeric. If name is a number it is also called numeric.

See also
Device::create(Devicegraph*)
Exceptions
Exception

◆ find_by_name() [1/2]

static const Md * storage::Md::find_by_name ( const Devicegraph * devicegraph,
const std::string & name )
static

Find a Md by its name.

Only the name returned by get_name() is considered.

Exceptions
DeviceNotFound,DeviceHasWrongType

◆ find_by_name() [2/2]

static Md * storage::Md::find_by_name ( Devicegraph * devicegraph,
const std::string & name )
static

Find a Md by its name.

Only the name returned by get_name() is considered.

Exceptions
DeviceNotFound,DeviceHasWrongType

◆ find_free_numeric_name()

static std::string storage::Md::find_free_numeric_name ( const Devicegraph * devicegraph)
static

Find a free numeric name for a MD, e.g.

"/dev/md2". A free numeric name might not be available.

Exceptions
Exception

◆ get_all()

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

Get all Mds.

◆ get_all_if()

static std::vector< const Md * > storage::Md::get_all_if ( const Devicegraph * devicegraph,
std::function< bool(const Md *)> pred )
static

Get all Mds for which the predicate pred returns true.

◆ get_allowed_md_parities()

std::vector< MdParity > storage::Md::get_allowed_md_parities ( ) const

Get the allowed parities for the MD RAID.

Only meaningful for RAID5, RAID6 and RAID10. So far depends on the MD RAID level and the number of devices.

Exceptions
Exception

◆ get_blk_devices() [1/2]

std::vector< BlkDevice * > storage::Md::get_blk_devices ( )

Return blk devices used for the MD RAID.

For Mds of type MdMember this does not include the MdContainer.

◆ get_blk_devices() [2/2]

std::vector< const BlkDevice * > storage::Md::get_blk_devices ( ) const

Return blk devices used for the MD RAID.

For Mds of type MdMember this does not include the MdContainer.

◆ get_chunk_size()

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

Get the chunk size of the MD RAID.

The chunk size is not meaningful for LINEAR nor RAID1.

See also
is_chunk_size_meaningful()

◆ get_md_level()

MdLevel storage::Md::get_md_level ( ) const

Get the MD RAID level.

See also
MdLevel

◆ get_md_parity()

MdParity storage::Md::get_md_parity ( ) const

Get the parity of the MD RAID.

Only meaningful for RAID5, RAID6 and RAID10.

See also
MdParity

◆ get_number()

unsigned int storage::Md::get_number ( ) const

Returns the number of the MD.

Throws if the MD is not numeric.

Exceptions
Exception

◆ get_uuid()

const std::string & storage::Md::get_uuid ( ) const

Get the UUID.

Note: Special MD RAID format.

◆ minimal_number_of_devices()

unsigned int storage::Md::minimal_number_of_devices ( ) const

Return the minimal number of devices required by the RAID (without spare and journal devices).

For RAIDs of level CONTAINER it returns 0 (those RAIDs cannot be created or modified anyway).

◆ remove_device()

void storage::Md::remove_device ( BlkDevice * blk_device)
Exceptions
Exception

◆ set_chunk_size()

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

Set the chunk size of the MD RAID.

The chunk size is not meaningful for LINEAR nor RAID1.

The function does not make a complete check of the chunk size since that depends on the RAID Level and the underlying devices. Use the Devicegraph::check() function.

Only for MD RAIDs not created on disk yet.

See also
is_chunk_size_meaningful()
Exceptions
InvalidChunkSize,Exception

◆ set_md_level()

void storage::Md::set_md_level ( MdLevel md_level)

Set the MD RAID level.

See also
MdLevel

◆ set_md_parity()

void storage::Md::set_md_parity ( MdParity md_parity)

Set the parity of the MD RAID.

Only meaningful for RAID5, RAID6 and RAID10 and for MD RAIDs not created on disk yet.

See also
MdParity

◆ set_metadata()

void storage::Md::set_metadata ( const std::string & metadata)

Set metadata for new created Linux RAID.

Allowed values are "1.0", "1.1", "1.2" and "default" (as long as mdadm treats "default" as "1.2"). Other values might also work.

If a specific metadata version is required it should be set since the default can change.

◆ set_uuid()

void storage::Md::set_uuid ( const std::string & uuid)

Set the UUID.

The UUID is only set when creating a new RAID on disk.

Note: Special MD RAID format.

◆ supports_journal_device()

bool storage::Md::supports_journal_device ( ) const

Return whether the RAID supports a journal device.

This is the case for RAID4, RAID5 and RAID6.

◆ supports_spare_devices()

bool storage::Md::supports_spare_devices ( ) const

Return whether the RAID supports spare devices.

This is the case for RAID1, RAID4, RAID5, RAID6 and RAID10.


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