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

A pool represents a collection of devices. More...

#include <Pool.h>

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

Public Member Functions

const std::map< std::string, std::string > & get_userdata () const
 Return the userdata of the pool.
void set_userdata (const std::map< std::string, std::string > &userdata)
 Set the userdata of the pool.
bool exists_device (const Device *device) const
 Check whether the device exists in the pool.
void add_device (const Device *device)
 Add a device to the pool.
void remove_device (const Device *device)
 Remove a device from the pool.
bool empty (const Devicegraph *devicegraph) const
 Check whether the pool has any devices in the devicegraph.
size_t size (const Devicegraph *devicegraph) const
 Get the number of devices of the pool available in the devicegraph.
std::vector< const Device * > get_devices (const Devicegraph *devicegraph) const
 Get the devices of the pool available in the devicegraph.
unsigned long long max_partition_size (Devicegraph *devicegraph, unsigned int number) const
 Find the maximum partition size the pool can provide for the given number of partitions.
std::vector< Partition * > create_partitions (Devicegraph *devicegraph, unsigned int number, unsigned long long size) const
 Create a number of partitions of size in the pool.
Impl & get_impl ()
const Impl & get_impl () const

Detailed Description

A pool represents a collection of devices.

This can be used to e.g. create the partitions used of an MD.

When requesting space from the pool the space is provided according to some strategy.

There are many aspects to consider for a strategy:

  1. Distribute bandwidth among all devices of the pool.
  2. When generating several partition pairs (e.g. for RAIDs) all of the space of the pool should be made available. This would fail if e.g. there are three disks in the pool and several RAIDs are created on the first two disks of the pool. When the first two disks are full no further RAIDs can be created leaving much of the pool used.
  3. When creating several small partitions there should still be enough space to later create big partitions.

The current strategy fulfills 1. and 2. by preferring devices which are so far less used.

All functions concerning pools are experimental.

TODO alignment considerations

Member Function Documentation

◆ add_device()

void storage::Pool::add_device ( const Device * device)

Add a device to the pool.

The devicegraph the device belongs to is irrelevant.

See also
remove_device(const Device*)
Exceptions
Exception

◆ create_partitions()

std::vector< Partition * > storage::Pool::create_partitions ( Devicegraph * devicegraph,
unsigned int number,
unsigned long long size ) const

Create a number of partitions of size in the pool.

Devices in the pool not of type partitionable or without a partition table are ignored.

The sizes of the created partitions may be different from size due to alignment. They may even be pairwise different.

The result is nondeterministic. E.g. if 3 partitions on 4 identical disks are requested, it is nondeterministic on which 3 disks the partitions are created.

Exceptions
PoolOutOfSpace,Exception

◆ empty()

bool storage::Pool::empty ( const Devicegraph * devicegraph) const

Check whether the pool has any devices in the devicegraph.

It is no error if devices are not available in the devicegraph.

◆ get_devices()

std::vector< const Device * > storage::Pool::get_devices ( const Devicegraph * devicegraph) const

Get the devices of the pool available in the devicegraph.

It is no error if devices are not available in the devicegraph.

◆ max_partition_size()

unsigned long long storage::Pool::max_partition_size ( Devicegraph * devicegraph,
unsigned int number ) const

Find the maximum partition size the pool can provide for the given number of partitions.

Exceptions
PoolOutOfSpace,Exception

◆ remove_device()

void storage::Pool::remove_device ( const Device * device)

Remove a device from the pool.

The devicegraph the device belongs to is irrelevant.

See also
add_device(const Device*)
Exceptions
Exception

◆ size()

size_t storage::Pool::size ( const Devicegraph * devicegraph) const

Get the number of devices of the pool available in the devicegraph.

It is no error if devices are not available in the devicegraph.


The documentation for this class was generated from the following file:
  • /home/abuild/rpmbuild/BUILD/libstorage-ng-4.5.263-build/libstorage-ng-4.5.263/storage/Pool.h