---
name: "pmiSetVolumeSize"
section: "3"
platform: "linux"
package: "pcp"
version: "7.2.2-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/pmiSetVolumeSize"
---

# pmiSetVolumeSize(3)

configure automatic data volume rotation for a LOGIMPORT archive

## NAME

**pmiSetVolumeSize** - configure automatic data volume rotation for a LOGIMPORT archive

## C SYNOPSIS

**#include \<pcp/pmapi.h\>**\
 **#include \<pcp/import.h\>**

**int pmiSetVolumeSize(size\_t** *max\_bytes***, void (\****on\_rotate***)(const char \*));**

**cc ... -lpcp\_import -lpcp**

## DESCRIPTION

As part of the Performance Co-Pilot Log Import API (see [**LOGIMPORT**(3)](/LOGIMPORT/3.md)), **pmiSetVolumeSize** configures automatic data volume rotation for the archive associated with the current context.

After each successful call to **pmiHighResWrite**(3) or [**pmiWrite**(3)](/pmiWrite/3.md), if the current data volume file size meets or exceeds *max\_bytes*, the library closes the current data volume, opens the next numbered volume, and writes a new volume label. Volume files are named *archive***.0***,* *archive***.1***,* and so on, where *archive* is the base path given to [**pmiStart**(3)](/pmiStart/3.md). The *.meta* and *.index* files are shared across all volumes and remain open throughout.

If *on\_rotate* is not NULL, it is called immediately after the old volume is closed and before the function returns. The single argument is the full path of the just-closed volume file (e.g. *myarchive.0*). The caller may use this callback to compress the completed volume or perform any other post-rotation work. The callback is invoked synchronously; long-running operations should be deferred to a child process.

Passing *max\_bytes* as zero disables volume rotation (the default).

**pmiSetVolumeSize** interacts with the existing **PCP\_LOGIMPORT\_MAXLOGSZ** environment variable: both mechanisms trigger **newvolume**() independently, so if both are active the smaller threshold governs.

## EXAMPLE

The following fragment opens a PCP archive, configures 100 MB volume rotation, and compresses each completed volume:

```
static void
on_vol(const char *path)
{
    char cmd[MAXPATHLEN + 32];
    pmsprintf(cmd, sizeof(cmd), "xz %s &", path);
    system(cmd);
}
pmiStart("myarchive", 0);
pmiSetVolumeSize(100 * 1024 * 1024, on_vol);
```

## DIAGNOSTICS

**pmiSetVolumeSize** returns zero on success. If there is no current context, **PM\_ERR\_NOCONTEXT** is returned. If *max\_bytes* is greater than zero but does not exceed the on-disk label size for the configured archive version (124 bytes for v2, 800 bytes for v3), **PM\_ERR\_CONV** is returned. A threshold at or below the label size would cause the new volume's label to immediately exceed the threshold on every write, triggering a rotation cascade.

## SEE ALSO

[**LOGIMPORT**(3)](/LOGIMPORT/3.md), [**pmiEnd**(3)](/pmiEnd/3.md), [**pmiErrStr**(3)](/pmiErrStr/3.md), **pmiHighResWrite**(3), [**pmiStart**(3)](/pmiStart/3.md), [**pmiWrite**(3)](/pmiWrite/3.md) and [**pmlogcheck**(1)](/pmlogcheck/1.md).
