Pool Functions

Pool functions provide methods to determine attributes of pools in a PixStor Filesystem.

CLib’s Pool Functions provide faster operation than the equivalent PixStor Python API arcapix.fs.gpfs.pool.Pool.

These methods do not require root permission

Description

statfspool_result struct

The statfspool_result struct returned by statfspool() has the following fields

f_blocks              # total data blocks in pool
f_bfree               # free blocks in pool
f_bavail              # free blocks avail to non-superuser
f_mblocks             # total metadata blocks in pool
f_mfree               # free blocks avail for system metadata
f_bsize               # optimal storage pool block size
f_files               # total file nodes assigned to pool
f_poolid              # storage pool id
f_fsize               # fundamental file system block size
f_usage               # data and/or metadata stored in pool
f_replica             # replica
f_bgf                 # block group factor
f_wad                 # write affinity depth
f_allowWriteAffinity  # allow write affinity depth. 1 means yes
f_nextid              # id of the next pool in the filesystem or -1 if no more pools

All fields are of type int.

Note

Fields f_replica, f_bgf, f_wad, and f_allowWriteAffinity are new in 4.1.1 file system code. For earlier versions of PixStor file system code, these fields will all have value 0

arcapix.fs.gpfs.clib.pool.getpoolname(pathname, gpfs_pool_t poolId)

Retrieves the name of the storage pool.

Parameters
  • pathname (str) – path to any file in the file system

  • poolId (int) – id of pool, such as returned by statfspool

arcapix.fs.gpfs.clib.pool.statfspool(pathname, gpfs_pool_t poolId=0, int nPools=0)

Obtain status information about the storage pools.

Parameters
  • pathname (str) – path to any file in the filesystem

  • nPools (int) – number of pools requested or 0 to return all

  • poolId (int) – id of first pool to return

Return type

statfspool_result

Hint

These methods specify which filesystem to use by providing a path to some file in the filesystem. You can get the mountpoint for a named filesystem by using Filesystem Snapshot Identifiers methods

>>> from arcapix.fs.gpfs.clib.fssnap import get_fssnaphandle_by_name, get_pathname_from_fssnaphandle
>>>
>>> path = get_pathname_from_fssnaphandle(get_fssnaphandle_by_name('mmfs1'))
>>> pools = statfspool(path)

Examples

List names of pools in a filesystem

>>> for pool in statfspool('/mmfs1'):
...     print(getpoolname('/mmfs1', pool.f_poolid))
...
system
sas1
sata1
sata2

Get a pool by id

>>> # REMEMBER statfspool returns a list
>>> pool = statfspool('/mmfs1', poolId=65538, nPools=1)[0]
>>> pool.f_usage & U_DATA != 0  # does the pool hold data?
True
>>> pool.f_usage & U_METADATA != 0  # does the pool hold metadata?
False

Find a pool by name

We could fetch stats for all pools like the example above, however this will load data for all pools into memory. If the filesystem has a lot of pools, this may not be desirable. This example shows iterating over pools, loading only one at a time.

>>> pool = statfspool('/mmfs1', 0, 1)[0]  # get first pool
>>>
>>> while pool.f_nextid != -1:  # -1 means no next pool
...
...     # for this example we're looking for 'sata1'
...     if getpoolname('/mmfs1', pool.f_poolid) == 'sata1':
...         break
...
...     # get next pool
...     pool = statfspool('/mmfs1', pool.f_nextid, 1)[0]
...
... else:
...     raise Exception("pool 'sata1' wasn't found")
...
>>> print(pool.f_poolid)
65538

Check available space in data pools

>>> for pool in statfspool('/mmfs1'):
...
...     if pool.f_usage & U_DATA == 0:
...         # pool doesn't hold data (metadata only)
...         continue
...
...     name = getpoolname('/mmfs1', pool.f_poolid)
...
...     # free blocks * block size = free bytes
...     free_kb = pool.f_bfree * pool.f_bsize / 1024
...
...     # free block / total blocks
...     free_pct = 100 * pool.f_bfree / pool.f_blocks
...
...     print("%s\t%d\t%10d KB  (%3d %%)" % (name, pool.f_poolid, free_kb, free_pct))
...
sas1     65537      10412032 KB  ( 99 %)
sata1    65538       9162752 KB  ( 87 %)
sata2    65539       5169152 KB  ( 98 %)