libstorage-ng
|
A pool represents a collection of devices. More...
#include <Pool.h>
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. More... | |
void | remove_device (const Device *device) |
Remove a device from the pool. More... | |
bool | empty (const Devicegraph *devicegraph) const |
Check whether the pool has any devices in the devicegraph. More... | |
size_t | size (const Devicegraph *devicegraph) const |
Get the number of devices of the pool available in the devicegraph. More... | |
std::vector< const Device * > | get_devices (const Devicegraph *devicegraph) const |
Get the devices of the pool available in the devicegraph. More... | |
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. More... | |
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. More... | |
Impl & | get_impl () |
const Impl & | get_impl () const |
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:
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
void storage::Pool::add_device | ( | const Device * | device | ) |
Add a device to the pool.
The devicegraph the device belongs to is irrelevant.
Exception |
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.
PoolOutOfSpace,Exception |
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.
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.
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.
PoolOutOfSpace,Exception |
void storage::Pool::remove_device | ( | const Device * | device | ) |
Remove a device from the pool.
The devicegraph the device belongs to is irrelevant.
Exception |
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.