Veritas™ File System 5.0.1 Programmer's Reference Guide

Using policies and application programming
interfaces
The following examples assume there is a volume set, volset, with the volumes
vol-01, vol-02, and vol-03. The file system mount point /mnt is mounted on
volset.
Defining and assigning allocation policies
The following pseudocode provides an example of using the allocation policy APIs
to define and assign allocation policies.
To define and assign an allocation policy to reallocate an existing files data blocks
to a specific volume
To reallocate an existing files data blocks to a specific volume (vol-03), create
code similar to the following:
/* Create a data policy for moving file’s data */
strcpy((char *) ap.ap_name, "Data_Mover_Policy");
ap.ap_flags = FSAP_CREATE;
ap.ap_order = FSAP_ORDER_ASGIVEN;
ap.ap_ndevs = 1;
strcpy(ap.ap_devs[0], "vol-03");
fd = open("/mnt", O_RDONLY);
vxfs_ap_define(fd, &ap, 0);
file_fd = open ("/mnt/file_to_move", O_RDONLY);
vxfs_ap_assign_file(file_fd, "Data_Mover_Policy", NULL, 0);
vxfs_ap_enforce_file(file_fd, "Data_Mover_Policy", NULL);
To create policies that allocate new files under a directory
In this example, the files are under dir1, the metadata is allocated to vol-01, and
file data is allocated to vol-02.
To create policies to allocate new files under directory dir1, create code similar
to the following:
/* Define 2 policies */
/* Create the RAID5 policy */
strcpy((char *) ap.ap_name, "RAID5_Policy");
ap.ap_flags = FSAP_CREATE | FSAP_INHERIT;
ap.ap_order = FSAP_ORDER_ASGIVEN;
ap.ap_ndevs = 1;
strcpy(ap.ap_devs[0], "vol-02");
59Multi-volume support
Using policies and application programming interfaces