Configure Affinities
Affinities for stripe groups are defined in the file system configuration file. They can be created through the StorNext GUI or by adding one or more Affinity
lines to a StripeGroup
section in the configuration file. A stripe group may have multiple affinities, and an affinity may be assigned to multiple stripe groups.
Affinities for files are defined in the following ways:
- Using the
cvmkfile
command with the ‘-k
’ option. -
Using the
snfsdefrag
command with the ‘-k
’ option.Note: Beginning with StorNext 6, use the
sgoffload
command instead of thesnfsdefrag
command. Thesgoffload
command moves extents belonging to files that are currently in use (open). Thesgoffload
command also informs the client to suspend I/O for a time, moves the data, then informs the client to refresh the location of the data and resume I/O. - Using the
cvaffinity
command with the ‘-s
’ option - Through inheritance from the directory in which they are created
- Through the
CvApi_SetAffinity()
function, which sets affinities programmatically - Using the
cvmkdir
command with the-k
option, a directory can be created with an affinity
Auto Affinities designate the affinity (stripe group[s]) to which allocations will be targeted for all files on the file system whose name has the specified file extension. For example, files ending with .dpx
like, frame1.dpx
, can be assigned an affinity by mapping dpx to an affinity in the configuration file. This assignment happens when the file is created.
See the StorNext Online Help for more details on how to configure Auto Affinities using the GUI.
At creation time, a file that matches the configuration specification (see below) will have the affinity automatically assigned. If the file would inherit a parent's affinity (its parent directory has an affinity such as from: cvmkdir -k <affinity> <dir>
), the automatic affinity from a configuration file entry overrides it. If there are no auto affinity mappings that match for a given file name, the file's affinity is not affected (left at 0 or the inherited value). One of the configuration entries can indicate "no affinity" causing a file at creation time to have its affinity set to 0, even if it would inherit its parent's affinity.
If a file already exists, its affinity is not affected by automatic affinities.
If a file is renamed or linked to another name, its affinity is not changed. This is significant since some application create a file with a temporary name and then rename the file. The file's automatic affinity mapping occurs only at create time so the name used for these applications is the temporary name. The applications typically write; therefore space is allocated using the temporary file name so there is no suffix or extension to use. The rename usually occurs after the file is finished.
The assignment is retained in the on-disk inode and exists for the life of the file. As before this feature, you can use the cvaffinity(1)
command to check or change a file's affinity.
The automatic affinity capability is implemented by creating new entries in the configuration file mapping file extensions to affinities or no affinity. The affinity in each entry must match the current affinity specification, for example, 1-8 character/ASCII string. Each mapping is followed by a list of extensions. The extensions are case insensitive.
The following examples show how to configure automatic affinities in a file system's configuration file. The examples use XML syntax. The end of this section has the XML syntax converted to the ASCII configuration format.
<autoAffinities>
<autoAffinity affinity="Video">
<extension>dpx</extension>
<extension>mov</extension>
</autoAffinity>
<autoAffinity affinity="Audio">
<extension>mp3</extension>
<extension>wav</extension>
</autoAffinity>
<autoAffinity affinity="Image">
<extension>jpg</extension>
<extension>jpeg</extension>
</autoAffinity>
<autoAffinity affinity="Other">
<extension>html</extension>
<extension>txt</extension>
</autoAffinity>
<noAffinity>
<extension>c</extension>
<extension>sh</extension>
<extension>o</extension>
</noAffinity>
</autoAffinities>
The affinities used must also exist in the StripeGroup sections of the same configuration file. For example, the above configuration uses the affinity Image
. This affinity must be present in at least one StripeGroup.
If a filename does not match any lines in the AutoAffinities section, its affinity is 0 or the inherited affinity from its parent. An entry can be used to map such files to a specific affinity by having an empty extension field. For example:
</autoAffinity>
<autoAffinity affinity="Other">
<extension>html</extension>
<extension>txt</extension>
<extension></extension>
</autoAffinity>
Or:
<noAffinity>
<extension>c</extension>
<extension>sh</extension>
<extension>o</extension>
<extension></extension>
</autoAffinity>
The last case is useful to override inheritable affinities for files that do not match any extension so that they get 0 as their affinity. One could map all files thereby overriding all inheritable affinities on a system with old directory trees that have affinities.
If checked in the GUI, this permits files of a particular affinity to have their allocations placed on other available stripe groups (with non-exclusive affinities) when the stripe groups of their assigned affinity do not have sufficient space. Otherwise, allocation attempts will fail with an out-of-space error.
A new global is created to alter the behavior of affinities when all the space of a StripeGroup is used or overly fragmented not allowing certain allocations. Currently, a file with an affinity must allocate space on a StripeGroup with that affinity. If those StripeGroups are full or overly fragmented, a file allocate might fail with ENOSPC. This can be thought of as affinity enforcement. The new behavior is that an allocation with an affinity would behave the same as a file without any affinity when there is no matching StripeGroup. It can allocate space on any StripeGroup with exclusive=false
, but only after an attempt to allocate space with the affinity fails.
The new parameter is:
The default behavior is false (enforcement instead). If set to true, the new behavior is to allow allocation on StripeGroups that do not match the affinity but only when there is no space available on the "preferred" StripeGroups.
Affinities create File Segregation and Grouping.
If Allocation Session Reservation is also enabled, files that land in the same session must have the same affinity. Creating sessions with the pair, session key and affinity, causes the functionality of grouping or segregating files within a session or folder.
For example, consider a folder my_movies that currently has the affinity Video.
It was created with the command:
Consider you have two StripeGroups:
- StripeGroup number 1: affinity=Video exclusive=false
- StripeGroup number 2: No affinity.
Also consider the following:
All the files under the directory prefer StripeGroup number 1. This includes *.dpx and *.WAV files and any others. For example, you want to separate the *.dpx files and *.WAV files. Create the mapping in the configuration file shown above.
- StripeGroup number 1: Contains the Video affinity. StripeGroup number 2 is modified to have the Audio affinity.
- StripeGroup number 2: affinity Audio exclusive=false
Consider if you create a directory with no affinity and then write *.dpx and audio files, *.WAV, in that directory.
The *.dpx files correctly land on StripeGroup number 1 and the *.WAV files go to StripeGroup number 2. Any other files also go to either StripeGroup number 2 or StripeGroup number 1. Now, consider you want the voice also on StripeGroup number 1 but in a separate location from the *.dpx files. Simply add Audio to the affinities on StripeGroup number 1 and remove it from StripeGroup number 2. With this addition, *.WAV files will land on StripeGroup number 1, but they will be in separate sessions from the *.dpx files. They will all prefer StripeGroup number 2 until it is full.
With Allocation Session Reservation enabled and the above automatic affinities, *.WAV files are grouped separately from *.dpx files since they have different affinities. If you desire just file grouping and no affinity steering to different stripe groups, simply add all the affinities to each StripeGroup that allows data and set exclusive=false
on each data StripeGroup. The non-exclusivity is needed so that files without affinities can also use the data stripe groups.
Finally, Quantum recommends to set AffinityPreference=true
.
Below are the example configuration file entries in the ASCII configuration file format.
First, Affinity Preference:
Next, Auto or No affinity mappings shown above in XML.
# Auto Affinities
[AutoAffinity Video]
Extension mov
Extension dpx
[AutoAffinity Audio]
Extension wav
Extension mp3
[AutoAffinity Image]
Extension jpeg
Extension jpg
[AutoAffinity Other]
Extension txt
Extension html
# No Affinities
[NoAffinity]
Extension o
Extension sh
Extension c
Empty Extension example:
[AutoAffinity Other]
Extension txt
Extension html
Extension
Or:
[NoAffinity]
Extension o
Extension sh
Extension c
Extension