Original Source: Xsan Maintenance
The proper Xsan volume maintenance is critical to the health of your filesystem. Short of a full crash with loss of configuration files, I have not seen any minor problems that this didn’t take care of (or at least help out tremendously). I try to do this to each volume at least once a month, and anytime there is a problem (i.e. filesystem crash). Start by stopping the volume:
# stop [volname]
Then the file system checks. Start with a journal recovery, then a read-only scan, then a read/write scan.
Once these are all finished, start up the volume:
# start [volname]
The amount of time that the “cvfsck” will take is dependent on the amount of data on the volume. If at any step in the “cvfsck” the volume comes up as “dirty” instead of “clean” then first, make sure the volume is stopped (most common cause of this is a volume that is still running). After you check that, its always a good idea to run the “wv” until you get two “clean” reports in a row.
Another part of keeping the File System maintained is preventing severe fragmentation. In our own experiments, we found some files can have performance problems with as little as 3 or 4 extents (pieces that the file is separated into) but most are fine with many. However, just about all files start having problems when they reach about 200 extents which can happen very quickly. Running defragging can impact performance of the other clients, so its definitely best to do it overnight. So I like to have a machine doing overnight defrags several times a month. I usually do 1 prune operation per month as well. Also, with the Xsan 2.2 update, the ‘snfsdefrag’ process saw a dramatic speed increase. So if possible (and for many more reasons) you want to be running Xsan 2.2 or higher on the client that is defragging.
To defragement an Xsan Volume (the volume is allowed to be running during this) use the command:
# sudo snfsdefrag -rv /Volumes/<sanvolume>
Replace <sanvolume> with the name of your volume. You can also specify that it only defragments specific directories, which is useful if you are using affinities. The ‘-r’ option tells it to recurse through the given directory, or to visit everything below that point.
When Xsan writes a file to the volume, it pre-allocates the amount of storage that it thinks it will need for that file. This is good because it reduces fragmentation in certain circumstances. However, if the file does not use that many blocks, they remain allocated. Usually this is one or two block at a time, but can be more than that (especially if a file has shrunk in size). Pruning is the operation of checking for, and freeing up these allocated blocks. It can free up several kilobytes or, in extreme cases, several hundred gigabytes. To invoke the prune operation you simply add the “-p” argument to the defrag command:
# sudo snfsdefrag -rpv /Volumes/[sanvolume]