Symantec logo

Allocation flags

Allocation flags can be specified with VX_SETEXT ioctl for additional control over allocation policies. Allocation flags are specified in the a_flag argument of vx_ext structure to determine:

Allocation flags with reservation

The VX_TRIM, VX_NOEXTEND, VX_CHGSIZE, VX_NORESERVE, VX_CONTIGUOUS, and VX_GROWFILE flags can be used to modify reservation requests. Note that VX_NOEXTEND is the only flag that is persistent; the other flags may have persistent effects, but they are not returned by the VX_GETEXT ioctl. The non-persistent flags remain active for a file in the file system cache until the file is no longer accessed and is removed from the cache.

Reservation trimming

The VX_TRIM flag specifies that the reservation amount must be trimmed to match the file size when the last close occurs on the file. At the last close, the VX_TRIM flag is cleared and any unused reservation space beyond the size of the file is freed. This can be useful if an application needs enough space for a file, but it is not known how large the file will become. Enough space can be reserved to hold the largest expected file, and when the file has been written and closed, any extra space will be released.

Non-persistent reservation

If reservation is not desired to be a persistent attribute, the VX_NORESERVE flag can be specified to request allocation of space without making reservation a persistent attribute of the file. This flag can be used by applications interested in temporary reservation but wish to free any space past the end of the file when the file is closed. For example, if an application is copying a file that is 1 MB long, it can request a 1 MB reservation with the VX_NORESERVE flag set. The space is allocated, but the reservation in the file is left at 0. If the program aborts for any reason or the system crashes, the unused space past the end of the file is released. When the program finishes, there is no clean up because the reservation was never recorded on disk.

No write beyond reservation

The VX_NOEXTEND flag specifies that any attempt to write beyond the current reservation must fail. Writing beyond the current reservation requires the allocation of new space for the file. To allocate new space to the file, the space reservation must be increased. The ulimit command provides a similar function by preventing a file from using too much space.

See the limit(1) manual page.

Contiguous reservation

The VX_CONTIGUOUS flag specifies that any space allocated to a file must satisfy the requirement of a single extent allocation. If there is not one extent large enough to satisfy the reservation request, the request fails. For example, if a file is created and a 1 MB contiguous reservation is requested, the file size is set to zero and the reservation to 1 MB. The file will have one extent that is 1 MB long. If another reservation request is made for a 3 MB contiguous reservation, the new request will find that the first 1 MB is already allocated and allocate a 2 MB extent to satisfy the request. If there are no 2 MB extents available, the request fails. Extents are, by definition, contiguous. Note that because VX_CONTIGUOUS is not a persistent flag, space will not be allocated contiguously for restoring a file that was previously allocated with the VX_CONTIGUOUS flag.

Include reservation in the file size

A reservation request can affect the size of the file to include the reservation amount by specifying VX_CHGSIZE. This flag increases the size of the file to match the reservation amount without zeroing the reserved space. Because the effect of this flag is uninitialized data in a file, which might have been previously contained in other files, the use of this flag is restricted to users with the appropriate privileges. Without this flag, the space of the reservation is not included in the file until an extending write operation requires the space. A reservation that immediately changes the file size can generate large temporary files. Applications can benefit from this type of reservation by eliminating the overhead imposed with write operations to allocate space and update the size of the file.

It is possible to use these flags in combination. For example, using VX_CHGSIZE and VX_NORESERVE changes the file size, but does not set any reservation. When the file is truncated, the space is freed. If the VX_NORESERVE flag is not used, the reservation is set on the disk along with the file size.

Reading the grown part of the file

When the allocation flag (a.flag) is set to VX_GROWFILE, the size of the file is changed to include the reservation. This flag reads the grown part of the file (between the current size of the file and the size after the operation succeeds). VX_GROWFILE has persistent affects, but is not visible as an allocation flag. This flag is visible through the VX_GETEXT ioctl.