Go to main content

Oracle® Solaris 11.4 DTrace (Dynamic Tracing) Guide

Exit Print View

Updated: November 2018
 
 

fileops Provider

The fileops provider makes the probes available pertaining to file operations such as open, close, read, write and so on. These probes are not specific to any file system type, nor are they dependent on I/O to external storage devices. For example, the fileops:::read probe fires on any read from a file, regardless of whether the data comes from disk or is cached in memory.

fileops Probes

The fileops provider probes fire on the successful completion of the operation. The probes available in the fileops provider are as follows:

Probe
Description
chmod
Fires when the mode of a file is changed. The fileinfo_t structure corresponding to the file is pointed to by args[0]. args[1] contains the latency of the operation. args[2] contains the new file mode.
chown
Fires when the ownership of a file is changed. The fileinfo_t structure corresponding to the file is pointed to by args[0]. args[1] contains the latency of the operation. args[2] contains the user ID of the new owner of the file.
chgrp
Fires when the group ownership of a file is changed. The fileinfo_t structure corresponding to the file is pointed to by args[0]. args[1] contains the latency of the operation. args[2] contains the group ID of the new group owner of the file.chgrp
chgrp
Fires when the group ownership of a file is changed. The fileinfo_t structure corresponding to the file is pointed to by args[0]. args[1] contains the latency of the operation. args[2] contains the group ID of the new group owner of the file.
close
Fires when an open file is closed. The fileinfo_t structure corresponding to the file is pointed to by args[0]. args[1] contains the latency of the operation.
create
Fires when a file is created. The fileinfo_t structure corresponding to the new file is pointed to by args[0]. args[1] contains the latency of the operation. args[2] contains the mode of the new file.
link
Fires when a hard link is created to an existing file. The fileinfo_t structure corresponding to the file is pointed to by args[0]. args[1] contains the latency of the operation. args[2] contains the fileinfo_t corresponding to the new link.
mkdir
Fires when a new directory is created. The fileinfo_t structure corresponding to the file is pointed to by args[0]. args[1] contains the latency of the operation. args[2] contains the mode of the new directory.
open
Fires when an existing file is opened. The fileinfo_t structure corresponding to the file is pointed to by args[0]. args[1] contains the latency of the operation. args[2] contains open(2) flags.
When you call open(2) with theO_CREAT flag and the file does not exist, the fileops:::create probe will fire first on creation of the file.
read
Fires when a read is performed from an open file. The fileinfo_t structure corresponding to the file is pointed to by args[0]. args[1] contains the latency of the operation. args[2] contains the file offset. args[3] contains the requested number of bytes. args[4] contains the actual number of bytes read.
readdir
Fires when a directory is read. The fileinfo_t structure corresponding to the directory is pointed to by args[0]. args[1] contains the latency of the operation. args[2] contains the number of bytes read.
rename
Fires when a file is renamed. The fileinfo_t structure corresponding to the original file name is pointed to by args[0]. args[1] contains the latency of the operation. args[2] contains the fileinfo_t corresponding to the new file name.
rmdir
Fires when a directory is removed. The fileinfo_t structure corresponding to the directory is pointed to by args[0]. args[1] contains the latency of the operation.
symlink
Fires when a symbolic link to a file is created. The fileinfo_t structure corresponding to the source file is pointed to by args[0]. args[1] contains the latency of the operation. args[2] contains the string representing the target of the symbolic link.
unlink
Fires when a link to an existing file is destroyed. The fileinfo_t structure corresponding to the file is pointed to by args[0]. args[1] contains the latency of the operation.
write
Fires when a write is performed to an open file. The fileinfo_t structure corresponding to the file is pointed to by args[0]. args[1] contains the latency of the operation. args[2] contains the file offset. args[3] contains the requested number of bytes. args[4] contains the actual number of bytes actually written.

For more information, see io fileinfo_t Structure structure.

fileops Probe Arguments

The following table lists the argument types for the fileops probes.

Table 25  Argument Types in the fileops Probes
Probe
args[0]
args[1]
args[2]
args[3]
args[4]
chmod
fileinfo_t *
hrtime_t
mode_t
NA
NA
chgrp
fileinfo_t *
hrtime_t
gid_t
NA
NA
chown
fileinfo_t *
hrtime_t
uid_t
NA
NA
close
fileinfo_t *
hrtime_t
NA
NA
NA
create
fileinfo_t *
hrtime_t
mode_t
NA
NA
link
fileinfo_t *
hrtime_t
fileinfo_t *
NA
NA
mkdir
fileinfo_t *
hrtime_t
mode_t
NA
NA
open
fileinfo_t *
hrtime_t
int
NA
NA
read
fileinfo_t *
hrtime_t
off_t
ssize_t
ssize_t
readdir
fileinfo_t *
hrtime_t
ssize_t
NA
NA
rename
fileinfo_t *
hrtime_t
fileinfo_t *
NA
NA
rmdir
fileinfo_t *
hrtime_t
NA
NA
NA
symlink
fileinfo_t *
hrtime_t
string
NA
NA
unlink
fileinfo_t *
hrtime_t
NA
NA
NA
write
fileinfo_t *
hrtime_t
off_t
ssize_t
ssize_t

Using the fileops read Probe

Example 26  Displaying Read Latencies by Using the read Probe

You can use the read probe to observe read latencies on different file system types. For example:

fileops:::read
{
        @[args[0]->fi_fs] = quantize(args[1]);
}

Running the example script on a server for several seconds generates an output similar to the following example:

# dtrace -s ./read-latency-by-fs.d
dtrace: script './read-latency-by-fs.d' matched 1 probe
^C

  tmpfs
           value  ------------- Distribution ------------- count
              64 |                                         0
             128 |@@@@@@@@@                                2
             256 |@@@@                                     1
             512 |                                         0
            1024 |                                         0
            2048 |                                         0
            4096 |                                         0
            8192 |@@@@@@@@@@@@@@@@@@                       4
           16384 |@@@@@@@@@                                2
           32768 |                                         0

  procfs
           value  ------------- Distribution ------------- count
            1024 |                                         0
            2048 |@@@@@@@                                  2
            4096 |                                         0
            8192 |@@@@@@@@@@@@@@@@@@                       5
           16384 |@@@@@@@@@@@@@@@                          4
           32768 |                                         0

  nfs3
           value  ------------- Distribution ------------- count
             128 |                                         0
             256 |@@@@                                     6
             512 |@@@                                      5
            1024 |@@@@@                                    7
            2048 |@@@@@@@@@@@@@@                           21
            4096 |@@@@@@@                                  10
            8192 |@@@@@@@@                                 12
           16384 |                                         0

  sockfs   
           value  ------------- Distribution ------------- count
             128 |                                         0
             256 |@@@@@                                    16
             512 |@@@@@@@@                                 27
            1024 |@@@@@@@                                  24
            2048 |@@@@@@@@@@@                              38
            4096 |@@                                       8
            8192 |@@@@@@@                                  23
           16384 |                                         1
           32768 |                                         0
           65536 |                                         0
          131072 |                                         0
          262144 |                                         0
          524288 |                                         0
         1048576 |                                         0
         2097152 |                                         1
         4194304 |                                         0

  fifofs
           value  ------------- Distribution ------------- count
              32 |                                         0
              64 |                                         1
             128 |@@@                                      8
             256 |@@@@@                                    13
             512 |@@                                       6
            1024 |@@                                       4
            2048 |@@                                       4
            4096 |@@@@@@@                                  18
            8192 |@                                        2
           16384 |@@@                                      8
           32768 |                                         1
           65536 |@                                        3
          131072 |                                         0
          262144 |                                         0
          524288 |@                                        2
         1048576 |                                         1
         2097152 |@@                                       6
         4194304 |@@@@@@@                                  17
         8388608 |@                                        2
        16777216 |                                         0
        33554432 |                                         1
        67108864 |                                         1
       134217728 |                                         0

  zfs
           value  ------------- Distribution ------------- count
             256 |                                         0
             512 |@                                        85
            1024 |@@                                       275
            2048 |@                                        116
            4096 |@@@@@@                                   982
            8192 |@@@@@@@@@@@@                             1963
           16384 |                                         72
           32768 |                                         34
           65536 |                                         2
          131072 |                                         39
          262144 |                                         3
          524288 |                                         0
         1048576 |                                         53
         2097152 |@@                                       351
         4194304 |@@@@@@@@@                                1360
         8388608 |@@@@@@                                   1011
        16777216 |                                         18
        33554432 |                                         6
        67108864 |                                         2
       134217728 |                                         3
       268435456 |                                         2
       536870912 |                                         0

In this example, you can see that memory-resident file systems such as tmpfs and pseudo-file systems such as procfs satisfy read requests very quickly. You can also see that file systems such as zfs have a bi-modal distribution. Reads that are satisfied from the in-memory cache happen very quickly and the reads that must go to disk are orders of magnitude slower.

Example 27  Displaying the Distribution of Write Sizes by Using the write Probe

You can use the write probe to observe the distribution of write sizes on the system, independent of file system type. For example:

fileops:::write
{
        @ = quantize(args[4]);
}

Running this briefly on a small server generates an output similar to the following:

# dtrace -s ./write-size.d
dtrace: script './write-size.d' matched 1 probe
^C


           value  ------------- Distribution ------------- count    
              -1 |                                         0        
               0 |                                         2        
               1 |@@@@@@@@@@                               190      
               2 |                                         5        
               4 |@                                        16       
               8 |@                                        20       
              16 |@                                        24       
              32 |@@@@                                     80       
              64 |@@@@@@@@@@@@@                            253      
             128 |@@@@@                                    96       
             256 |@@                                       48       
             512 |                                         3        
            1024 |@@                                       34       
            2048 |                                         2        
            4096 |                                         0        
            8192 |                                         3        
           16384 |                                         0   

fileops Stability

The fileops provider uses stability mechanism of DTrace to describe its stabilities as shown in the following table. For more information about the stability mechanism, see DTrace Stability Mechanisms.

Table 26  fileops Provider Stability
Element
Name Stability
Data Stability
Dependency Class
Provider
Evolving
Evolving
ISA
Module
Private
Private
Unknown
Function
Private
Private
Unknown
Name
Evolving
Evolving
ISA
Arguments
Evolving
Evolving
ISA