HPlogo HP-UX Reference Volume 2 of 5 > f

fsadm_vxfs(1M)

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

NAME

fsadm (vxfs) — resize or reorganize a VxFS file system

SYNOPSIS

/usr/sbin/fsadm [-F vxfs] [-V] [-D] mount_point

/usr/sbin/fsadm [-F vxfs] [-V] [-E] mount_point

/usr/sbin/fsadm [-F vxfs] [-V] [-e] [-E] [-s] [-v] [-l largesize] [-a days] [-t time] [-p passes] [-r rawdev] mount_point

/usr/sbin/fsadm [-F vxfs] [-V] [-d] [-D] [-s] [-v] [-a days] [-t time] [-p passes] [-r rawdev] mount_point

/usr/sbin/fsadm [-F vxfs] [-V] [-b newsize] [-r rawdev] mount_point

/usr/sbin/fsadm [-F vxfs] [-V] [-o largefiles|nolargefiles] mount_point|special

DESCRIPTION

fsadm is designed to perform various online administration functions on VxFS file systems. The current version supports querying or changing the file-system compatibility bits, file-system resizing, extent reorganization, and directory reorganization. fsadm operates on file systems mounted for read/write access. The -o option can also operate on a device containing a clean, unmounted file system. Only a privileged user can change compatibility bits on a mounted file system or resize or reorganize a file system.

Options

-F vxfs

Specify the VxFS file system type.

-V

Echoes the completed command line, but performs no other action. The command line is generated by incorporating the user-specified options. This option allows the user to verify the command line.

-b newsize

Resize the file system to newsize sectors.

-D

Report on directory fragmentation. If specified in conjunction with the -d option, the fragmentation report is produced both before and after the directory reorganization.

-E

Report on extent fragmentation. If specified in conjunction with the -e option, the fragmentation report is produced both before and after the extent reorganization.

-d

Reorganize 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.

-e

Extent reorganization. Attempt to minimize fragmentation. Aged files are moved to the end of the allocation units to produce free space. Other files are reorganized to have the minimum number of extents possible.

-s

Print a summary of activity at the end of each pass.

-v

Verbose. Report reorganization activity.

-a days

Consider files not accessed within the specified number of days as aged files. The default is 14 days. Aged files are moved to the end of the directory by the -d option, and reorganized differently by the -e option.

-l largesize

Large file size in file system blocks. Indicates the size of files to be considered as large files. The value must be between 8 and 2048 blocks. The default is 64 blocks.

-p passes

Maximum number of passes to run. The default is 5 passes. Reorganizations are processed until reorganization is complete, or the specified number of passes have been run.

-r rawdev

Pathname of raw device to read to determine file layout and fragmentation. This option can be used when fsadm cannot determine what the raw device should be.

-t time

Maximum time to run. Reorganizations are processed until reorganization is complete, or the time limit has expired. time is specified in seconds.

-o specific_options

Specifies options specific to the vxfs file system type. specific_options is a list of suboptions pairs intended for the vxfs-specific module of the command.

The following specific_options are valid on a VxFS file system:

largefiles

Set the largefile compatibility bit for the file system. When this bit is set large files (greater than 2 Gbyte) can be created on the file system.

nolargefiles

Clear the largefile compatibility bit for the file system. When this bit is not set, large files cannot be created on the file system. An attempt to clear the bit will fail if any large files exist on the file system.

The -o largefiles, -o nolargefiles, -b, -D, -E, -d, and -e options determine what function will be performed. If none of these options is specified fsadm will print the current compatibility-bit settings and exit. Otherwise it will perform the function(s) defined by the option(s). The -b, -o largefiles, and -o nolargefiles options cannot be specified if any other of these options are given. If both -e and -d are specified, fsadm will perform the directory reorganization first. It will perform the extent reorganization after the directory reorganization has been completed.

File-System Compatibility Bits

The -o largefiles and -o nolargefiles options can be used to change the largefile compatibility bit. When invoked without options fsadm prints the current state of the compatibility bits.

VxFS 3.0 has some new features that are incompatible with earlier versions of HP-UX and with old applications. These features are large files (file sizes greater than 2 Gbyte), and hierarchical storage management via the DMAPI (Data Management Applications Programming Interface).

Large files are available only with the Version 3 disk layout, available in VxFS 3.0 and above, so an old version of HP-UX will never be exposed to them (the file-system mount would fail). But many existing applications will break if confronted with large files, so a compatibility bit is provided that allows or prevents the creation of large files on the file system. If the largefile compatibility bit is set, large files may be created on the file system. If it is not set, any attempt to create a large file on the file system will fail.

An attempt to set the bit via the -o largefiles option will succeed only if the file system has the Version 3 disk layout (see the vxupgrade(1M) manual page to upgrade a file system from the Version 2 disk layout to the Version 3 disk layout). An attempt to clear the bit via the -o nolargefiles option will succeed only if the bit is set and there are no large files present on the file system. (Also see the mount_vxfs(1M) manual page).

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 an unmounted file system is specified, it must be clean.

The DMAPI compatibility bit cannot be changed by fsadm; it can only be queried. If set, it indicates that the file system is mounted, or has been mounted, under the control of the Hierarchical Storage Management software and cannot be mounted unless that software is active on the system.

Defragmentation

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

There are two options that are available to control the amount of work done by fsadm. The -t option is used to specify a maximum length of time to run. The -p option is used to specify a maximum number of passes to run. If both are specified, the utility exits if either of the terminating conditions is reached. By default, fsadm will run 5 passes. If both the -e and -d options are specified, the utility will run 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 the file does not exist, it is created. The fcntl(2) system call is used to obtain a write lock on the file. If the write lock fails, fsadm will assume that another fsadm is running and will fail. fsadm will report the process ID of the process holding the write lock on the .fsadm file.

File System Resizing

If the -b option is specified, fsadm will resize the file system whose mount point is mount_point. If newsize is larger than the current size of the file system, the file system will be expanded to newsize sectors. Similarly, if newsize is smaller than the current size of the file system, an attempt will be made to shrink the file system to newsize sectors.

Increasing the size of a file system requires that the file system contains enough free space, prior to the expansion, for the growth of the structural files. In the case where a filesystem has no free blocks available, the attempt to increase the size of the file system will fail (see the extendfs(1M) manual page for an alternate method to increase file system size).

Reducing the size of a file system will fail if there are file-system resources currently in use within the sectors to be removed from the file system. In this case, a reorganization may help free those busy resources and allow a subsequent reduction in the size of the file system.

Reporting on Directory Fragmentation

As files are allocated and freed, directories tend to grow and become sparse. In general, a directory is as large as the largest number of files it ever contained, even if some files have been subsequently removed.

The command line to obtain a directory fragmentation report is:

fsadm [-D] [-r rawdev] mount_point

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

# fsadm -D /lhome

Directory Fragmentation Report Dirs Total Immed Immeds Dirs to Blocks to Searched Blocks Dirs to Add Reduce Reduce au 0 15 3 12 0 0 0 au 1 0 0 0 0 0 0 total 15 3 12 0 0 0

The column labeled "Dirs Searched" 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 column labeled "Total Blocks" contains the total number of blocks used by directory extents.

The column labeled "Immed Dirs" 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 pathname resolution. The column labeled "Immeds to Add" 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 column labeled "Dirs to Reduce" 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. Since directory entries vary in length, it is possible that 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 nonzero "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 column labeled "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 columns labeled "Dirs to Reduce" are substantial, a directory reorganization should improve performance of pathname resolution. The directories that fragment tend to be the directories with the most activity. A small number of fragmented directories may account for a large percentage of name lookups in the file system.

Directory Reorganization

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

For compression, the valid entries in the directory are moved to the front of the directory and the free space is grouped 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 directory entries are small enough, the directory will be placed in the inode immediate data area.

The entries in a directory are also sorted to improve pathname lookup performance. Entries are sorted based on the last access time of the entry. The -a option is used to specify 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 bucket 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 directory reorganization runs in one pass across the entire file system.

The command line to reorganize directories of a file system is:

fsadm -d [-s] [-v] [-p passes] [-t timeout] [-r rawdev] [-D] mount_point

The following example illustrates the output of the command fsadm -d -s command:

# fsadm -d -s /lhome

Directory Reorganization Statistics Dirs Dirs Total Failed Blocks Blocks Immeds Searched Changed Ioctls Ioctls Reduced Changed Added au 0 2343 1376 2927 1 209 3120 72 au 1 582 254 510 0 47 586 28 au 2 142 26 38 0 21 54 16 au 3 88 24 29 1 5 36 2 total 3155 1680 3504 2 282 3796 118

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

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

The column labeled "Failed Ioctls" contains the number of requests that failed for some reason. The reason for failure is usually that the directory being reorganized is active. A few failures should be no cause for alarm. If the -v option is used, all ioctl calls and status returns are recorded.

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

The column labeled "Immeds Added" 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 will change from having one large free area to having many smaller free areas. This process is known as fragmentation. Also, when files are grown — particularly when growth occurs in small increments — small files could be allocated in multiple extents. In the ideal case, each file that is not sparse would have exactly one extent (containing the entire file), and the free-extent map would be one continuous range of free blocks.

Conversely, in a case of extreme fragmentation, there can be free space in the file system, none of which can be allocated. For example, on Version 2 VxFS file systems, the indirect-address extent size is always 8K long. This means that to allocate an indirect-address extent to a file, an 8K extent must be available. For example, if no extent of 8K byes or larger is available, even though more than 8K of free space is available, an attempt to allocate a file into indirect extents will fail and return ENOSPC.

Determining Fragmentation

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

Running the Extent-Fragmentation Report

The extent-fragmentation report can be run to acquire detailed information about the degree of fragmentation in a given file system.

The command line to run an extent-fragmentation report is

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

The extent reorganizer has the concept of an immovable extent: if the file already contains large extents, reallocating and consolidating these extents will not improve performance, so they are considered immovable. fsadm's notion of how large an extent must be to qualify as immovable can be controlled by the -l option. By default, largesize is 64 blocks, meaning that any extent larger than 64 blocks is considered to be immovable. For the purposes of the extent-fragmentation report, the value chosen for largesize will affect which extents are reported as being immovable extents.

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

# fsadm -E /lhome

Extent Fragmentation Report Files with Total Total Extents Extents Blocks Distance au 0 14381 18607 30516 4440997 au 1 2822 3304 24562 927841 au 2 2247 2884 22023 1382962 au 3 605 780 24039 679867 total 19992 25575 101140 7431667 Consolidatable Immovable Extents Blocks Extents Blocks au 0 928 2539 0 0 au 1 461 5225 99 13100 au 2 729 8781 58 11058 au 3 139 1463 49 17258 total 2257 18008 206 41416 Free Extents By Size au 0 Free Blocks 217, Smaller Than 8 - 48%, Smaller Than 64 - 100% 1: 15 2: 15 4: 15 8: 14 16: 0 32: 0 64: 0 128: 0 256: 0 512: 0 1024: 0 2048: 0 096: 0 8192: 0 16384: 0 au 1 Free Blocks 286, Smaller Than 8 - 41%, Smaller Than 64 - 100% 1: 16 2: 21 4: 15 8: 13 16: 4 32: 0 64: 0 128: 0 256: 0 512: 0 1024: 0 2048: 0 4096: 0 8192: 0 16384: 0 au 2 Free Blocks 510, Smaller Than 8 - 15%, Smaller Than 64 - 100% 1: 10 2: 14 4: 10 8: 14 16: 8 32: 6 64: 0 128: 0 256: 0 512: 0 1024: 0 2048: 0 4096: 0 8192: 0 16384: 0 au 3 Free Blocks 6235, Smaller Than 8 - 3%, Smaller Than 64 - 15% 1: 29 2: 33 4: 27 8: 30 16: 18 32: 8 64: 4 128: 3 256: 2 512: 2 1024: 1 2048: 1 4096: 0 8192: 0 16384: 0 au 4 Free Blocks 8551, Smaller Than 8 - 2%, Smaller Than 64 - 22% 1: 29 2: 33 4: 30 8: 38 16: 28 32: 29 64: 26 128: 11 256: 8 512: 3 1024: 0 2048: 0 4096: 0 8192: 0 16384: 0 total Free Blocks 15799, Smaller Than 8 - 4%, Smaller Than 64 - 24% 1: 99 2: 116 4: 97 8: 109 16: 58 32: 43 64: 30 128: 14 256: 10 512: 5 1024: 1 2048: 1 4096: 0 8192: 0 16384: 0

The numbers in the column labeled ``Files with Extents'' indicate the total number of files that have data extents. A file is considered to be in the extent-allocation unit that contains the extent holding the file's inode.

The column labeled ``Total Extents'' contains the total number of extents belonging to files in the allocation unit. The extents themselves are not necessarily in the same allocation unit.

The column labeled ``Total Blocks'' contains the total number of blocks used by files in the allocation unit. If the total number of blocks is divided by the total number of extents, the resulting figure is the average extent size.

The column labeled ``Total Distance'' contains the total distance between extents in the allocation unit. For example, if a file has two extents, the first containing blocks 100 through 107 and the second containing blocks 110 through 120, the distance between the extents is 110-107, or 3. In general, a lower number means that files are more contiguous. If an extent reorganization is run on a fragmented file system, the value for Total Distance should be reduced.

The column labeled ``Consolidatable Extents'' contains the number of extents that are candidates to be consolidated. Consolidation means merging two or more extents into one combined extent. For files that are entirely in direct extents, the extent reorganizer will attempt to consolidate extents into extents up to size largesize. All files of size largesize or less will typically be contiguous in one extent after reorganization. Since most files are small, this will usually include about 98 percent of all files.

The column labeled ``Consolidatable Blocks'' contains the total number of blocks in Consolidatable Extents. The column labeled ``Immovable Extents'' contains the total number of extents that are considered to be immovable. In the report, an immovable extent appears in the allocation unit of the extent itself, as opposed to in the allocation unit of its inode. This is because the extent is considered to be immovable, and thus permanently fixed in the associated allocation unit.

The column labeled ``Immovable Blocks'' contains the total number of blocks in immovable extents. The figures under the heading ``Free Extents By Size'' indicate per-allocation unit 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 should match the output of df -o s unless there has been recent allocation or deallocation activity (as this utility acts on mounted file systems). These figures give an indication of fragmentation and extent availability on a per-allocation-unit basis. For each allocation unit, and for the complete file system, the total free blocks and total free blocks by category are shown. The figures are presented as follows:

  • The figure labeled ``Free Blocks'' indicates the total number of free blocks.

  • The figure labeled ``Smaller Than 8'' indicates the percentage of free blocks that are in extents less than 8 blocks in length.

  • The figure labeled ``Smaller Than 64'' indicates the percentage of free blocks that are in extents less than 64 blocks in length.

In the preceding example, 4 percent of free space is in extents less than 8 blocks in length, and 24 percent of the free space is in extents less than 64 blocks in length. This represents a typical value for a mature file system that is regularly reorganized. The total free space is about 10 percent.

Extent Reorganization

If the -e option is specified, fsadm will reorganize the 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 in one contiguous extent. The -l option is used to specify 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. In addition to reducing fragmentation, extent reorganizations improves performance. Small files can be read or written in one I/O operation. Large files can approach raw-disk performance for sequential I/O operations.

Extent reorganization also tries to improve the locality of reference on the file system. Extents are moved into the same allocation unit as their inode. Within the allocation unit, small files and directories are migrated to the front of the allocation unit. Large files and inactive files are migrated towards the back of the allocation unit. (A file is considered inactive if the access time on the inode is more than 14 days old. The time interval can be varied using the -a option.) Extent reorganization should reduce the average seek time by placing inodes and frequently used data closer together.

fsadm will try to perform extent reorganization on all inodes on the file system. Each pass through the inodes will move the file system closer to the organization considered optimal by fsadm. The first pass might place a file into one contiguous extent. The second pass might move the file into the same allocation unit as its inode. Then, since the first file has been moved, a third pass might move extents for a file in another allocation unit into the space vacated by the first file during the second pass.

When the file system is more than 90% full, fsadm shifts to a different reorganization scheme. Instead of attempting to make files contiguous, extent reorganization tries to defragment the free-extent map into chunks of at least 64 blocks or the size specified by the -l option.

The command line to perform extent reorganization is

fsadm -F vxfs -e [-sv] [-p passes] [-t time] [-a days] [-l largesize] [-r rawdev] mount_point

The following example illustrates the output from the fsadm -F vxfs -e -s command:

# fsadm -F vxfs -e -s /lhome

Allocation Unit 0, Pass 1 Statistics Extents Consolidations Performed Total Errors Searched Number Extents Blocks File Busy Not Free au 0 2467 11 30 310 0 0 au 1 0 0 0 0 0 0 au 2 0 0 0 0 0 0 au 3 0 0 0 0 0 0 au 4 0 0 0 0 0 0 total 2467 11 30 310 0 0 In Proper Location Moved to Proper Location Extents Blocks Extents Blocks au 0 1379 8484 794 10925 au 1 0 0 0 0 au 2 0 0 0 0 au 3 0 0 0 0 au 4 0 0 0 0 total 1379 8484 794 10925 Moved to Free Area In Free Area Could not be Moved Extents Blocks Extents Blocks Extents Blocks au 0 231 4851 4 133 0 0 au 1 0 0 0 0 0 0 au 2 0 0 0 0 0 0 au 3 0 0 0 0 0 0 au 4 0 0 0 0 0 0 total 231 4851 4 133 0 0 Allocation Unit 0, Pass 2 Statistics Extents Consolidations Performed Total Errors Searched Number Extents Blocks File Busy Not Free au 0 2467 0 0 0 0 0 au 1 0 0 0 0 0 0 au 2 0 0 0 0 0 0 au 3 0 0 0 0 0 0 au 4 0 0 0 0 0 0 total 2467 0 0 0 0 0 In Proper Location Moved to Proper Location Extents Blocks Extents Blocks au 0 2173 19409 235 4984 au 1 0 0 0 0 au 2 0 0 0 0 au 3 0 0 0 0 au 4 0 0 0 0 total 2173 19409 235 4984 Moved to Free Area In Free Area Could not be Moved Extents Blocks Extents Blocks Extents Blocks au 0 0 0 0 0 0 0 au 1 0 0 0 0 0 0 au 2 0 0 0 0 0 0 au 3 0 0 0 0 0 0 au 4 0 0 0 0 0 0 total 0 0 0 0 0 0

Note that the default five passes were scheduled, but the reorganization finished in two passes.

This file system had not had much activity since the last reorganization, with the result that little reorganization was required. The time it takes to complete extent reorganization varies, depending on fragmentation and disk speeds. However, in general, extent reorganization may be expected to take approximately one minute for every 10 megabytes of disk space used.

In the preceding example, the column labeled ``Extents Searched'' contains the total number of extents examined. The column labeled ``Number'' (located under the heading ``Consolidations Performed'') contains the total number of consolidations or merging of extents performed. The column labeled ``Extents'' (located under the heading ``Consolidations Performed'') contains the total number of extents that were consolidated. (More than one extent may be consolidated in one operation.) The column labeled ``Blocks'' (located under the heading ``Consolidations Performed'') contains the total number of blocks that were consolidated.

The column labeled ``File Busy'' (located under the heading ''Total Errors'') contains the total number of reorganization requests that failed because the file was active during reorganization. The column labeled ``Not Free'' (located under the heading ``Total Errors'') contains the total number of reorganization requests that failed because an extent that the reorganizer expected to be free was allocated at some time during the reorganization.

The column labeled ``In Proper Location'' contains the total extents and blocks that were already in the proper location at the start of the pass. The column labeled ``Moved to Proper Location'' contains the total extents and blocks that were moved to the proper location during the pass.

The column labeled ``Moved to Free Area'' contains the total number of extents and blocks that were moved into a convenient free area in order to free up space designated as the proper location for an extent in the allocation unit being reorganized. The column labeled ``In Free Area'' contains the total number of extents and blocks that were in areas designated as free areas at the beginning of the pass.

The column labeled ``Could not be Moved'' contains the total number of extents and blocks that were in an undesirable location and could not be moved. This occurs when there is not enough free space to allow sufficient extent movement to take place. This often occurs on the first few passes for an allocation unit if a large amount of reorganization needs to be performed.

If the next to the last pass of the reorganization run indicates extents that cannot be moved, then the reorganization fails. A failed reorganization may leave the file system badly fragmented, since free areas are used when trying to free up reserved locations. To lessen this fragmentation, extents are not moved into the free areas on the final two passes of the extent reorganizer, and the last pass of the extent reorganizer only consolidates free space.

Notes

The online reorganization and online resize features of fsadm are available only with the Advanced VxFS package.

FILES

lost+found/.fsadm

lock file /dev/rdsk/* file-system devices

© Hewlett-Packard Development Company, L.P.