|
| 1 | +# Warm Performance (SSD) tier for an FSx for ONTAP volume |
| 2 | + |
| 3 | +## Introduction |
| 4 | +This sample provides a script that can be used to warm a FSx for ONTAP |
| 5 | +volume. In other words, it ensures that all the blocks for a volume are in |
| 6 | +the "performance tier" as opposed to the "capacity tier." It does that by |
| 7 | +simply reading every byte of every file in the volume. Doing that |
| 8 | +causes all blocks that are currently in the capacity tier to be pulled |
| 9 | +into the performance tier before being returned to the reader. At that point, |
| 10 | +assuming the tiering policy is not set to 'all', all the data should remain |
| 11 | +in the performance tier until ONTAP tiers it back based on the volume's |
| 12 | +tiering policy. |
| 13 | + |
| 14 | +Note that Data ONTAP will not store data in the performance |
| 15 | +tier from the capacity tier if it detects that the data is being read |
| 16 | +sequentially. This is to keep things like backups and virus scans from |
| 17 | +filling up the performance tier. Because of that, this script will |
| 18 | +read files in "reverse" order. Meaning it will read the last block of |
| 19 | +the file first, then the second to last block, and so on. |
| 20 | + |
| 21 | +To speed up the process, the script will spawn multiple threads to process |
| 22 | +the volume. It will spawn a separate thread for each directory |
| 23 | +in the volume, and then a separate thread for each file in that directory. |
| 24 | +The number of directory threads is controlled by the -t option. The number |
| 25 | +of reader threads is controlled by the -x option. Note that the script |
| 26 | +will spawn -x reader threads **per** directory thread. So for example, if you have 4 |
| 27 | +directory threads and 10 reader threads, you could have up to 40 reader |
| 28 | +threads running at one time. |
| 29 | + |
| 30 | +Since the goal of this script is to force all the data that is currently |
| 31 | +in the capacity tier to the performance tier you should ensure you have |
| 32 | +enough free space in your performance tier to hold all the data in the volume. |
| 33 | +You can use the `volume show-footprint` ONTAP command to see how much space |
| 34 | +is currently in the capacity tier. You can then use `storage aggregate show` |
| 35 | +to see how much space is available in the performance tier. |
| 36 | + |
| 37 | +## Set Up |
| 38 | +The script is meant to be run on a Linux based host that is able to NFS |
| 39 | +mount the volume to be warmed. If the volume is already mounted, then |
| 40 | +any user that has read access to the files in the volume can run it. |
| 41 | +Otherwise, the script needs to be run as 'root' so it can mount the |
| 42 | +volume before reading the files. |
| 43 | + |
| 44 | +If the 'root' user can't read the files in the volume, then you should use 'root' user just |
| 45 | +to mount the volume and then run the script from a user ID that can read the contents |
| 46 | +of all the files in the volume. |
| 47 | + |
| 48 | +Make sure you have set the tiering policy on the volume set to something |
| 49 | +other than "all" or "snapshot-only", otherwise the script will be ineffective. |
| 50 | + |
| 51 | +# Running The Script |
| 52 | +There are two main ways to run the script. The first is to just provide |
| 53 | +the script with a directory to start from using the -d option. The script will then read |
| 54 | +every file in that directory and all its subdirectories. The second way |
| 55 | +is to provide the script with the FSx for ONTAP file system data endpoint with the -f option |
| 56 | +and the volume name with the -v option. The script will then attempt to mount the volume |
| 57 | +if it isn't already mounted. If it does mount it, it will mount it read-only |
| 58 | +and unmount when it is done. |
| 59 | + |
| 60 | +In order to mount the volume the script assumes that the junction path is the same |
| 61 | +as the volume name. If this isn't the case, then just mount the volume first |
| 62 | +before running the script and provide the path to the mount point |
| 63 | +with the -d option. |
| 64 | + |
| 65 | +To run this script you just need to change the UNIX permissions on |
| 66 | +the file to be executable, then run it as a command: |
| 67 | +``` |
| 68 | +chmod +x warm_performance_tier |
| 69 | + ./warm_performance_tier -d /path/to/mount/point |
| 70 | +``` |
| 71 | +The above example will force the script to read every file in the /path/to/mount/point |
| 72 | +directory and any directory under it. |
| 73 | + |
| 74 | +If you want the script to ensure the volume is mounted, you can specify |
| 75 | +the file system data endpoint and volume name: |
| 76 | +``` |
| 77 | +./warm_performance_tier -f fsxfileserver.us-west-2.amazonaws.com -v myvolume |
| 78 | +``` |
| 79 | +By default there won't be any output from the script. You can provide a -V option to |
| 80 | +get verbose output. This will display the thread ID, date (in epoch seconds), then the |
| 81 | +directory or file being processed. |
| 82 | + |
| 83 | +If you run the script with a '-h' option, you will see the following help message: |
| 84 | +``` |
| 85 | +Usage: warm_performance_tier [-f filesystem_endpoint] [-v volume_name] [-d directory] [-t max_directory_threads] [-x max_read_threads] [-n nfs_type] [-h] [-V] |
| 86 | +Where: |
| 87 | + -f filesystem_endpoint - Is the hostname or IP address of the FSx for ONTAP file system. |
| 88 | + -v volume_name - Is the name of the volume. |
| 89 | + -n nfs_type - Is the NFS version to use. Default is nfs4. |
| 90 | + -d directory - Is the root directory to start the process from. |
| 91 | + -t max_directory_threads - Is the maximum number of threads to use to process directories. The default is 10. |
| 92 | + -x max_read_threads - Is the maximum number of threads to use to read files. The default is 4. |
| 93 | + -V - Enable verbose output. Displays the thread ID, date (in epoch seconds), then the directory or file being processed. |
| 94 | + -h - Prints this help information. |
| 95 | +
|
| 96 | +Notes: |
| 97 | + * The filesystem_endpoint, volume_name and nfs_type are used to mount the volume |
| 98 | + if it is not already mounted. It will be mounted read-only. It assumes that |
| 99 | + the junction path is the same as the volume name. |
| 100 | + * For each directory thread, there will be a maximum of max_read_threads threads |
| 101 | + reading files. |
| 102 | +``` |
| 103 | + |
| 104 | +## Author Information |
| 105 | + |
| 106 | +This repository is maintained by the contributors listed on [GitHub](https://github.com/NetApp/FSx-ONTAP-samples-scripts/graphs/contributors). |
| 107 | + |
| 108 | +## License |
| 109 | + |
| 110 | +Licensed under the Apache License, Version 2.0 (the "License"). |
| 111 | + |
| 112 | +You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0). |
| 113 | + |
| 114 | +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, without WARRANTIES or conditions of any kind, either express or implied. |
| 115 | + |
| 116 | +See the License for the specific language governing permissions and limitations under the License. |
| 117 | + |
| 118 | +© 2024 NetApp, Inc. All Rights Reserved. |
0 commit comments