C H A P T E R 5

Advanced Topics

This chapter discusses advanced topics that are beyond the scope of basic system administration and usage. This chapter contains the following sections:

- Using Daemons, Processes, and Tracing

- Using the setfa(1) Command to Set File Attributes

- Configuring WORM-FS File Systems

- Accommodating Large Files

- Understanding I/O Types

- Increasing File Transfer Performance for Large Files

- Enabling Qwrite Capability

- Setting the Write Throttle

- Setting the Flush-Behind Rate

- Tuning the Number of Inodes and the Inode Hash Table

##

Using Daemons, Processes, and Tracing

It is useful to have an understanding of system daemons and processes when you are debugging. This section describes the Sun StorEdge SAM-FS daemons and processes. It also provides information about daemon tracing.

### Daemons and Processes

All Sun StorEdge SAM-FS daemons are named in the form `sam-`daemon_name `d`. Processes are named in a similar manner; the difference is that they do not end in the lowercase letter `d`.

TABLE 5-1 shows some of the daemons and processes that can run on your system. Others, such as `sam-genericd` and `sam-catserverd`, might also be running, depending on system activities.

TABLE 5-1 Daemons and Processes
Process | Description
--- | ---
sam-amld | Initializes the Sun StorEdge SAM-FS automated library daemons: `sam-catserverd`, `sam-scannerd`, and `sam-robotsd`.
`sam-archiverd` | Automatically archives Sun StorEdge SAM-FS files. This process runs as long as the Sun StorEdge SAM-FS file system is mounted.
sam-catserverd | Keeps track of media in Sun StorEdge SAM-FS and SAM-QFS library catalogs.
`sam-fsd` | Master daemon.
`sam-rftd` | Transfers data between multiple Sun StorEdge SAM-FS host systems.
`sam-robotsd` | Starts and monitors automated library media changer control daemons.
`sam-scannerd` | Monitors all manually mounted removable media devices. The scanner periodically checks each device for inserted archive media cartridges.
`sam-releaser` | Attempts to release disk space occupied by previously archived files on Sun StorEdge SAM-FS file systems until a low water mark is reached. The releaser is started automatically when a high water mark is reached on disk cache and stops when it has finished releasing files. This is a process, not a daemon.
`sam-stagealld` | Controls the associative staging of Sun StorEdge SAM-FS files.
`sam-stagerd` | Controls the staging of Sun StorEdge SAM-FS files.
`sam-rpcd` | Controls the remote procedure call (RPC) application programming interface (API) server process.
sam-robotsd | Starts and monitors the execution of the media changer library control daemons for Sun StorEdge SAM-FS.

When you run Sun StorEdge SAM-FS software, `init` starts the `sam-fsd` daemon as part of `/etc/inittab` processing. The daemon is started at `init` levels 0, 2, 3, 4, 5, and 6. It should restart automatically in case of failure.

In a Sun StorEdge QFS shared file system, a `sam-fsd` daemon is always active. In addition, one `sam-sharefsd` daemon is active for each mounted shared file system.

When a `sam-fsd` daemon recognizes a Sun StorEdge QFS shared file system, it starts a shared file system daemon (`sam-sharefsd`). TCP sockets are used to communicate between the server and client hosts. All clients that connect to the metadata server are validated against the hosts file.

Note - See the hosts.fs man page for more information about the hosts file.

The `sam-sharedfsd` daemon on the metadata server opens a listener socket on the port named `sam-qfs`. During the Sun StorEdge QFS installation process, the `sam-qfs` entry is automatically added to `/etc/services` file. Do not remove this entry. In addition, the shared file system port is defined in the `/etc/inet/services` file as port number 7105. Verify that this port does not conflict with another service.

Note - Before the Sun StorEdge QFS 4U2 release, one port per file system was required. You can remove these entries from your file.

All metadata operations, block allocation and deallocation, and record locking are performed on the metadata server. The `sam-sharefsd` daemon does not keep any information. Hence, it can be stopped and restarted without causing any consistency problems for the file system.

When running Sun StorEdge SAM-FS software, the `sam-fsd` daemon creates the following processes:

- `sam-archiverd`. The `sam-archiverd` daemon starts the `sam-arcopy` and the `sam-arfind` processes.

- `sam-stagealld`.

- `sam-stagerd`.

- `sam-rftd`.

- `sam-amld`. Issuing a `samd`(1M) `stop` command stops this daemon.
  `sam-amld` starts the following child daemons:

- `sam-robotsd`. Issuing a `samd`(1M) `stop` command stops this daemon.

- `sam-scannerd`. Issuing a `samd`(1M) `stop` command stops this daemon.

- `sam-catserverd`. Issuing a `samd`(1M) `stop` command stops this daemon.

### Trace Files

Several Sun StorEdge SAM-FS processes can write messages to trace files. These messages contain information about the state and progress of the work performed by the daemons. The messages are primarily used by Sun Microsystems staff members to improve performance and diagnose problems. The message content and format are subject to change from release to release.

Trace files can be used in debugging. By default, trace files are not enabled. You can enable trace files by editing the `defaults.conf` file. You can enable tracing for all processes, or you can enable tracing for individual processes. For information about the processes that you can trace, see the `defaults.conf`(4) man page.

By default, trace files are written to the `/var/opt/SUNWsamfs/trace` directory. In that directory, the trace files are named for the processes (`archiver`, `catserver`, `fsd`, `ftpd`, `recycler`, `sharefsd`, and `stager`). You can change the names of the trace files by specifying directives in the `defaults.conf` configuration file. You can also set a limit on the size of a trace file and rotate your tracing logs. For information about controlling tracing, see the `defaults.conf`(4) man page.

#### Trace File Content

Trace file messages contain the time and source of the message. The messages are produced by events in the processes. You can select the events by using directives in the `defaults.conf` file.

The default events are as follows:

- Customer notification `syslog` or `notify` file messages

- Nonfatal program errors

- Fatal `syslog` messages

- Process initiation and completion

- Other miscellaneous events

You can also trace the following events:

- Memory allocations

- Interprocess communication

- File actions

- Operator messages

- Queue contents when changed

- Other miscellaneous events

The default message elements (program name, process id (PID), and time) are always included and cannot be excluded. Optionally, the messages can also contain the following elements:

- The date (The time is always included.)

- The source file name and line number

- The event type

#### Trace File Rotation

To prevent trace files from growing indefinitely, the `sam-fsd` daemon monitors the size of the trace files and periodically executes the following command:

    /opt/SUNWsamfs/sbin/trace_rotate

This script moves the trace files to sequentially numbered copies. You can modify this script to suit your operation. Alternatively, you can provide this function using `cron`(1) or some other facility.

#### Determining Which Processes Are Being Traced

To determine which processes are being traced currently, enter the `sam-fsd`(1M) command at the command line. CODE EXAMPLE 5-1 shows the output from this command.

CODE EXAMPLE 5-1 `sam-fsd` (1M) Command Output
    # sam-fsd
    Trace file controls:
    sam-amld      /var/opt/SUNWsamfs/trace/sam-amld
                  cust err fatal misc proc date
                  size    0    age 0
    sam-archiverd /var/opt/SUNWsamfs/trace/sam-archiverd
                  cust err fatal misc proc date
                  size    0    age 0
    sam-catserverd /var/opt/SUNWsamfs/trace/sam-catserverd
                  cust err fatal misc proc date
                  size    0    age 0
    sam-fsd       /var/opt/SUNWsamfs/trace/sam-fsd
                  cust err fatal misc proc date
                  size    0    age 0
    sam-rftd      /var/opt/SUNWsamfs/trace/sam-rftd
                  cust err fatal misc proc date
                  size    0    age 0
    sam-recycler  /var/opt/SUNWsamfs/trace/sam-recycler
                  cust err fatal misc proc date
                  size    0    age 0
    sam-sharefsd  /var/opt/SUNWsamfs/trace/sam-sharefsd
                  cust err fatal misc proc date
                  size    0    age 0
    sam-stagerd   /var/opt/SUNWsamfs/trace/sam-stagerd
                  cust err fatal misc proc date
                  size    0    age 0
    sam-serverd   /var/opt/SUNWsamfs/trace/sam-serverd
                  cust err fatal misc proc date
                  size    0    age 0
    sam-clientd   /var/opt/SUNWsamfs/trace/sam-clientd
                  cust err fatal misc proc date
                  size    0    age 0
    sam-mgmt      /var/opt/SUNWsamfs/trace/sam-mgmt
                  cust err fatal misc proc date
                  size    0    age 0

For more information about enabling trace files, see the `defaults.conf`(4) man page and the `sam-fsd`(1M) man page.

##

Using the`setfa`(1) Command to Set File Attributes

Sun StorEdge SAM-FS file systems enable end users to set performance attributes for files and directories. Applications can enable these performance features on a per-file or per-directory basis. The following sections describe how the application programmer can use these features to select file attributes for files and directories, to preallocate file space, to specify the allocation method for the file, and to specify the disk stripe width.

For more information about implementing the features described in the following subsections, see the `setfa`(1) man page.

### Selecting File Attributes for Files and Directories

The `setfa`(1) command sets attributes on a new or existing file. The file is created if it does not already exist.

You can set attributes on a directory as well as a file. When using `setfa`(1) with a directory, files and directories created within that directory inherit the attributes set in the original directory. To reset attributes on a file or directory to the default, use the `-d` (default) option. When the `-d` option is used, first attributes are reset to the default and then other attributes are processed.

### Preallocating File Space

An end user can preallocate space for a file. This space is associated with a file so that no other files in the file system can use the disk addresses allocated to this file. Preallocation ensures that space is available for a given file, which avoids a file-system-full condition. Preallocation is assigned at the time of the request rather than when the data is actually written to disk.

Note that space can be wasted by preallocation of files. If the file size is less than the allocation amount, the kernel allocates space to the file from the current file size up to the allocation amount. When the file is closed, space below the allocation amount is not freed.

You can preallocate space for a file by using the `setfa`(1) command with either the `-L` or the `-l` (lowercase letter L) option. Both options accept a file length as their argument. Use the `-L` option for an existing file, which can be empty or contain data. Use the `-l` option for a file that has no data yet. If you use the `-l` option, the file cannot grow beyond its preallocated limit.

For example, to preallocate a 1-gigabyte file named `/qfs/file_alloc`, type the following:

    # setfa -l 1g /qfs/file_alloc

After space for a file has been preallocated, truncating a file to 0 length or removing the file returns all space allocated for a file. There is no way to return only part of a file's preallocated space to the file system. In addition, if a file is preallocated in this manner, there is no way to extend the file beyond its preallocated size in future operations.

### Selecting a File Allocation Method and Stripe Width

By default, a file uses the allocation method and stripe width specified at mount time (see the `mount_samfs`(1M) man page). However, an end user might want to use a different allocation scheme for a file or directory. The user could do this by using the `setfa`(1) command with the `-s` (stripe) option.

The allocation method can be either round-robin or striped. The `-s` option specifies the allocation method and the stripe width, as shown in TABLE 5-2.

TABLE 5-2 File Allocations and Stripe Widths
`-s` Option | Allocation Method | Stripe Width | Explanation
--- | --- | --- | ---
0 | Round-robin | Not applicable | The file is allocated on one device until that device has no space.
1-255 | Striped | 1-255 DAUs | The file is striped across all disk devices with this number of DAUs per disk.

The following example shows how to create a file explicitly by specifying a round-robin allocation method:

    # setfa -s 0 /qfs/100MB.rrobin

The following example shows how to create a file explicitly by specifying a striped allocation method with a stripe width of 64 DAUs (preallocation is not used):

    # setfa -s 64 /qfs/file.stripe

##

Configuring WORM-FS File Systems

Write Once Read Many (WORM) technology is used in many applications because of the integrity of the data and the accepted legal admissibility of stored files that use the technology. Beginning with release 4, update 3, of the Sun StorEdge SAM-FS software, a WORM-FS feature became available as an add-on package called `SUNWsamfswm`. In the 4U4 software release the WORM-FS interface was modified to be compatible with the new Sun StorEdge 5310 NAS appliance. The previous WORM-FS interface using `ssum` is no longer supported.

Note - The WORM-FS feature is licensed separately from the Sun StorEdge SAM-FS file system. Contact your local Sun sales representative for information about obtaining the WORM-FS package.

The WORM-FS feature offers default and customizable file-retention periods, data and path immutability, and subdirectory inheritance of the WORM setting.

### Enabling the WORM-FS Feature

Use the `worm_capable` mount option to enable the WORM-FS feature. This option can be provided on the command line when the file system is mounted, or listed in `/etc/vfstab` or in `/opt/SUNWsamfs/famfs.cmd`. The rules of precedence for mount options applies.

The `worm_capable` attribute is stored in the mount table and enables WORM files to be created in directories anywhere in the file system.

Note - You must have system administration privileges to set the `worm_capable` mount option in `/etc/vfstab`.

CODE EXAMPLE 5-2 shows the two WORM-FS mount options. The file system `samfs1` mounted at `/samfs1` is WORM-capable and has the default retention period for files set to 60 minutes.

CODE EXAMPLE 5-2 Using WORM-FS Mount Options
    # cat /etc/vfstab#device 	device 	mount 	FS 	fsck	mount	mount#to mount 	to fsck 	point	type	pass	at boot	options#fd 	-	/dev/fd	fd	-	no	-/proc	-	/proc	proc	-	no	-/dev/dsk/c0t0d0s1	- 	-	swap	-	no	-samfs1 	-	/samfs1	samfs	-	yes 	worm_capable,def_retention=60swap	-	/tmp	tmpfs	-	yes	-

After the WORM-FS feature has been enabled and at least one WORM file is resident in the file system, the file system's superblock is updated to reflect the WORM capability. Any subsequent attempt to rebuild the file system through `sammkfs` will fail.

The `worm_capable` mount option enables a file system to contain WORM files, but it does not automatically create WORM files. To create a WORM file, you must first make the directory WORM-capable. To do this, create an ordinary directory and then use the WORM trigger command `chmod 4000` directory-name to set the WORM bit on the directory. The directory can now contain WORM files.

After setting the WORM bit on a parent directory, you can create files in that directory and then use the WORM trigger `chmod 4000` file-name to set the WORM bit on files that you want to be retained.

Note - Use care when applying the WORM trigger. The file data and path cannot be changed after the file has the WORM feature applied. Once this feature is applied to a file, it is irrevocable.

The WORM-FS feature also includes file-retention periods that can be customized. Assigning a retention period to a file maintains the WORM features in that file for the specified period of time. Do one of the following to set a retention period for a file:

- Advance the file's access time using the `touch` utility, or with a program using the `libc` subroutine `utimes()`. With these methods, the file's retention period is stored in minutes. (After the access time is advanced, the `chmod 4000` command is used to set the WORM trigger.)

- Use the default retention period for a file. See Setting the Default Retention Period for more information.

CODE EXAMPLE 5-3 shows the creation of a file in a WORM-capable directory, setting of the WORM trigger on the file, and use of the `sls` command to display the file's WORM features. This example uses the default retention period of the file system (60 minutes, as set in CODE EXAMPLE 5-2).

CODE EXAMPLE 5-3 Creation of a WORM-Capable Directory and WORM File
    # cd WORM# echo "This is a test file" >> test# sls -Dtest:	mode: -rw-r--r--  links: 1  owner: root group: other	length: 20  admin id: 0  inode: 1027.1	access: Oct 30 02:50  modification: Oct 30 02:50	changed: Oct 30 02:50  attributes: Oct 30 02:50	creation: Oct 30 02:50  residence: Oct 30 02:50	checksum: gen  no_use  not_val  algo: 0
    # chmod 4000 test# sls -Dtest:	mode: -r--r--r--  links: 1  owner: root group: other	length: 20  admin id: 0  inode: 1027.1	access: Oct 30 02:50  modification: Oct 30 02:50	changed: Oct 30 02:50  retention-end: Oct 30 2005 03:50	creation: Oct 30 02:50  residence: Oct 30 02:50	retention: active retention-period: 0y, 0d, 1h, 0m	checksum: gen  no_use  not_val  algo: 0

With the addition of the WORM-FS feature, three states are possible for a file in a Sun StorEdge SAM-FS file system:

- Normal

- Retained

- Expired

The normal state represents the state of an ordinary file in a Sun StorEdge SAM-FS file system. A transition to the retained, or active, state occurs when the WORM bit is set on a file. The expired, or over, state occurs when the file's retention period is exceeded.

When a retention period is assigned to a file and the WORM trigger is applied to it, the file's path and data are immutable. When the retention period expires, the state is changed to "expired" but the path and data remain immutable.

When a file is in an expired state, only two operations are available:

- Extension of the retention period (The retention period can never be shortened.)

- Deletion of the file

If the retention period is extended, the file's state returns to "active" and the new end date and duration are set accordingly.

Both hard and soft links to files can be used with the WORM-FS feature. Hard links can be established only with files that reside in a WORM-capable directory. After a hard link is created, it has the same WORM characteristics as the original file. Soft links can also be established, but a soft link cannot use the WORM features. Soft links to WORM files can be created in any directory in a Sun StorEdge SAM-FS file system.

Another attribute of the WORM-FS feature is directory inheritance. New directories that are created under a directory that includes the `worm_capable` attribute inherit this attribute from their parent. If a directory has a default retention period set, this retention period is also inherited by any new subdirectories. The WORM bit can be set on any file whose parent directory is WORM-capable. Ordinary users can set the WORM feature on directories and files that they own or have access to by using normal UNIX permissions.

Note - A WORM-capable directory can only be deleted if it contains no WORM files.

#### Using the WORM-FS Feature in SAM-QFS Environments

In SAM-QFS environments, the releaser function could cause the data associated with a file to be stored on non-WORM media. To avoid this, one of the following methods should be used:

- Use the `-release` `-n` archive directive in the `archiver.cmd` file. The `-release` `-n` directive prevents the release of disk cache blocks. Alternatively, use the `release` command with the `-n` option on specific files or directories.

- Use WORM media (for example, VolSafe) as the archive destination.

For more information on the releaser feature in Sun StorEdge SAM-FS, see the `sam-releaser`(1M) man page or Chapter 4 of the Sun StorEdge SAM-FS Storage and Archive Management Guide.

Sun StorEdge SAM-FS also provides the `ssum` utility to assist with setting a checksum on a file. Checksums are not normally generated for a file unless this utility is used. The `ssum -g` option generates a checksum for a file when it is archived. The `ssum -u` option ensures that the checksum matches when the file is staged in. For more information, see the `ssum`(1) man page.

### Setting the Default Retention Period

The default retention period for a file system can be set as a mount option in the `/etc/vfstab` file. For example:

`samfs1 - /samfs1 samfs - no
bg,worm_capable,def_retention=1y60d`

The format for setting the default retention period is `MyNdOhPm`, in which `M`, `N`, `O`, and `P` are non-negative integers and `y`, `d`, `h`, and `m` stand for years, days, hours, and minutes, respectively. Any combination of these units can be used. For example, `1y5d4h3m` indicates 1 year, 5 days, 4 hours, and 3 minutes; `30d8h` indicates 30 days and 8 hours; and `300m` indicates 300 minutes. The new format is backward compatible with previous software versions, in which the retention period was specified in minutes.

You can also set a default retention period for a directory, as described in the following section, Setting the Retention Period Using touch. This retention period overrides the default retention period for the file system. It is also inherited by any subdirectories.

### Setting the Retention Period Using `touch`

You use the `touch` utility to set or extend a file's or directory's retention period. You can also use `touch` to shorten the default retention period for a directory (but not for a file).

To set the retention period, you must first advance the file's or directory's access time using `touch`, and then apply the WORM trigger using the `chmod` command.

CODE EXAMPLE 5-4 shows the use of the `touch` utility to set a file's retention period followed by the application of the WORM trigger.

CODE EXAMPLE 5-4 Using `touch` and `chmod` to Set the Retention Period
    # touch -a -t200508181125 test
    # sls -D
    test:
      mode: -rw-r--r--  links:   1  owner: root      group: root
      length:         0  admin id:      0  inode:     1027.1
      access:      Aug 18  2005  modification: Aug 18 11:19
      changed:     Aug 18 11:19  attributes:   Aug 18 11:19
      creation:    Aug 18 11:19  residence:    Aug 18 11:19
    # chmod 4000 test
    # sls -D
    test:
      mode: -r-Sr--r--  links:   1  owner: root      group: root
      length:         0  admin id:      0  inode:     1027.1
      access:      Aug 18  2005  modification: Aug 18 11:19
      changed:     Aug 18 11:19  retention-end: Aug 18 2005 11:25
      creation:    Aug 18 11:19  residence:    Aug 18 11:19
      retention:   active        retention-period: 0y, 0d, 0h, 6m

The `-a` option for `touch` is used to change the access time of the file or directory. The `-t` option specifies what time is to be used for the access time field. The format for the time argument is `[[CC]YY]MMDDhhmm[.SS]`, as follows:

- `[CC]` - The first two digits of the year.

- `[YY]` - The second two digits of the year.

- `MM` - The month of the year (01-12).

- `DD` - The day of the month (01-31).

- `hh` - The hour of the day (00-23).

- `mm` - The minute of the hour (00-59).

- `[SS]` - The second of the minute (00-61).

The `CC`, `YY`, and `SS` fields are optional. If `CC` and `YY` are not given, the default is the current year. See the `touch` manpage for more information on these options.

To set the retention period to permanent retention, set the access time to its largest possible value: `203801182214.07`.

#### Extending a File's Retention Period

CODE EXAMPLE 5-5 shows an example of using `touch` to extend a file's retention period.

CODE EXAMPLE 5-5 Using `touch` to Extend a File's Retention Period
    # sls -D test
    test:
      mode: -r-Sr--r--  links:   1  owner: root      group: root
      length:         0  admin id:      0  inode:     1029.1
      access:      Aug 18 11:35  modification: Aug 18 11:33
      changed:     Aug 18 11:33  retention-end: Aug 18 2005 11:35
      creation:    Aug 18 11:33  residence:    Aug 18 11:33
      retention:   over          retention-period: 0y, 0d, 0h, 2m
    # touch -a -t200508181159 test
    # sls -D
    test:
      mode: -r-Sr--r--  links:   1  owner: root      group: root
      length:         0  admin id:      0  inode:     1029.1
      access:      Aug 18 11:35  modification: Aug 18 11:33
      changed:     Aug 18 11:33  retention-end: Aug 18 2005 11:59
      creation:    Aug 18 11:33  residence:    Aug 18 11:33
      retention:   active        retention-period: 0y, 0d, 0h, 26m

In this example the retention period was extended to Aug 18, 2005 at 11:59AM, which is 26 minutes from the time the WORM trigger was initially applied.

### Using `sls` to View WORM-FS Files

Use the `sls` command to view WORM file attributes. The `-D` option shows whether a directory is WORM-capable. Use this option on a file to display when the retention period began, when it will end, the current retention state, and the duration as specified on the command line.

The start of the retention period is stored in the file's `changed` attribute field. The end of the retention period is stored in the file's `attribute time` field. This time is displayed as a calendar date. An additional line in the `sls` output shows the retention period state and duration.

CODE EXAMPLE 5-6 shows an example of how `sls -D` displays a file's retention status.

CODE EXAMPLE 5-6 Using `sls` to Find a File's Retention Status
    sls -D test
    test:	mode: -r-Sr--r--  links:   1  owner: root group: root	length: 5  admin id: 0  inode: 1027.1	access: Aug 18 2005 modification: Aug 18 11:19	changed: Aug 18 11:19 retention-end: Aug 18 2005 11:25	creation: Aug 18 11:19 residence: Aug 18 11:19	retention: active retention-period: 0y, 0d, 0h, 6m

In this example, the retention state is active, as shown by the `retention: active` designation, meaning that the file has the WORM bit set. The retention period started on August 18, 2005, at 11:19 and will end on August 18, 2005, at 11:25. The retention period was specified to be 0 years, 0 days, 0 hours, and 6 minutes.

### Using `sfind` to Find WORM-FS Files

Use the `sfind` utility to search for files that have certain retention periods. See the `sfind`(1) man page for more information on the options. The following options are available:

- `-ractive` - Finds files whose retention period is active.

- `-rover` - Finds files whose retention periods have expired.

- `-rafter` date - Finds files whose retention period will end after the specified date. The date is specified as `YYYYMMDDHHmm`, where `YYYY` is the year, `MM` is the month, `DD` is the day, `HH` is the hour, and `mm` is minutes.

For example, CODE EXAMPLE 5-7 shows the command to find files whose retention period expires after 12/24/2004 at 15:00.

CODE EXAMPLE 5-7 Using `sfind` to Find All WORM Files That Expire After a Certain Date
    # sfind -rafter 200412241500

- `-rremain` time - Finds files that have retention periods with at least the specified amount of time left. The time is specified as `MyNdOhPm`, where `M`, `N`, `O`, and `P` are arbitrary non-negative integers and `y`, `d`, `h`, and `m` represent the number of years, days, hours, and minutes, respectively.

For example, shows the command to find files for which more than 1 year, 10 days, 5 hours, and 10 minutes remain before expiration.

CODE EXAMPLE 5-8 Using `sfind` to Find All WORM Files With More Than a Specified Time Remaining
    # sfind -rremain 1y10d5h10m

- `-rlonger` time - Finds files that have retention periods longer than the specified amount of time. The time is specified as `MyNdOhPm`, where `M`, `N`, `O`, and `P` are arbitrary non-negative integers and `y`, `d`, `h`, and `m` represent the number of years, days, hours, and minutes, respectively.

For example, shows the command to find files that have retention periods longer than 10 days.

CODE EXAMPLE 5-9 Using `sfind` to Find All WORM Files With Longer Than a Specified Retention Period
    # sfind -rlonger 10d

- `-rpermanent` - Finds files whose retention period is permanent.

##

Accommodating Large Files

When manipulating very large files, pay careful attention to the size of disk cache that is available on the system. If you try to write a file that is larger than your disk cache, the program blocks, waiting for space that might never exist, because the available disk space is insufficient to handle the request.

If your application must write a file that is larger than the disk cache, you can segment the file with the `segment`(1) command. For more information about the `segment`(1) command, see the `segment`(1) man page or see the Sun StorEdge SAM-FS Storage and Archive Management Guide.

##

Understanding I/O Types

The Sun StorEdge SAM-FS file systems support paged I/O, direct I/O, and switching between the I/O types. The following sections describe these I/O types.

### Paged I/O

When paged I/O is used, user data is cached in virtual memory pages, and the kernel writes the data to disk. The standard Solaris OS interfaces manage paged I/O. Paged I/O (also called buffered or cached I/O) is selected by default.

### Direct I/O

Direct I/O is a process by which data is transferred directly between the user's buffer and the disk. This means that much less time is spent in the system. For performance purposes, specify direct I/O only for large, block-aligned, sequential I/O.

The `setfa`(1) command and the `sam_setfa`(3) library routine both have a `-D` option that sets the direct I/O attribute for a file or directory. If applied to a directory, files and directories created in that directory inherit the direct I/O attribute. After the `-D` option is set, the file uses direct I/O.

You can also select direct I/O for a file by using the Solaris OS `directio`(3C) function call. If you use the function call to enable direct I/O, the setting lasts only while the file is active.

To enable direct I/O on a file-system basis, do one of the following:

- Specify the `-o forcedirectio` option with the `mount`(1M) command.

- Put the `forcedirectio` keyword in the mount option column of the `/etc/vfstab` file, or use it as a directive in the `samfs.cmd` file.

For more information, see the `setfa`(1), `sam_setfa`(3), `directio`(3C), `samfs.cmd`(4), and `mount_samfs`(1M) man pages.

### I/O Switching

By default, paged I/O is performed, and I/O switching is disabled. However, the Sun StorEdge SAM-FS file systems support automatic I/O switching, a process by which a site-defined amount of paged I/O occurs before the system switches automatically to direct I/O.

I/O switching should reduce page cache usage on large I/O operations. To enable I/O switching, use `samu`(1M), or use the `dio_wr_consec` and `dio_rd_consec` parameters as directives in the `samfs.cmd` file or as options with the `mount`(1M) command.

For more information about these options, see the `mount_samfs`(1M) or `samfs.cmd`(4) man pages.

##

Increasing File Transfer Performance for Large Files

Sun StorEdge SAM-FS file systems are tuned to work with a mix of file sizes. You can increase the performance of disk file transfers for large files by enabling file system settings.

Note - Sun recommends that you experiment with performance tuning outside of a production environment. Tuning these variables incorrectly can have unexpected effects on the overall system. If your site has a Sun Enterprise Services (SES) support contract, please inform SES if you change performance tuning parameters.

### To Increase File Transfer Performance

1. Set the maximum device read/write directive.

The `maxphys` parameter in the Solaris `/etc/system` file controls the maximum number of bytes that a device driver reads or writes at any one time. The default value for the `maxphys` parameter can differ, depending on the level of your Sun Solaris OS, but it is typically around 128 kilobytes.

Add the following line to `/etc/system` to set `maxphys` to 8 megabytes:

    set maxphys = 0x800000

2. Set the SCSI disk maximum transfer parameter.

The `sd` driver enables large transfers for a specific file by looking for the`sd_max_xfer_size` definition in the `/kernel/drv/sd.conf` file. If this definition does not exist, the driver uses the value defined in the `sd` device driver definition, `sd_max_xfer_size`, which is 1024 x 1024 bytes.

To enable and encourage large transfers, add the following line at the end of the`/kernel/drv/sd.conf` file:

    sd_max_xfer_size=0x800000;

3. Set the fibre disk maximum transfer parameter.

The `ssd` driver enables large transfers for a specific file by looking for the`ssd_max_xfer_size` definition in the `/kernel/drv/ssd.conf` file. If this definition does not exist, the driver uses the value defined in the `ssd` device driver definition, `ssd_max_xfer_size`, which is 1024 x 1024 bytes.

Add the following line at the end of the `/kernel/drv/ssd.conf` file:

    ssd_max_xfer_size=0x800000;

4. Reboot the system.

5. Set the `writebehind` parameter.

This step affects paged I/O only.

The `writebehind` parameter specifies the number of bytes that are written behind by the file system when paged I/O is being performed on a Sun StorEdge SAM-FS file system. Matching the `writebehind` value to a multiple of the RAID's read-modify-write value can increase performance.

This parameter is specified in units of kilobytes and is truncated to an 8-kilobyte multiple. If set, this parameter is ignored when direct I/O is performed. The default `writebehind` value is 512 kilobytes. This value favors large-block, sequential I/O.

Set the `writebehind` size to a multiple of the RAID 5 stripe size for both hardware and software RAID-5. The RAID-5 stripe size is the number of data disks multiplied by the configured stripe width.

For example, assume that you configure a RAID-5 device with three data disks plus one parity disk (3+1) with a stripe width of 16 kilobytes. The `writebehind` value should be 48 kilobytes, 96 kilobytes, or some other multiple, to avoid the overhead of the read-modify-write RAID-5 parity generation.

For Sun StorEdge SAM-FS file systems, the DAU (`sammkfs`(1M) `-a` command) should also be a multiple of the RAID-5 stripe size. This allocation ensures that the blocks are contiguous.

You should test the system performance after resetting the `writebehind` size. The following example shows testing timings of disk writes:

    # timex dd if=/dev/zero of=/sam/myfile bs=256k count=2048

You can set the `writebehind` parameter from a mount option, from within the`samfs.cmd` file, from within the `/etc/vfstab` file, or from a command within the`samu`(1M) utility. For information about enabling this from a mount option, see the`-o writebehind=`n option on the `mount_samfs`(1M) man page. For information about enabling this from the`samfs.cmd` file, see the `samfs.cmd`(4) man page. For information about enabling this from within `samu`(1M), see the `samu`(1M) man page.

6. Set the `readahead` parameter.

This step affects paged I/O only.

The `readahead` parameter specifies the number of bytes that are read ahead by the file system when paged I/O is being performed on a Sun StorEdge SAM-FS file system. This parameter is specified in units of kilobytes and is truncated to an 8-kilobyte multiple. If set, this parameter is ignored when direct I/O is performed.

Increasing the size of the `readahead` parameter increases the performance of large file transfers, but only to a point. You should test the performance of the system after resetting the `readahead` size until you see no more improvement in transfer rates. The following is an example method of testing timings on disk reads:

    # timex dd if=/sam/myfile of=/dev/null bs=256k

You should test various `readahead` sizes for your environment. The `readahead` parameter should be set to a size that increases the I/O performance for paged I/O, but is not so large as to hurt performance. It is also important to consider the amount of memory and number of concurrent streams when you set the `readahead` value. Setting the `readahead` value multiplied by the number of streams to a value that is greater than memory can cause page thrashing.

The default `readahead` value is 1024 kilobytes. This value favors large-block, sequential I/O. For short-block, random I/O applications, set `readahead` to the typical request size. Database applications do their own read-ahead, so for these applications, set `readahead` to 0.

The `readahead` setting can be enabled from a mount option, from within the`samfs.cmd` file, from within the `/etc/vfstab` file, or from a command within the`samu`(1M) utility. For information about enabling this setting from a mount option, see the `-o readahead=`n option on the `mount_samfs`(1M) man page. For information about enabling this setting from the `samfs.cmd` file, see the `samfs.cmd`(4) man page. For information about enabling this setting from within `samu`(1M), see the `samu`(1M) man page.

7. Set the stripe width.

The `-o stripe=`n option with the `mount`(1M) command specifies the stripe width for the file system. The stripe width is based on the disk allocation unit (DAU) size. The n argument specifies that n x DAU bytes are written to one device before writing switches to the next device. The DAU size is set when the file system is initialized by the `sammkfs`(1M) `-a` command.

If `-o stripe=0` is set, files are allocated to file system devices using the round-robin allocation method. With this method, each file is completely allocated on one device until that device is full. Round-robin is the preferred setting for a multistream environment. If `-o stripe=`n is set to an integer greater than 0, files are allocated to file system devices using the stripe method. To determine the appropriate `-o stripe=`n setting, try varying the setting and taking performance readings. Striping is the preferred setting for turnkey applications with a required bandwidth.

You can also set the stripe width from the `/etc/vfstab` file or from the`samfs.cmd` file.

For more information about the `mount`(1M) command, see the `mount_samfs`(1M) man page. For more information about the `samfs.cmd` file, see the `samfs.cmd`(4) man page.

##

Enabling Qwrite Capability

By default, the Sun StorEdge SAM-FS file systems disable simultaneous reads and writes to the same file. This is the mode defined by the UNIX `vnode` interface standard, which gives exclusive access to only one write while other writers and readers must wait. Qwrite enables simultaneous reads and writes to the same file from different threads.

The Qwrite feature can be used in database applications to enable multiple simultaneous transactions to the same file. Database applications typically manage large files and issue simultaneous reads and writes to the same file. Unfortunately, each system call to a file acquires and releases a read/write lock inside the kernel. This lock prevents overlapped (or simultaneous) operations to the same file. If the application itself implements file locking mechanisms, the kernel-locking mechanism impedes performance by unnecessarily serializing I/O.

Qwrite can be enabled in the `/etc/vfstab` file, in the `samfs.cmd` file, and as a mount option. The `-o qwrite` option with the `mount`(1M) command bypasses the file system locking mechanisms (except for applications accessing the file system through NFS) and lets the application control data access. If `qwrite` is specified, the file system enables simultaneous reads and writes to the same file from different threads. This option improves I/O performance by queuing multiple requests at the drive level.

The following example uses the `mount`(1M) command to enable Qwrite on a database file system:

    # mount -F samfs -o qwrite /db

For more information about this feature, see the `qwrite` directive on the`samfs.cmd`(4) man page or the `-o qwrite` option on the `mount_samfs`(1M) man page.

##

Setting the Write Throttle

The `-o wr_throttle=`n option limits the number of outstanding write kilobytes for one file to n. By default, Sun StorEdge SAM-FS file systems set the `wr_throttle` to 16 megabytes.

If a file has n write kilobytes outstanding, the system suspends an application that attempts to write to that file until enough bytes have completed the I/O to allow the application to be resumed.

If your site has thousands of streams, such as thousands of NFS-shared workstations accessing the file system, you can tune the `-o wr_throttle=`n option in order to avoid flushing excessive amounts of memory to disk at once. Generally, the number of streams multiplied by 1024 x the n argument to the `-o wr_throttle=`n option should be less than the total size of the host system's memory minus the memory needs of the Solaris OS, as shown in this formula:

    number-of-streams x n x 1024 < total-memory - Solaris-OS-memory-needs

For turnkey applications, you might want to use a size larger than the default 16,384 kilobytes, because this keeps more pages in memory.

##

Setting the Flush-Behind Rate

Two mount parameters control the flush-behind rate for pages written sequentially and for stage pages. The `flush_behind` and `stage_flush_behind` mount parameters are read from the`samfs.cmd` file, the `/etc/vfstab` file, or the`mount`(1M) command.

The `flush_behind=`n mount parameter sets the maximum flush-behind value. Modified pages that are being written sequentially are written to disk asynchronously to help the Sun Solaris Volume Manager (VM) layer keep pages clean. To enable this feature, set n to be an integer from 16 through 8192. By default, n is set to 0, which disables this feature. The n argument is specified in kilobyte units.

The `stage_flush_behind=`n mount parameter sets the maximum stage flush-behind value. Stage pages that are being staged are written to disk asynchronously to help the Sun Solaris VM layer keep pages clean. To enable this feature, set n to be an integer from 16 through 8192. By default, n is set to 0, which disables this feature. The n argument is specified in kilobyte units.

For more information about these mount parameters, see the `mount_samfs`(1M) man page or the `samfs.cmd`(4) man page.

##

Tuning the Number of Inodes and the Inode Hash Table

The Sun StorEdge SAM-FS file system enables you to set the following two tunable parameters in the `/etc/system` file:

- `ninodes`

- `nhino`

To enable nondefault settings for these parameters, edit the `/etc/system` file, and then reboot your system.

The following subsections describe these parameters in more detail.

### The `ninodes` Parameter

The `ninodes` parameter specifies the maximum number of default inodes. The value for `ninodes` determines the number of in-core inodes that Sun StorEdge SAM-FS software keeps allocated to itself, even when applications are not using many inodes.

The format for this parameter in the `/etc/system` file is as follows:

    set samfs:ninodes = value

The range for value is from 16 through 2000000. The default value for `ninodes` is one of the following:

- A value that is equal to the `ncsize` setting. The `ncsize` parameter is a Solaris tuning parameter that specifies the number of entries in the directory name look-up cache (DNLC). For more information about `ncsize`, see the Solaris Tunable Parameters Reference Manual.

- `2000`. The file systems set `ninodes` to `2000` if the `ncsize` setting is zero or out of range.

### The `nhino` Parameter

The `nhino` parameter specifies the size of the in-core inode hash table.

The format for this parameter in the `/etc/system` file is as follows:

    set samfs:nhino = value

The range for value is `1` through 1048756. value must be a nonzero power of 2. The default value for `nhino` is one of the following:

- A value that is equal to the ninodes value divided by 8 and then, if necessary, rounded up to the nearest power of 2. For example, assume that the following line exists in `/etc/system`:

    set samfs:ninodes 8000

For this example, if `nhino` is not set, the system assumes `1024`, which is 8000 divided by 8 and then rounded up to the nearest power of 2 (210)

- `512`. The file systems set `nhino` to `512` if the `ninodes` setting is out of range.

### When to Set the `ninodes` and `nhino` Parameters

When searching for an inode by number (after obtaining an inode number from a directory or after extracting an inode number from an NFS file handle), a Sun StorEdge SAM-FS file system searches its cache of in-core inodes. To speed this process, the file system maintains a hash table to decrease the number of inodes it must check.

A larger hash table reduces the number of comparisons and searches, at a modest cost in memory usage. If the `nhino` value is too large, the system is slower when undertaking operations that sweep through the entire inode list (inode syncs and unmounts). For sites that manipulate large numbers of files and sites that do extensive amounts of NFS I/O, it can be advantageous to set these parameter values to larger than the defaults.

If your site has file systems that contain only a small number of files, it might be advantageous to make these numbers smaller than the defaults. This could be the case, for example, if you have a file system into which you write large single-file `tar`(1) files to back up other file systems.

Copyright © 2006, Sun Microsystems, Inc. All Rights Reserved.