fsadm_vxfs (1M)

NAME

fsadm_vxfs - resize or reorganize (defragment) a VxFS file system

SYNOPSIS

fsadm [-F vxfs] [-d] [-D] [-e] [-E] [-s] [-v]
      [-a days][-k ckpt_name][-l largesize][-p passes]
      [-r rawdev][-t time] mount_point

fsadm [-F vxfs] [-b newsize] [-r rawdev] mount_point

fsadm [-F vxfs] [-c] mount_point

fsadm [-F vxfs] [-o specific_options] mount_point | special

fsadm [-F vxfs] [-d] [-D] [-e] [-E] -f filename | -

fsadm [-F vxfs] [-L] mount_point

fsadm [-F vxfs] -R [-A] mount_point

AVAILABILITY

VRTSvxfs

DESCRIPTION

The fsadm command performs online administration functions on VxFS file systems, Storage Checkpoints, or individual files and directories. The fsadm command supports file system resizing, extent reorganization, directory reorganization, querying or changing the largefiles flag, and Thin Storage Reclamation. The fsadm command operates on file systems mounted for read/write access; however, the -o option can also operate on a special device containing a clean, unmounted file system. Only a privileged user can change the largefiles flag on a mounted file system, or resize or reorganize a file system. You can invoke only one instance of fsadm per file system at a time.

If mount_point is a Storage Checkpoint, fsadm performs the specified operation on the entire file system, including all of the file system’s Storage Checkpoints.

Cluster File System Issues

See the -L and the -o logsize=size options for CFS-related issues.

NOTES

When you have fileset (Storage Checkpoint) quotas enabled on a file system with fsckptadm_vxfs(1M) and you reorganize the file system with fsadm, fsadm changes the file system and affects the Storage Checkpoint quota usage on the file system. For example:

# fsckptadm getquotalimit $DIR1
Filesystem hardlimit softlimit usage action_flag
/mnt1 200000 100000 103952
# fsadm -ed $DIR1 # fsckptadm getquotalimit $DIR1
Filesystem hardlimit softlimit usage action_flag
/mnt1 200000 100000 118106

Thin Storage Reclamation is a slow process and may take over an hour to complete.

OPTIONS

If no options are specified, fsadm prints the current largefiles flag setting, then exits. The -b, -L, -o largefiles, and -o nolargefiles options cannot be specified if any other options are given. If both -e and -d are specified, fsadm first completes the directory reorganization, then does the extent reorganization.
-A Initiates Thin Storage aggressive reclamation on the mount point specified by mount_point. The operation compacts the existing allocated blocks in the file system to create larger regions of free blocks, potentially reclaiming more than the default reclamation mode, which does not move any blocks that are in use. As part of this operation, extra space allocation might be triggered from the underlying Thin Storage, which is released at the end of the operation. Aggressive reclamation can take quite a long time, and can also fragment existing large allocations.
The return values are the same as for the vxfs_ts_reclaim() API. See the vxfs_ts_reclaim(3) manual page.
-a days Considers files not accessed within the specified number of days as aged files. The default is 14 days. The -d option moves aged files to the end of the directory.
-b newsize Resizes the file system to newsize sectors. -b cannot be used with the -cdDeEfko options.
-c Converts the inode format of files upgraded from Version 1 and Version 2 disk layouts so that they can grow beyond a two gigabyte offset. This option is required because some file systems that are upgraded (see the vxupgrade(1M) manual page) from the older disk layout versions could not be extended past 2 GB or contain more than 8 million inodes.
-d Reorganizes directories. Directory entries are reordered to place subdirectory entries first, then all other entries in decreasing order of time of last access. The directory is also compacted to remove free space.
-D Reports on directory fragmentation. If specified with the -d option, the fragmentation report is produced both before and after the directory reorganization.
-e Extent reorganization. Minimizes file system fragmentation. Files are reorganized to have the minimum number of extents.
-E Reports on extent fragmentation. If specified with the -e option, the fragmentation report is produced both before and after the extent reorganization.
-f filename | -
  Performs and reports extent reorganization or directory reorganization on an individual file or directory. For example, when used with the -d option, a reorganization is performed on the specified directory. When used with the -e option, an extent reorganization is performed on a specified file. If you specify - (dash), the command reads input from the standard input device instead of using a file name or directory name.
-F vxfs Specifies the VxFS file system type.
-k ckpt_name Reorganizes or reports directories or extent fragmentation on the specified Storage Checkpoint. See also NOTES section on Storage Checkpoint quotas.
-l largesize Large extent size in file system blocks. Indicates the size of extents to be considered as large extents, that is, extents that are immovable while performing an extent defragmentation. The value must be between 8 and 2048 blocks. The default is 64 blocks.
-L Queries the current size of the intent log as well as the volume on which it resides. On single-volume file systems, logvol will be empty. For cluster file systems, this command displays the information for the local node only (e.g., the node on which the command is being executed).
The -L option is mutually exclusive with all other options.
-o specific_options
  Specifies VxFS-specific options.
largefiles Sets the largefiles flag for the file system. When this flag is set, large files (greater than two gigabytes) can be created on the file system. The -o largefiles option is mutually exclusive with the -o nolargefiles option and with all other -o options.
logsize=size
  Allocates the intent log size in file system blocks for the specified file system. The recommended value for size is greater than 256K. The maximum is 256 MB.
size can also be specified with a suffix to indicate a unit of measure other than file system blocks. Append k or K to indicate the value is in kilobytes, or m or M to indicate megabytes. An appended letter can be separated from the number by a space. In that case, enclose the letter and number in a set of quotes (for example, "512 k").
System performance can improve by increasing the size of the intent log because it reduces the frequency at which the log wraps. Increasing the intent log size can also increase the time required for a log replay.
In a cluster file system, every node has its own intent log. This action applies only to the intent log of local node (e.g., the node on which the command is being executed).
See the logsize specific option of the mkfs_vxfs(1M) manual page for more information on log sizes.
logvol=volumename
  Directs the intent log size allocation specified by logsize to the specified intent logging volume. volumename must exist and belong to the same volume set as the file system. This modifies the file system log allocation policy to contain the specified device. The old log space is freed after the command completes.
If logvol is specified and logsize is not specified, the log is moved to the new volume while retaining the existing size.
mntlock=ID Specifies that the mount point will be locked with the specified identifier, ID, which will disallow unmounting the file system except if the umount command is invoked with the mntunlock option. The identifier can be any ASCII string of up to 31 bytes.
mntunlock=ID
  Unmounts a file system that was mounted with the mntlock=ID option. The /etc/mnttab entry for the file system shows whether the file system was mounted with the mntlock option. The specified identifier, ID, must match the identifier specified with the mntlock option that was used to lock the mount point.
nolargefiles
  Clears the largefiles flag for the file system. When the largefiles flag is not set, large files cannot be created on the file system. Any attempt to clear the flag fails if a large file exists on the file system.
You can set or clear the flag on a mounted file system by specifying mount_point, or on an unmounted file system on the device special.
When invoked without arguments, fsadm prints the current state of the largefiles flag.
Be careful when implementing large file system capability. System administration utilities such as backup may not operate correctly if they are not large file aware. In addition, the -o nolargefiles option is mutually exclusive with the -o largefiles option and with all other -o options.
The -o option cannot be used with the -bcdDeEfk options.
-p passes Maximum number of passes to run. The default is five passes. Reorganizations are processed until reorganization is complete, or until the specified number of passes are run.
-r rawdev Path name of the raw device to read to determine file layout and fragmentation. This option can be used when fsadm cannot determine the raw device. There can be a performance benefit from using raw devices, since a write to a raw device bypasses the operating system’s buffer cache. Data can then be transferred directly from the application’s buffer cache to the disk.
-R Initiates Thin Storage Reclamation on the mount point specified by mount_point. The operation is run across whole length of the file system.
The return values are the same as for the vxfs_ts_reclaim() API. See the vxfs_ts_reclaim(3) manual page. The -R option cannot be combined with any other options.
-s Prints a summary of activity at the end of each pass.
-t time Maximum time to run. Reorganizations are processed until reorganization is complete, or until the time limit expires. time is specified in seconds.
-v Specifies verbose mode. Reports reorganization activity.
-w Thaws the specified file systems. You cannot specify more than six file systems at a time. Specifying all thaws all VxFS file systems.

Largefiles Flag

Large files (files larger than 2 gigabytes) can be created if the file system has the largefiles flag set. This flag is set by default when the file system is created.

The -o largefiles and -o nolargefiles options change the largefiles flag, allowing or disallowing large files (files larger than 2 GB) in the file system. Clearing the flag via the -o nolargefiles option succeeds only if the flag is set and there are no large files present on the file system. See the mkfs_vxfs(1M) and mount_vxfs(1M) manual pages for information on creating and mounting file systems with large files.

The -o largefiles and -o nolargefiles options are the only fsadm options that can be used on an unmounted file system. An unmounted file system can be specified by invoking fsadm with a special device rather than a mount point. If you specify an unmounted file system, that file system must be clean.

Changing the largefiles flag may require changes to /etc/vfstab. For example, if fsadm is used to set the largefiles flag, but nolargefiles is specified as a mount option in /etc/vfstab, the file system is not mountable.

Defragmentation

For optimal performance, the kernel extent allocator must be able to find large extents when it wants them. To maintain file system performance, run fsadm periodically against all VxFS file systems to reduce fragmentation. The frequency depends on file system usage and activity patterns, and the importance of performance; typically between once a day and once a month against each file system. The -v option can be used to examine the amount of work performed by fsadm. You can adjust the frequency of reorganization based on the rate of file system fragmentation.

Running fsadm with Storage Checkpoints enabled can also affect Storage Checkpoint quota usage. See the NOTES section on Storage Checkpoint quotas.

There are two options that are available to control the amount of work done by fsadm. The -t option specifies a maximum length of time to run. The -p option specifies a maximum number of passes to run. If both are specified, fsadm exits if either of the terminating conditions is reached. By default, fsadm runs five passes. If both the -e and -d options are specified, fsadm runs all the directory reorganization passes before any extent reorganization passes.

fsadm uses the file .fsadm in the lost+found directory as a lock file. When fsadm is invoked, it opens the file lost+found/.fsadm in the root of the file system specified by mount_point. If .fsadm does not exist, it is created. The fcntl system call (see the fcntl(2) manual page) obtains a write lock on the file. If the write lock fails, fsadm assumes that another instance of fsadm is running and fails. fsadm reports the process ID of the process holding the write lock on the .fsadm file.

File System Resizing

If the -b option is specified, fsadm resizes the file system whose mount point is mount_point. If newsize is larger than the current size of the file system, the file system is expanded to newsize sectors. Similarly, if newsize is smaller than the current size of the file system, fsadm shrinks the file system to newsize sectors.

If there are file system resources in use in the sectors being removed, fsadm relocates those resources to sectors staying within the resized file system. The time needed for relocation depends on the number of blocks being moved.

The fsadm command cannot resize multi-volume file systems. See the fsvoladm(1M) manual page for information on resizing multi-volume file systems.

Reporting On Directory Fragmentation

As files are allocated and deallocated, directories tend to grow and become sparse. In general, the directory size is determined by the largest number of files it has ever contained, even if some files were subsequently removed.

To obtain a directory fragmentation report, use the command syntax:


fsadm -D [-r rawdev] mount_point

The following is some example output from the fsadm -D command:


# fsadm -F vxfs -D /var

Directory Fragmentation Report

Dirs Total Immed Immeds Dirs to Blocks Searched Blocks Dirs to Add Reduce to Reduce

total 486 99 388 6 6 6

The Dirs Searched column contains the total number of directories. A directory is associated with the extent-allocation unit containing the extent in which the directory’s inode is located. The Total Blocks column contains the total number of blocks used by directory extents.

The Immed Dirs column contains the number of directories that are immediate, meaning that the directory data is in the inode itself, as opposed to being in an extent. Immediate directories save space and speed up path name resolution.

The Immeds to Add column contains the number of directories that currently have a data extent, but that could be reduced in size and contained entirely in the inode.

The Dirs to Reduce column contains the number of directories for which one or more blocks could be freed if the entries in the directory are compressed to make the free space in the directory contiguous. Because directory entries vary in length, some large directories may contain a block or more of total free space, but with the entries arranged in such a way that the space cannot be made contiguous. As a result, it is possible to have a non-zero Dirs to Reduce calculation immediately after running a directory reorganization. The -v (verbose) option of directory reorganization reports occurrences of failure to compress free space.

The Blocks to Reduce contains the number of blocks that could be freed if the entries in the directory are compressed.

Measuring Directory Fragmentation

If the totals in the Dirs to Reduce column are substantial, a directory reorganization can improve the performance of path name resolution. The directories that fragment tend to be the directories with the most activity. A small number of fragmented directories can account for a large percentage of name lookups in the file system.

Directory Reorganization

If the -d option is specified, fsadm reorganizes the directories on the file system whose mount point is mount_point. Directories are reorganized in two ways: compression and sorting.

For compression, fsadm moves valid entries to the front of the directory and groups the free space at the end of the directory. If there are no entries in the last block of the directory, the block is released and the directory size is reduced.

If the total space used by all directory entries is small enough, fsadm puts the directory in the inode immediate data area.

fsadm also sorts directory entries to improve path name lookup performance. Entries are sorted based on the last access time of the entry. The -a option specifies a time interval; 14 days is the default if -a is not specified. The time interval is broken up into 128 buckets, and all times within the same buckets are considered equal. All access times older than the time interval are considered equal, and those entries are placed last. Subdirectory entries are placed at the front of the directory and symbolic links are placed after subdirectories, followed by the most-recently-accessed files.

The command syntax for reorganizing directories in a file system is:


fsadm -d [-D][-s][-v][-a days][-p passes] [-t time][-r rawdev] mount_point

The following example shows the output of the fsadm -d -D command:


# fsadm -F vxfs -d -D -s /opt

Directory Fragmentation Report

Dirs Total Immed Immeds Dirs to Blocks Searched Blocks Dirs to Add Reduce to Reduce

total 34663 8800 26655 2569 2716 2836

Directory Reorganization Statistics (pass 1 of 2)

Dirs Dirs Total Failed Blocks Blocks Immeds Searched Changed Ioctls Ioctls Reduced Changed Added

fset 999 8008 3121 5017 0 3037 4428 2569 total 8008 3121 5017 0 3037 4428 2569

Directory Reorganization Statistics (pass 2 of 2)

Dirs Dirs Total Failed Blocks Blocks Immeds Searched Changed Ioctls Ioctls Reduced Changed Added

fset 999 5439 552 2448 0 708 4188 0 total 5439 552 2448 0 708 4188 0

Directory Fragmentation Report

Dirs Total Immed Immeds Dirs to Blocks Searched Blocks Dirs to Add Reduce to Reduce

total 34663 6231 29224 0 147 267

The Dirs Searched column contains the number of directories searched. Only directories with data extents are reorganized. Immediate directories are skipped. The Dirs Changed contains the number of directories for which a change was made.

The Total Ioctls column contains the total number of VX_DIRSORT ioctls performed. Reorganization of directory extents is performed using this ioctl.

The Failed Ioctls column contains the number of requests that failed. The reason for failure is usually that the directory being reorganized is active. A few failures are typical in most file systems. If the -v option is specified, all ioctl calls and status returns are recorded.

The Blocks Reduced column contains the total number of directory blocks freed by compressing entries. The Blocks Changed column contains the total number of directory blocks updated while sorting and compressing entries.

The Immeds Added column contains the total number of directories with data extents that were compressed into immediate directories.

Reporting on Extent Fragmentation

As files are created and removed, over time the free extent map for an allocation unit changes from having one large free area to having many smaller free areas. This process is known as fragmentation. Also, when files increase in size (particularly when growth occurs in small increments), small files can be allocated in multiple extents. In the best case, each file that is not sparse has exactly one extent (containing the entire file), and the free-extent map is one continuous range of free blocks.

Determining Fragmentation

To determine whether a file system is fragmented, the free extents for that file system must be examined. If a large number of small extents are free, there is fragmentation. If more than half of the amount of free space is used by small extents (smaller than 64 blocks), or there is less than 5 percent of total file system space available in large extents, there is serious fragmentation.

Running The Extent-fragmentation Report

The extent-fragmentation report provides detailed information about the degree of fragmentation in a given file system.

The command syntax for an extent-fragmentation report is:


fsadm -E [-l largesize] [-r rawdev] mount_point

The extent reorganization facility considers certain extents to be immovable, that is, if the file already contains large extents, reallocating and consolidating these extents does not improve performance. The -l option controls when fsadm considers an extent immovable. By default, largesize is 64 blocks. For the extent-fragmentation report, the value for largesize affects which extents are reported as being immovable extents.

The following is an example of the output generated by the fsadm -E command:


# fsadm -F vxfs -E /home

Extent Fragmentation Report

Total Average Average Total Files File Blks # Extents Free Blks 939 11 2 245280 blocks used for indirects: 0 % Free blocks in extents smaller than 64 blks: 8.35 % Free blocks in extents smaller than 8 blks: 4.16 % blks allocated to extents 64 blks or larger: 45.81 Free Extents By Size 1: 356 2: 292 4: 271 8: 181 16: 23 32: 7 64: 3 128: 1 256: 1 512: 0 1024: 1 2048: 1 4096: 2 8192: 2 16384: 1 32768: 2

The numbers in the Total Files column indicate the total number of files that have data extents.

The Average File Blks column contains the average number of blocks belonging to all files.

The Average # Extents column contains the average number of extents used by files in the file system.

The Total Free Blks column contains the total number of free blocks in the file system. The total number of blocks used for indirect address extent are reported as blocks used for indirects.

The general shape of free extent map is also reported. There are two percentages reported: % free extents smaller than 64 blocks and % free extents smaller than 8 blocks. These numbers are typically near zero on an unfragmented file system.

Another metric reported is the percentage of blocks that are part of extents 64 blocks or larger. Files with a single small extent are not included in this calculation. This number is typically large on file systems that contain many large files and is small on file systems that contain many small files.

The figures under the heading Free Extents By Size indicate the totals for free extents of each size. The totals are for free extents of size 1, 2, 4, 8, 16... up to a maximum of the number of data blocks in an allocation unit. The totals are similar to the output of the df -o command unless there was recent allocation or deallocation activity (because fsadm acts on mounted file systems). These figures provide an indication of fragmentation and extent availability on a file system.

Extent Reorganization

If the -e option is specified, fsadm reorganizes data extents on the file system whose mount point is mount_point. The primary goal of extent reorganization is to defragment the file system.

To reduce fragmentation, extent reorganization tries to place all small files into one contiguous extent. The -l option specifies the size of a file that is considered large. The default is 64 blocks. Extent reorganization also tries to group large files into large extents of at least 64 blocks. Extent reorganizations can improve performance. Small files can be read or written in one I/O operation, and large files can approach raw-disk performance for sequential I/O operations.

fsadm performs extent reorganization on all inodes in the file system. Each pass through the inodes moves the file system closer to optimal organization.

fsadm reduces both file fragmentation and free extent fragmentation in each pass. In current versions of VxFS, fsadm relies on VxFS kernel allocation mechanisms to reallocate files in a more favorable extent geometry. At the same time, the kernel allocation mechanism is prevented from using blocks in areas of the free list that fsadm tries to make more contiguous.

The command syntax to perform extent reorganization is:


fsadm -e [-E][-s][-v][-l largesize][-p passes] [-r rawdev][-t time] mount_point

The following example shows the output from the fsadm -e -s command:


# fsadm -F vxfs -e -s /mnt1

Extent Fragmentation Report Total Average Average Total Files File Blks # Extents Free Blks 939 11 2 245280 blocks used for indirects: 0 % Free blocks in extents smaller than 64 blks: 8.35 % Free blocks in extents smaller than 8 blks: 4.16 % blks allocated to extents 64 blks or larger: 45.81

Free Extents By Size 1: 356 2: 292 4: 271 8: 181 16: 23 32: 7 64: 3 128: 1 256: 1 512: 0 1024: 1 2048: 1 4096: 2 8192: 2 16384: 1 32768: 2

Pass 1 Statistics Extents Reallocations Ioctls Errors Searched Attempted Issued FileBusy NoSpace Total total 2016 1473 789 0 0 0

Pass 2 Statistics Extents Reallocations Ioctls Errors Searched Attempted Issued FileBusy NoSpace Total total 1836 0 0 0 0 0

Extent Fragmentation Report Total Average Average Total Files File Blks # Extents Free Blks 939 11 1 245280 blocks used for indirects: 0 % Free blocks in extents smaller than 64 blks: 0.46 % Free blocks in extents smaller than 8 blks: 0.03 % blks allocated to extents 64 blks or larger: 45.53

Free Extents By Size 1: 10 2: 1 4: 1 8: 4 16: 3 32: 4 64: 3 128: 3 256: 3 512: 4 1024: 4 2048: 2 4096: 3 8192: 1 16384: 1 32768: 2

In this example, the default five passes were scheduled, but the reorganization completed in two passes.

This file system had a significant amount of free space although there were several free small extents. The situation was corrected by reallocating one or more of the extents on many of the files. The files selected for reallocation in this case are those with extents in the heavily fragmented section of the allocation units. The time it takes to complete extent reorganization varies, depending on the degree fragmentation, disk speed, and the number of inodes in the file system. In general, extent reorganization takes approximately one minute for every 100 megabytes of disk space.

In the preceding example, the Extents Searched column contains the total number of extents examined. The Reallocations Attempted column contains the total number of consolidations or merging of extents performed. The Ioctls Issued column contains the total number of reorganization request calls made during the pass. This corresponds closely to the number of files that are being operated on in that pass, as most files can be reorganized with a single ioctl. More than one extent may be consolidated in one operation.

The File Busy column (located under the heading Errors) shows the total number of reorganization requests that failed because the file was active during reorganization. The NoSpace column (located under the heading Errors) contains the total number of reorganization requests that failed because an extent presumed free was allocated during the reorganization. The Total column (located under the heading Errors) is the total number of errors encountered during the reorganization and may include errors that were not included with FileBusy or NoSpace.

The following command performs an extent reorganization on all individual files under the mount point mnt1:


find /mnt1 -print | fsadm -F vxfs -e -f -

Reorganization Prevention

Some specific applications may prevent extent and log reorganization from taking place by creating the /etc/vx/vxfs_noreorg_config file. When this file exists and the fsadm command options specified would result in either an extent (-e) or log reorganization, fsadm will return an error with the proper notification. The /etc/vx/vxfs_noreorg_config file should not be created or removed arbitrarily. Only those applications with explicit knowledge and need would create the file, and remove it when the need no longer exists. This method of reorganization prevention may be removed at any time without prior notice, and should not be depended on.

FILES

lost+found/.fsadm Lock file.
/dev/vx/rdsk/* File system devices.
/etc/vfstab Table of file system default parameters.

SEE ALSO

df_vxfs(1M), fsckptadm(1M), fsclustadm(1M), fsvoladm(1M), mkfs_vxfs(1M), mount_vxfs(1M), vxupgrade(1M), fcntl(2), vxfs_ts_reclaim(3), vfstab(4), vxfsio(7)


VxFS 5.1 fsadm_vxfs (1M)