C H A P T E R 2

File System Design

Well-designed file systems are critical to ensuring quick and uninterrupted access to information. Good design is also essential to file system recovery. This chapter contains the following sections:

- Design Basics

- Inode Files and File Characteristics

- Specifying Disk Allocation Units and Stripe Widths

- File Allocation Methods

##

Design Basics

Sun StorEdge QFS and Sun StorEdge SAM-FS file systems are multithreaded, advanced storage management systems. To take maximum advantage of these capabilities, create multiple file systems whenever possible.

The Sun StorEdge QFS and Sun StorEdge SAM-FS file systems use a linear search method when performing directory lookups. They search from the beginning of the directory to the end. As the number of files in a directory increases, the search time through the directory also increases. Users who have directories with thousands of files can experience excessive search times. These long search times are also evident when you restore a file system. To increase performance and speed up file system dumps and restores, you should keep the number of files in a directory under 10,000.

Both the directory name lookup cache (DNLC) feature and the directory DNLC feature improve file system performance. Directory DNLC is available in all Solaris operating system (OS) 9 releases and in the later Solaris OS release 8 updates.

##

Inode Files and File Characteristics

The types of files to be stored in a file system affect file system design. An inode is a 512-byte block of information that describes the characteristics of a file or directory. This information is allocated dynamically within the file system.

The inodes are stored in the`.inodes` file located under the file system mount point. A Sun StorEdge SAM-FS`.inodes` file resides on the same physical device as the file data and is interleaved with the file data. In contrast, a Sun StorEdge QFS `.inodes` file resides on a metadata device that is separate from the file data device.

Like a standard Solaris operating system (OS) inode, a Sun StorEdge QFS or Sun StorEdge SAM-FS file system inode contains the file's POSIX standard inode times: file access, file modification, and inode changed times. The Sun StorEdge QFS and Sun StorEdge SAM-FS file systems add a creation time, an attribute change time, and a residence time. TABLE 2-1 summarizes the times that are recorded in the inode.

TABLE 2-1 Content of `.inode` Files
Time | Incident
--- | ---
`access` | Time the file was last accessed. POSIX standard.
`modification` | Time the file was last modified. POSIX standard.
`changed` | Time the inode information was last changed. POSIX standard.
`attributes` | Time the attributes specific to the Sun StorEdge QFS or Sun StorEdge SAM-FS files systems were last changed. Sun Microsystems extension.
`creation` | Time the file was created. Sun Microsystems extension.
`residence` | Time the file changed from offline to online or vice versa. Sun Microsystems extension.

The attributes specific to the Sun StorEdge QFS and Sun StorEdge SAM-FS file systems include both user settings and general file states. The following two sections describe these characteristics.

### File Attributes and File States

A file's user-specified attributes and its system-specified states are stored in the file's inode. You can use the `sls`(1) `-D` command to display these inode attributes. For more information about`sls`(1) options, see the`sls`(1) man page.

A user can specify the following commands to set attributes:

- `archive`(1)

- `ssum`(1)

- `release`(1)

- `segment`(1)

- `setfa`(1)

- `stage`(1)

Users can set attributes from within applications by specifying the following application programming interface (API) routines:

- `sam_archive`(3)

- `sam_release`(3)

- `sam_segment`(3)

- `sam_setfa`(3)

- `sam_ssum`(3)

- `sam_stage`(3)

#### User-Specified File Attributes

TABLE 2-2 shows the user-specified attributes that are listed in the inode.

TABLE 2-2 User-Specified File Attributes
Command | Definition | Used By
--- | --- | ---
`archive -C` | The file is marked for concurrent archiving. This means that the file can be archived even if it is open for a write operation. You can use the `archive`(1) command to set this attribute. | Sun StorEdge SAM-FS
`archive -n` | The file is marked to never be archived. The superuser can use the `archive`(1) command to set this attribute. | Sun StorEdge SAM-FS
`release -a` | This file is marked to be released as soon as one archive copy is made. You can set this attribute from within the`archiver.cmd` file or by using the`release`(1) command. | Sun StorEdge SAM-FS
`release -n` | This file is marked to never be released. You can set this attribute from within the archiver.cmd file, or the superuser can use the release(1) command to set it. | Sun StorEdge SAM-FS
`release -p` | The file is marked for partial release. You can set this attribute from within the`archiver.cmd` file or by using the`release`(1) command. | Sun StorEdge SAM-FS
`stage -a` | The file is marked for associative staging. You can set this attribute from within the`archiver.cmd` file or by using the`stage`(1) command. | Sun StorEdge SAM-FS
`stage -n` | The file is marked to never be staged. This signifies direct access to removable media cartridges. You can set this attribute from within the`archiver.cmd` file, or the superuser can use the `stage`(1) command to set it. Not supported on Sun StorEdge QFS shared file system clients. | Sun StorEdge SAM-FS
`setfa -D` | The file is marked for direct I/O. | Sun StorEdge QFS Sun StorEdge SAM-FS
`setfa -g` n | The file is marked for allocation on striped group n. | Sun StorEdge QFS
`setfa -s` m | The file is marked for allocation with a stripe width of m. | Sun StorEdge QFS Sun StorEdge SAM-FS
`segment` n `m stage_ahead` x |
| The file is marked for segmentation. The`` n `m` notation indicates that the segment is n megabytes in size. The`stage_ahead` x`` attribute indicates the number of segments (x) to be staged ahead. You can use the `segment`(1) command to set this attribute. | Sun StorEdge SAM-FS

You can set the attributes shown in TABLE 2-2 on both files and directories. After directory attributes are set, files that are created in the directory inherit all the directory attributes at the time of creation. Files created before an attribute is applied to the parent directory do not inherit directory attributes.

Users can gather information about file attributes by using the `sls`(1) command, which is described in Displaying File Information.

#### System-Specified File States

TABLE 2-3 shows the various states that the file systems set for a file. These states are stored in the inode.

TABLE 2-3 System-Specified File States
Attribute | Definition | Used By
--- | --- | ---
`archdone` | Indicates that the file's archive requirements have been met. There is no more work the archiver must do on the file. The archiver sets this attribute. It cannot be set by a user. Note that `archdone` does not necessarily indicate that the file has been archived. | Sun StorEdge SAM-FS
`damaged` | The file is damaged. The stager or the`samfsrestore`(1M) command sets this attribute. You can use the`undamage`(1M) command to reset this attribute to undamaged. If this attribute has been set by the `samfsrestore`(1M) utility, it means that no archive copies existed for the file at the time a `samfsdump`(1M) was taken. You can reset this attribute to undamaged, but the file might still be unrecoverable. | Sun StorEdge SAM-FS
`offline` | The file data has been released. The releaser sets this attribute. You can also set this attribute by using the`release`(1) command. | Sun StorEdge SAM-FS

Users can gather information about file states by using the`sls`(1) command, which is described in Displaying File Information.

### Displaying File Information

The Sun StorEdge QFS and Sun StorEdge SAM-FS `sls`(1) command extends the standard UNIX `ls`(1) command and provides more information about a file. CODE EXAMPLE 2-1 shows detailed `sls`(1) command output that displays the inode information for file `hgc2`.

CODE EXAMPLE 2-1 `sls` (1) Output in a Sun StorEdge SAM-FS Environment
    # sls -D hgc2
    hgc2:
      mode: -rw-r--r--  links:   1  owner: root      group: other
      length:     14971  admin id:      0  inode:       30.5
      archdone;
      segments 3, offline 0, archdone 3, damaged 0;
      copy 1: ---- Jun 13 17:14     2239a.48   lt MFJ192
      copy 2: ---- Jun 13 17:15      9e37.48   lt AA0006
      access:      Jun 13 17:08  modification: Jun 13 17:08
      changed:     Jun 13 17:08  attributes:   Jun 13 17:10
      creation:    Jun 13 17:08  residence:    Jun 13 17:08

TABLE 2-4 describes the meaning of each row of `sls`(1) output shown in CODE EXAMPLE 2-1. In TABLE 2-4, note that lines that pertain to archiving do not appear in `sls`(1) output in a Sun StorEdge QFS environment.

TABLE 2-4 `sls` (1) Output Explanation
Line Number | First Few Characters | Content
--- | --- | ---
1 | `mode:` | The file's mode and permissions, the number of hard links to the file, the owner of the file, and the group to which the owner belongs.
2 | `length:` | The file's length in bytes, the file's admin ID number, and the file's inode number. By default, the admin ID number is 0. If this number is greater than 0, it indicates the file's accounting category for counting files and blocks. You can set this number to a value greater than 0 even when file system quotas are not enabled on this file system. For information about file system quotas, see File System Quotas. The inode number is a two-part number that contains the inode number itself, followed by a period (.), followed by the inode generation number.
3 | `archdone;` | The file attributes specific to the file. For more information about this line, see the`sls`(1) man page.
4 | `segments` | The segment index information. This line does not appear unless the file is a segment index. The general format for this line is as follows: `segments` n`, offline` o`, archdone` a`, damaged` d`;` `segments` n shows the total number of data segments for this file. In this example, there are 3. `offline` o shows the number of data segments offline. In this example, there are no offline segments. `archdone` a shows the number of segments for which the archiving requirements have been met. In this example, there are 3. `damaged` d shows the number of damaged segments. In this example, there are no damaged segments.
5 | `copy 1:` | The first archive copy line. The `sls`(1) command displays one archive copy line for each active or expired archive copy. For more information, see Archive Copy Line Explanation.
6 | `copy 2:` | The second archive copy line. For more information, see Archive Copy Line Explanation.
7 | `access:` | The time the file was last accessed and modified.
8 | `changed:` | The time the file content was last changed and since the file's attributes were last changed.
9 | `creation:` | The time the file was created and became resident in the file system.

#### Archive Copy Line Explanation

The fields in the archive copy lines are as follows:

- The first field indicates the archive copy number.

- The second field contains four indicators, each of which is either a dash (-) or a letter. Reading them from left to right, TABLE 2-5 shows the information that the indicators convey.

TABLE 2-5 Archive Copy Line Indicators
Position | Meaning
--- | ---
1 | Indicates either an expired or active entry. An S indicates that the archive copy is expired. That is, the file was modified and this archive copy is a previous version of the file. A U indicates that the copy has been unarchived. Unarchiving is the process by which archive entries for files or directories are deleted. A dash (-) indicates that the archive copy is active and valid.
2 | Indicates whether the archive copy is to be rearchived. An r indicates that the archive copy is scheduled to be rearchived by the archiver. A dash (-) indicates that the archive copy is not to be rearchived by the archiver.
3 | Unused.
4 | Indicates whether the copy is damaged or undamaged. A `D` indicates that the archive copy is damaged. A damaged archive copy is not a candidate for staging. A dash (-) indicates that the archive copy is not damaged. It is a candidate for staging.

- The third field shows the date and time the archive copy was written to the archive media.

- The fourth field contains two hexadecimal numbers separated by a decimal point (.). The first hexadecimal number (`2239a`) indicates the position of the beginning of the archive file on the cartridge. The second hexadecimal number (`48`) is the file byte offset (divided by 512) of this copy in the archive file.

- The fifth and sixth fields in the archive copy line indicate the media type and the Volume Serial Name (VSN) where the archive copy resides.

#### Checksum Line Explanation

If a file has checksum-related attributes, the `sls`(1) command returns a `checksum` line. You can use the `ssum`(1) command to set these attributes (`generate`, `use`, or `valid`). This line appears in `sls`(1) output in Sun StorEdge SAM-FS environments. The format of the checksum line is as follows:

    checksum: gen  use  val  algo:  1

The system displays the preceding line if checksum attributes are set for a file. You can interpret this line as follows:

- If the `generate` attribute is not set,`no_gen` appears in place of`gen`.

- If the `use` attribute is not set,`no_use` appears.

- If the file has been archived and a checksum has been computed, `val` appears.

- If the file has not been archived or if no checksum has been computed,`not_val` appears.

- The keyword`algo` precedes the numeric algorithm indicator that specifies the algorithm that is used to generate the checksum value.

##

Specifying Disk Allocation Units and Stripe Widths

Disk space is allocated in blocks. These are also called disk allocation units (DAUs), which are the basic units of online disk storage. While sectors, tracks, and cylinders describe the physical disk geometry, the DAU describes the file system geometry. Choosing the appropriate DAU size and stripe size can improve performance and optimize magnetic disk usage. The DAU setting is the minimum amount of contiguous space that is used when a file is allocated.

Example: Assume that you have a Sun StorEdge SAM-FS file system. Your DAU is set to 16 kilobytes and you have disabled striping by setting`stripe=0`. You are using round-robin allocation (because of the`stripe=0` setting), and you have two files, as follows:

- The first file is a 15-kilobyte file. It occupies one DAU. The file data occupies 15 kilobytes of the DAU, and the other 1 kilobyte is not used.

- The second file is a 20-kilobyte file. It occupies two DAUs. The file data occupies all 16 kilobytes of the first DAU, and 4 kilobytes of the second DAU. The second DAU contains 12 kilobytes that are not used.

The `-a` allocation_unit option on the `sammkfs`(1M) command specifies the DAU setting.

If striped allocation is used, the stripe width mount option determines the maximum number of DAUs written in one I/O event. This setting is specified by the`-o stripe=`n`` option on the `mount`(1M) command. You must run the `sammkfs`(1M) command before you run the `mount`(1M) command.

The following sections describe how to configure DAU settings and stripe widths.

Note - Unless otherwise noted, Sun StorEdge QFS file system information throughout this manual applies to Sun SAM-QFS configurations as well.

### DAU Settings and File System Geometry

The Sun StorEdge QFS and Sun StorEdge SAM-FS file systems use an adjustable DAU. You can use this configurable DAU to tune the file system to the physical disk storage device. This minimizes the system overhead caused by read-modify-write operations. Applications that manipulate very large files can benefit substantially from this feature. For information about how to control the read-modify-write operation, see Increasing Large File Transfer Performance.

Each file system can have its own unique DAU setting. Thus, several mounted file systems can be active on a server, each with a different DAU setting. The DAU setting is determined when the file system is created using the`sammkfs`(1M) command. It cannot be changed dynamically.

The possible DAU settings differ depending on the file system you are using. The following sections describe the DAU settings for each file system. These sections also introduce the concept of the master configuration (`mcf` ) file. You create this ASCII file at system configuration time. It defines the devices and file systems used in your Sun StorEdge QFS or Sun StorEdge SAM-FS environment. The`mcf` file is introduced in the following sections, but it is more thoroughly discussed in Volume Management.

Two file allocation schemes are available to you: a dual allocation scheme and a single allocation scheme. The following sections describe these schemes.

#### Dual Allocation Scheme

A Sun StorEdge SAM-FS file system is defined as Equipment Type `ms` in your `mcf` file. The only device type allowed in a Sun StorEdge SAM-FS file system is type `md`. Both metadata and file data are written to the `md` devices in a Sun StorEdge SAM-FS file system. By default, the DAU on an `md` device is 16 kilobytes.

A Sun StorEdge QFS file system is defined as Equipment Type `ma` in your `mcf` file. Metadata is written to `mm` devices. Data can be written to `md`, `mr`, or `g` XXX devices.

The `md` and `mm` devices use a dual allocation scheme and are as follows:

- On `md` data devices, the small allocation is 4 kilobytes, and the large allocation is a DAU. The default DAU is 64 kilobytes in a Sun StorEdge QFS shared file system. The default DAU is 16 kilobytes in a Sun StorEdge QFS (unshared) file system. You can override this default when the file system is initialized by using the -`a` allocation_unit option to the `sammkfs`(1M) command. The DAU size can be either 16, 32, or 64 kilobytes.

When a file is created on an `md` device, the system allocates the first eight addresses of a file in the small allocation. If more space is needed, the file system uses one or more large allocations (DAUs) in expanding the file. As a result, I/O performance improves for large files while minimizing the disk fragmentation that can result from having many small files.

- On `mm` metadata devices, the small allocation is 4 kilobytes, and the large allocation is 16 kilobytes. The dual allocation scheme enables the file system to write metadata to disk more efficiently and helps minimize disk fragmentation.

Depending on the type of file data stored in the file system, selecting a larger DAU size can improve file system performance significantly. For information about tuning file system performance, see Advanced Topics.

#### Single Allocation Scheme

Only Sun StorEdge QFS file systems can include devices that use a single allocation scheme. The Sun StorEdge QFS file systems are Equipment Type `ma` in your `mcf` file. These file systems consist of separate metadata devices and data devices, as follows:

- The metadata devices can be defined only as Equipment Type `mm`.

- The data devices can be defined as Equipment Type `md`, `mr`, or `g` XXX. The `md` devices follow the dual allocation scheme of a Sun StorEdge SAM-FS file system and are limited to DAU sizes of 16 kilobytes, 32 kilobytes, or 64 kilobytes.

The `mr` and `g` XXX devices follow a single allocation scheme. You can mix `mr` and `g` XXX devices in a file system, but you cannot mix `md` devices with either `mr` or `g` XXX devices in a file system.

The DAU size for Sun StorEdge QFS file systems that use `mr` and `g` XXX data devices is configurable. The possible DAU sizes that can be used on data devices depend on the Equipment Type assigned to each data device in the `mcf` file. TABLE 2-6 shows these DAU sizes.

TABLE 2-6 Sun StorEdge QFS Equipment Types
Equipment Type | DAU Sizes
--- | ---
`mr` or `g` XXX | You can specify different DAU sizes by adjusting the default size in 8-kilobyte increments. The DAU size can be from 16 kilobytes to 65,528 kilobytes (64 megabytes). The default DAU for an `mr` or `g` XXX device in a Sun StorEdge QFS environment is 64 kilobytes.
`md` | This type of device uses a dual allocation in the style of a Sun StorEdge SAM-FS file system. The DAU can be configured to be 16, 32, or 64 kilobytes in length. The default DAU for an `md` device in a Sun StorEdge QFS environment is 64 kilobytes. An `md` device in a Sun StorEdge QFS file system is used to store data only, not metadata. This is the difference between an `md` device in a Sun StorEdge QFS file system and an `md` device in a Sun StorEdge SAM-FS file system.

Note - If you did not perform a `sammkfs`(1M) on your file system when the Sun StorEdge QFS software was installed, you are using a version 1 superblock. In the version 1 superblock, the `mm` devices do not use the dual allocation scheme. In the version 1 superblock, the allocation for `mm` devices is 16 kilobytes. Only a version 2 superblock enables you to define `md` devices in a Sun StorEdge QFS file system.

The DAU setting is specified using the `-a` allocation_unit option to the `sammkfs`(1M) command. The following command specifies a DAU of 128 kilobytes:

    # sammkfs -a 128 samqfs1

For more information about the `sammkfs`(1M) command, see the `sammkfs`(1M) man page.

#### Allocation Scheme Summary

TABLE 2-7 shows the Equipment Types that can be used in Sun StorEdge QFS and Sun StorEdge SAM-FS file systems.

TABLE 2-7 Equipment Types for File System Devices
Equipment Types in `mcf` File | Type of Data Stored | Allocation Scheme | File Systems That Can Include the Equipment Type
--- | --- | --- | ---
`md` | File data and metadata | Dual | Sun StorEdge SAM-FS
`md` | File data | Dual | Sun StorEdge QFS
`mm` | Metadata | Dual | Sun StorEdge QFS
`mr` | File data | Single | Sun StorEdge QFS
`g` XXX | File data | Single | Sun StorEdge QFS

Within a Sun StorEdge SAM-FS file system (an `ms` file system), you can have only `md` devices.

Within a Sun StorEdge QFS file system (an `ma` file system), you can mix devices as follows:

- `mm` and `mr` devices

- `mm` and `g` XXX devices

- `mm`, `mr`, and `g` XXX devices

- `mm` and `md` devices

TABLE 2-8 summarizes the allocation schemes used by the various file systems.

TABLE 2-8 File Allocation
File System and Device Type | Allocation Increments
--- | ---
Sun StorEdge SAM-FS with `md` devices | Up to eight 4-kilobyte blocks, then DAUs
Sun StorEdge QFS with `mr` devices | DAUs
Sun StorEdge QFS with `g` X devices | DAUs
Sun StorEdge QFS with `md` devices | Up to eight 4-kilobyte blocks, then DAUs

TABLE 2-9 summarizes the DAU defaults.

TABLE 2-9 Default DAU Sizes
File System and Device Types | Default DAU Size
--- | ---
Sun StorEdge SAM-FS `md` devices | 16 kilobytes
Sun StorEdge QFS `mr` and `md` devices | 64 kilobytes
Sun StorEdge QFS `g` X devices | 256 kilobytes

### Stripe Widths on Data Disks

Stripe width defaults differ between Sun StorEdge QFS and Sun StorEdge SAM-FS file systems. The stripe width is specified by the`-o stripe=`n`` option on the`mount`(1M) command. If the stripe width is set to 0, round-robin allocation is used.

The following sections explain the differences that affect stripe widths on the various file systems.

#### Sun StorEdge SAM-FS Stripe Widths

On Sun StorEdge SAM-FS file systems, the stripe width is set at mount time. TABLE 2-10 shows default stripe widths.

TABLE 2-10 Sun StorEdge SAM-FS Default Stripe Widths
DAU | Default Stripe Width | Amount of Data Written to 1 Disk
--- | --- | ---
16 kilobytes (default) | 8 DAUs | 128 kilobytes
32 kilobytes | 4 DAUs | 128 kilobytes
64 kilobytes | 2 DAUs | 128 kilobytes

For example, if`sammkfs`(1M) is run with default settings, the default large DAU is 16 kilobytes. If no stripe width is specified when the `mount`(1M) command is issued, the default is used, and the stripe width set at mount time is 8.

Note that if you multiply the number in the first column of TABLE 2-10 by the number in the second column, the resulting number is 128 kilobytes. The Sun StorEdge QFS and Sun StorEdge SAM-FS file systems operate more efficiently if the amount of data being written to disk is at least 128 kilobytes.

#### Sun StorEdge QFS Stripe Widths - Not Using Striped Groups

On Sun StorEdge QFS file systems, the stripe width that is set at mount time depends on whether or not striped groups are configured. A striped group is a collection of devices that are striped as a group. For more information about striped groups, see File Allocation Methods. This section describes stripe widths for Sun StorEdge QFS file systems that are configured without stripe groups.

If striped groups are not configured, the DAU and stripe width relationships are similar to those for Sun StorEdge SAM-FS file systems. The differences being that DAUs larger than 64 kilobytes or greater are possible and that the DAU is configurable in 8-kilobyte blocks. The maximum DAU size is 65528 kilobytes.

By default, if no stripe width is specified, the amount of data written to disk is at or near 128 kilobytes. The Sun StorEdge QFS file systems are more efficient if write operations write at least one whole stripe per I/O request. TABLE 2-11 shows the default stripe widths. These are the widths used if you do not specify a stripe width.

TABLE 2-11 Default Stripe Widths
DAU | Default Stripe Width | Amount of Data Written to 1 Disk
--- | --- | ---
16 kilobytes | 8 DAUs | 128 kilobytes
24 kilobytes | 5 DAUs | 120 kilobytes
32 kilobytes | 4 DAUs | 128 kilobytes
40 kilobytes | 3 DAUs | 120 kilobytes
48 kilobytes | 2 DAUs | 96 kilobytes
56 kilobytes | 2 DAUs | 112 kilobytes
64 kilobytes (default) | 2 DAUs | 128 kilobytes
72 kilobytes | 1 DAU | 72 kilobytes
128 kilobytes | 1 DAU | 128 kilobytes
> 128 kilobytes | 1 DAU | DAU size

#### Sun StorEdge QFS Stripe Widths - Using Striped Groups

If striped groups are configured for your Sun StorEdge QFS file system, the minimum amount of space allocated is the DAU multiplied by the number of devices in the striped group. The amount of the allocation can be very large when using striped groups.

When striped groups are used, data is written to several disk devices at once. This allocation treats a group of disks as if they were one device. Allocations on striped groups are logically equal to the DAU size multiplied by the number of elements in the striped group.

The `-o stripe=`n mount option determines the number of allocations that occur on each stripe group before the allocation moves to a different striped group. If a file system is mounted with `-o stripe=0`, the allocation is always to one striped group.

By default, the setting is `-o stripe=0`, which is round robin. The setting can be as low as `-o stripe=0` (which disables striping) or as high as `-o stripe=255`. The system sets `-o stripe=0` if mismatched striped groups are present. When mismatched striped groups are present, a file can reside on only one stripe group.

#### Sun StorEdge QFS Data Alignment

Data alignment refers to matching the allocation unit of the RAID controller with the allocation unit of the file system. The optimal Sun StorEdge QFS file system alignment formula is as follows:

    allocation_unit = RAID_stripe_width x number_of_data_disks_in_the_RAID

For example, if a RAID-5 unit has a total of nine disks, with one of the nine being the parity disk, the number of data disks is eight. If the RAID stripe width is 64 kilobytes, then the optimal allocation unit is 64 multiplied by 8, which is 512 kilobytes.

Data files are striped or round-robin through each striped group (`g` XXX) or data disk (`mr` or `md`) defined within the same file system.

A mismatched alignment hurts performance because it can cause a read-modify-write operation. The rest of this chapter provides more information for you to consider when setting DAUs and determining stripe widths.

#### Stripe Widths on Metadata Disks

You can use the`-o mm_stripe=`n`` option to the`mount_samfs`(1M) command to stripe metadata information about the metadata disk. The default stripe width is`-o mm_stripe=1`, which specifies that one 16-kilobyte DAU be written to a metadata disk before switching to the next metadata disk. The small 4-kilobyte DAU is used for metadata disks.

By default, if you have multiple metadata devices, metadata is allocated using striped or round-robin allocation depending what is specified on the -`o mm_stripe=`n option to the `mount`(1M) command. The setting can be as low as `-o mm_stripe=0`, which disables striping. It can also be as high as `-o mm_stripe=255`.

##

File Allocation Methods

The Sun StorEdge QFS and Sun StorEdge SAM-FS file systems enable you to specify both round-robin and striped allocation methods. TABLE 2-12 shows the default file allocation methods used.

TABLE 2-12 Default Allocation Methods
File System | Metadata | File Data
--- | --- | ---
Sun StorEdge SAM-FS | Striped | Striped
Sun StorEdge QFS | Striped | Striped
Sun StorEdge QFS (striped groups) | Striped | Round-robin
Sun StorEdge QFS shared file system | Striped | Round-robin

The following sections describe allocation in more detail.

### Metadata Allocation

Metadata allocation differs depending on the type of file system you have.

- For Sun StorEdge SAM-FS file systems, metadata is allocated across the `md` devices.

- For Sun StorEdge QFS file systems, metadata is allocated across the `mm` devices.

No file data is allocated on the `mm` devices in Sun StorEdge QFS file systems.

Inodes are 512 bytes in length. Directories are initially 4 kilobytes in length. TABLE 2-13 shows how the system allocates metadata.

TABLE 2-13 Metadata Allocation
Metadata Type | Allocation Increments for Sun StorEdge QFS File Systems | Allocation Increments for Sun StorEdge SAM-FS File Systems
--- | --- | ---
Inodes (`.inodes` file) | 16-kilobyte DAU | 16, 32, or 64-kilobyte (DAU)
Indirect blocks | 16-kilobyte DAU | 16, 32, or 64-kilobyte (DAU)
Directories | 4-kilobyte blocks and 16-kilobyte DAUs | 4 kilobytes, up to a 32-kilobyte total, then DAU size

### Round-Robin Allocation

The round-robin allocation method writes one data file at a time to each successive device in the family set. Round-robin allocation is useful for multiple data streams because aggregate performance can exceed striping performance in this type of environment.

Round-robin disk allocation enables a single file to be written to a logical disk. The next file is written to the next logical disk. When the number of files written equals the number of devices defined in the family set, the file system starts over again with the first devices selected. If a file exceeds the size of the physical device, the first portion of the file is written to the first device, and the remainder of the file is written to the next device with available storage.

The size of the file being written determines the I/O size. You can specify round-robin allocation explicitly in the `/etc/vfstab` file by entering `stripe=0`.

The following figures depict round-robin allocations. In these figures, file 1 is written to disk 1, file 2 is written to disk 2, file 3 is written to disk 3, and so on. When file 6 is created, it is written to disk 1, starting the round-robin allocation scheme over again.

FIGURE 2-1 depicts a Sun StorEdge SAM-FS file system using round-robin allocation on five devices. FIGURE 2-2 depicts a Sun StorEdge QFS file system using round-robin allocation on five devices.

FIGURE 2-1 Round-Robin Sun StorEdge SAM-FS File System Using Five Devices
[ D ]

.

FIGURE 2-2 Round-Robin Sun StorEdge QFS File System Using Five Devices

### Striped Allocation

By default, Sun StorEdge QFS and Sun StorEdge SAM-FS file systems use a striped allocation method to spread data over all the devices in the file system family set. Striping is a method of writing files in an interlaced fashion across multiple devices concurrently.

Striping is used when performance for one file requires the additive performance of all the devices. A file system that is using striped devices addresses blocks in an interlaced fashion rather than sequentially. Striping generally increases performance because disk reads and writes are spread concurrently across disk heads. Striped disk access enables multiple I/O streams to simultaneously write a file across multiple disks. The DAU and the stripe width determine the size of the I/O transmission.

In a file system using striping, file 1 is written to disk 1, disk 2, disk 3, disk 4, and disk 5. File 2 is written to disks 1 through 5 as well. The DAU multiplied by the stripe width determines the amount of data written to each disk in a block.

When a Sun StorEdge QFS or Sun StorEdge SAM-FS file system starts to write a file to an`md` device, it first assumes that the file will fit into a small DAU, which is 4 kilobytes. If the file does not fit into the first eight small DAUs (32 kilobytes) allocated, the file system writes the remainder of the file into one or more large DAUs.

When a Sun StorEdge QFS file system starts to write a file to an`mr` device, it writes first to one DAU, then another, and so on. The`mr` devices have only one DAU size. A Sun StorEdge QFS file system can also write metadata to striped`mm` devices.

Multiple active files cause significantly more disk head movement if striped allocation is used. If I/O is to occur to multiple files simultaneously, use round-robin allocation.

The following figures depict file systems using striped allocations. In these figures, DAU x stripe_width bytes of the file are written to disk 1. DAU x stripe_width bytes of the file are written to disk 2. DAU x stripe_width bytes of the file are written to disk 3, and so on. The order of the stripe is first-in-first-out for the files. Striping spreads the I/O load over all the disks.

FIGURE 2-3 depicts a Sun StorEdge SAM-FS file system using five striped devices. FIGURE 2-4 depicts a Sun StorEdge QFS file system using five striped devices.

FIGURE 2-3 Sun StorEdge SAM-FS File System Using Five Striped Devices

FIGURE 2-4 Sun StorEdge QFS File System Using Five Striped Devices
[ D ]

### Striped Groups (Sun StorEdge QFS File Systems Only)

A striped group is a special Sun StorEdge QFS allocation method designed for file systems that have extremely large I/O requirements and terabytes of disk cache. A striped group enables you to designate an Equipment Type that contains multiple physical disks. Multiple striped group Equipment Types can make up a single Sun StorEdge QFS file system. Striped groups save bit map space and system update time for very large RAID configurations.

A striped group is a collection of devices within a Sun StorEdge QFS file system. Striped groups must be defined in the`mcf` file as`g` XXX`` devices. Striped groups enable one file to be written to and read from two or more devices. You can specify up to 128 striped groups within a file system.

FIGURE 2-5 depicts a Sun StorEdge QFS file system using striped groups and a round-robin allocation. In FIGURE 2-5, files written to the`qfs1` file system are round-robin between groups `g0`, `g1`, and `g2`. Three striped groups are defined (`g0`, `g1`, and `g2`). Each group consists of two physical RAID devices.

FIGURE 2-5 Sun StorEdge QFS Round-Robin Striped Groups
[ D ]

For the configuration in FIGURE 2-5, the mount point option in`/etc/vfstab` is set to`stripe=0`. CODE EXAMPLE 2-2 shows the `mcf` file that declares these striped groups.

CODE EXAMPLE 2-2 Example `mcf` File Showing Striped Groups
    # Equipment        Eq   Eq    Fam   Dev    Additional
    # Identifier       Ord  Type  Set   State  Parameters
    #
    qfs1               10   ma    qfs1
    /dev/dsk/c0t1d0s6  11   mm    qfs1  -
    /dev/dsk/c1t1d0s2  12   g0    qfs1  -
    /dev/dsk/c2t1d0s2  13   g0    qfs1  -
    /dev/dsk/c3t1d0s2  14   g1    qfs1  -
    /dev/dsk/c4t1d0s2  15   g1    qfs1  -
    /dev/dsk/c5t1d0s2  16   g2    qfs1  -
    /dev/dsk/c6t1d0s2  17   g2    qfs1  -

FIGURE 2-6 depicts a Sun StorEdge QFS file system using striped groups in which the data is striped across groups. In FIGURE 2-6, files written to the`qfs1` file system are striped through groups `g0`, `g1`, and `g2`. Each group includes four physical RAID devices. The mount point option in`/etc/vfstab` is set to`stripe=1` or greater.

FIGURE 2-6 Sun StorEdge QFS Striped Group Allocation
[ D ]

### Mismatched Striped Groups (Sun StorEdge QFS File Systems Only)

It is possible to build a file system with mismatched striped groups. File systems with mismatched striped groups are those that contain multiple striped groups with different numbers of devices in each group. Sun StorEdge QFS file systems support mismatched striped groups, but they do not support striping on mismatched groups. File systems with mismatched striped groups are mounted as round-robin file systems.

Note - If a file system contains mismatched striped groups, a single file can never span more than one stripe group. If the stripe group on which the file resides fills, it cannot be extended. If mismatched stripe groups are present, use the `setfa`(1) command's `-g` option to direct files into the desired group. For more information, see the `setfa`(1) man page. To determine how full a stripe group is, use the `samu`(1M) operator utility, and access the `m` display to display the status of mass storage.

The following example shows how a file system can be set up to store different types of files.

#### Example

Assume that you have a Sun StorEdge QFS license, and you need to create a file system at your site that contains both video and audio data.

Video files are quite large and require greater performance than audio files. You want to store them in a file system with a large striped group because striped groups maximize performance for very large files.

Audio files are smaller and require lower performance than video files. You want to store them in a small striped group. One file system can support both video and audio files.

FIGURE 2-7 depicts the file system needed. It is a Sun StorEdge QFS file system using mismatched striped groups in a striped allocation.

FIGURE 2-7 Sun StorEdge QFS File System Using Mismatched Striped Groups in a Striped Allocation
[ D ]

TABLE 2-14 shows the characteristics of this file system.

TABLE 2-14 File System `avfs` Characteristics
Characteristics | Notes
--- | ---
File system name | `avfs.`
Number of stripe groups | Two. The video file group is `g0`. The audio file group is `g1`.
Stripe width | 0.
DAU | 128 kilobytes.
Number of disks for `g0` | Eight.
Minimum block size for `g0` | Eight disks x 128-kilobyte DAU = 1024 kilobytes. This is the amount of data written in one block write. Each disk receives 128 kilobytes of data, so the total amount written to all disks at one time is 1024 kilobytes.
Number of disks for `g1` | One.
Minimum block size for `g1` | One disk x 128-kilobyte DAU = 128 kilobytes.

Add the following line to the `/etc/vfstab` file so the environment recognizes the`avfs` file system:

    avfs    -    /avfs    samfs    -    no    stripe=0

Note that in the`/etc/vfstab` file,`stripe=0` is used to specify a round-robin file system. This is used because a value greater than 0 (stripe > 0) is not supported for mismatched striped groups.

CODE EXAMPLE 2-3 shows the `mcf` file for file system `avfs`.

CODE EXAMPLE 2-3 The `mcf` File for File System `avfs`
    # Equipment         Eq   Eq    Fam  Dev    Additional
    # Identifier        Ord  Type  Set  State  Parameters
    #
    avfs                100  ma    avfs
    /dev/dsk/c00t1d0s6  101  mm    avfs  -
    #
    /dev/dsk/c01t0d0s6  102  g0    avfs  -
    /dev/dsk/c02t0d0s6  103  g0    avfs  -
    /dev/dsk/c03t0d0s6  104  g0    avfs  -
    /dev/dsk/c04t0d0s6  105  g0    avfs  -
    /dev/dsk/c05t0d0s6  106  g0    avfs  -
    /dev/dsk/c06t0d0s6  107  g0    avfs  -
    /dev/dsk/c07t0d0s6  108  g0    avfs  -
    /dev/dsk/c08t0d0s6  109  g0    avfs  -
    #
    /dev/dsk/c09t1d0s6  110  g1    avfs  -

After the`mcf` file for this file system is ready, you can enter the `sammkfs`(1M) and`mount`(1M) commands shown in CODE EXAMPLE 2-4 to create and mount the`avfs` file system.

CODE EXAMPLE 2-4 Commands to Create and Mount File System `avfs`
    # sammkfs -a 128 avfs
    # mount avfs

After the file system is mounted, you can use the commands shown in CODE EXAMPLE 2-5 to create two directories for the two types of files.

CODE EXAMPLE 2-5 Commands to Create Directories in File System `avfs`
    # cd /avfs
    # mkdir video
    # mkdir audio

After the directories are created, you can use the `setfa`(1) commands shown in CODE EXAMPLE 2-6 to assign the large striped group to video and to assign the small striped group to audio. Files created in these directories are allocated on their respective striped groups because attributes are inherited.

CODE EXAMPLE 2-6 Commands to Set File Attributes
    # setfa -g0 video
    # setfa -g1 audio

For more information about the`sammkfs`(1M) command, see the`sammkfs`(1M) man page. For more information about the`mount`(1M) commands, see the`mount_samfs`(1M) man page. For more information about the`setfa`(1) command, see the`setfa`(1) man page.

Copyright © 2004, Sun Microsystems, Inc. All rights reserved.