Home | History | Annotate | Line # | Download | only in Examples
      1  1.1  christos The following are demonstrations of the fsrw.d script.
      2  1.1  christos 
      3  1.1  christos 
      4  1.1  christos Here the fsrw.d script was running while a 50 Kbyte file was read,
      5  1.1  christos 
      6  1.1  christos    # ./fsrw.d
      7  1.1  christos    Event            Device RW     Size Offset Path
      8  1.1  christos    sc-read               .  R     8192      0 /extra1/50k
      9  1.1  christos      fop_read            .  R     8192      0 /extra1/50k
     10  1.1  christos        disk_io       cmdk0  R     8192      0 /extra1/50k
     11  1.1  christos        disk_ra       cmdk0  R     8192      8 /extra1/50k
     12  1.1  christos    sc-read               .  R     8192      8 /extra1/50k
     13  1.1  christos      fop_read            .  R     8192      8 /extra1/50k
     14  1.1  christos        disk_ra       cmdk0  R    34816     16 /extra1/50k
     15  1.1  christos    sc-read               .  R     8192     16 /extra1/50k
     16  1.1  christos      fop_read            .  R     8192     16 /extra1/50k
     17  1.1  christos    sc-read               .  R     8192     24 /extra1/50k
     18  1.1  christos      fop_read            .  R     8192     24 /extra1/50k
     19  1.1  christos    sc-read               .  R     8192     32 /extra1/50k
     20  1.1  christos      fop_read            .  R     8192     32 /extra1/50k
     21  1.1  christos    sc-read               .  R     8192     40 /extra1/50k
     22  1.1  christos      fop_read            .  R     8192     40 /extra1/50k
     23  1.1  christos    sc-read               .  R     8192     48 /extra1/50k
     24  1.1  christos      fop_read            .  R     8192     48 /extra1/50k
     25  1.1  christos    sc-read               .  R     8192     50 /extra1/50k
     26  1.1  christos      fop_read            .  R     8192     50 /extra1/50k
     27  1.1  christos    ^C
     28  1.1  christos 
     29  1.1  christos By looking closely at the Offset (Kbytes) and Size of each transaction, we
     30  1.1  christos can see how the read() system calls (sc-read) were satisfied by the file
     31  1.1  christos system. There were 8 read() system calls, and 3 disk events - 2 of which were
     32  1.1  christos UFS read-ahead (disk_ra). The final read-ahead was for 34 Kbytes and began
     33  1.1  christos with an offset of 16 Kbytes, which read the remaining file data (34 + 16 = 50
     34  1.1  christos Kbytes). The subsequent read() system calls and corresponding fop_read() calls
     35  1.1  christos returned from the page cache.
     36  1.1  christos 
     37  1.1  christos 
     38  1.1  christos 
     39  1.1  christos The following demonstrates how a logical I/O is broken up into multiple 
     40  1.1  christos physical I/O events. Here a dd command was used to read 1 Mbytes from the
     41  1.1  christos /var/sadm/install/contents file while fsrw.d was tracing.
     42  1.1  christos 
     43  1.1  christos    # ./fsrw.d
     44  1.1  christos    Event            Device RW     Size Offset Path
     45  1.1  christos    sc-read               .  R  1048576      0 /var/sadm/install/contents
     46  1.1  christos      fop_read            .  R  1048576      0 /var/sadm/install/contents
     47  1.1  christos        disk_ra       cmdk0  R     4096     72 /var/sadm/install/contents
     48  1.1  christos        disk_ra       cmdk0  R     8192     96 <none>
     49  1.1  christos        disk_ra       cmdk0  R    57344     96 /var/sadm/install/contents
     50  1.1  christos        disk_ra       cmdk0  R    57344    152 /var/sadm/install/contents
     51  1.1  christos        disk_ra       cmdk0  R    57344    208 /var/sadm/install/contents
     52  1.1  christos        disk_ra       cmdk0  R    49152    264 /var/sadm/install/contents
     53  1.1  christos        disk_ra       cmdk0  R    57344    312 /var/sadm/install/contents
     54  1.1  christos        disk_ra       cmdk0  R    57344    368 /var/sadm/install/contents
     55  1.1  christos        disk_ra       cmdk0  R    57344    424 /var/sadm/install/contents
     56  1.1  christos        disk_ra       cmdk0  R    57344    480 /var/sadm/install/contents
     57  1.1  christos        disk_ra       cmdk0  R    57344    536 /var/sadm/install/contents
     58  1.1  christos        disk_ra       cmdk0  R    57344    592 /var/sadm/install/contents
     59  1.1  christos        disk_ra       cmdk0  R    57344    648 /var/sadm/install/contents
     60  1.1  christos        disk_ra       cmdk0  R    57344    704 /var/sadm/install/contents
     61  1.1  christos        disk_ra       cmdk0  R    57344    760 /var/sadm/install/contents
     62  1.1  christos        disk_ra       cmdk0  R    57344    816 /var/sadm/install/contents
     63  1.1  christos        disk_ra       cmdk0  R    57344    872 /var/sadm/install/contents
     64  1.1  christos        disk_ra       cmdk0  R    57344    928 /var/sadm/install/contents
     65  1.1  christos        disk_ra       cmdk0  R    57344    984 /var/sadm/install/contents
     66  1.1  christos        disk_ra       cmdk0  R    57344   1040 /var/sadm/install/contents
     67  1.1  christos    ^C
     68  1.1  christos 
     69  1.1  christos Both the read() syscall (sc-read) and the fop_read() call asked the file system
     70  1.1  christos for 1048576 bytes, which was then broken into numerous disk I/O events of up to
     71  1.1  christos 56 Kbytes in size. The 8192 byte read with a path of "<none>" is likely to be
     72  1.1  christos the file system reading the indirect block pointers for the 
     73  1.1  christos /var/sadm/install/contents file (something DTrace could confirm in detail).
     74  1.1  christos 
     75  1.1  christos 
     76  1.1  christos 
     77  1.1  christos 
     78  1.1  christos The following traces activity as a cp command copies a 50 Kbyte file.
     79  1.1  christos 
     80  1.1  christos    # ./fsrw.d
     81  1.1  christos    Event            Device RW     Size Offset Path
     82  1.1  christos        disk_io        dad1  R     1024      0 /extra1
     83  1.1  christos        disk_io        dad1  R     8192      0 <none>
     84  1.1  christos        disk_io        dad1  R     8192      0 <none>
     85  1.1  christos        disk_io        dad1  R     2048      0 <none>
     86  1.1  christos        disk_io        dad1  R     2048      0 <none>
     87  1.1  christos    sc-write              .  W    51200      0 /extra1/outfile
     88  1.1  christos      fop_write           .  W    51200      0 /extra1/outfile
     89  1.1  christos        disk_io        dad1  R     8192      0 /extra1/50k
     90  1.1  christos        disk_ra        dad1  R     8192      8 /extra1/50k
     91  1.1  christos        disk_ra        dad1  R    34816     16 /extra1/50k
     92  1.1  christos        disk_io        dad1  R     2048      0 <none>
     93  1.1  christos        disk_io        dad1  W    49152      0 /extra1/outfile
     94  1.1  christos    ^C
     95  1.1  christos 
     96  1.1  christos Reads including UFS read-ahead can be seen as the file is read.
     97  1.1  christos The output finishes with disk writes as the new file is flushed to disk.
     98  1.1  christos The syscall write() and fop_write() can be seen to the /extra1/outfile,
     99  1.1  christos however there is no syscall read() or fop_read() to /extra1/50k - which
    100  1.1  christos we may have expected to occur before the writes. This is due to the way
    101  1.1  christos the cp command now works, it uses mmap() to map files in for reading.
    102  1.1  christos This activity can be seen if we also trace fop_getpage() and fop_putpage(),
    103  1.1  christos as the fspaging.d dtrace script does.
    104  1.1  christos 
    105  1.1  christos    # ./fspaging.d
    106  1.1  christos    Event             Device RW     Size Offset Path
    107  1.1  christos        disk_io         dad1  R     1024      0 /extra1
    108  1.1  christos        disk_io         dad1  R     8192      0 <none>
    109  1.1  christos        disk_io         dad1  R     2048      0 <none>
    110  1.1  christos    sc-write               .  W    51200      0 /extra1/outfile
    111  1.1  christos      fop_write            .  W    51200      0 /extra1/outfile
    112  1.1  christos      fop_getpage          .  R     8192      0 /extra1/50k
    113  1.1  christos        disk_io         dad1  R     8192      0 /extra1/50k
    114  1.1  christos        disk_ra         dad1  R     8192      8 /extra1/50k
    115  1.1  christos      fop_getpage          .  R     8192      8 /extra1/50k
    116  1.1  christos        disk_ra         dad1  R    34816     16 /extra1/50k
    117  1.1  christos      fop_getpage          .  R     8192     16 /extra1/50k
    118  1.1  christos      fop_getpage          .  R     8192     24 /extra1/50k
    119  1.1  christos      fop_getpage          .  R     8192     32 /extra1/50k
    120  1.1  christos      fop_getpage          .  R     8192     40 /extra1/50k
    121  1.1  christos      fop_getpage          .  R     8192     48 /extra1/50k
    122  1.1  christos      fop_putpage          .  W     8192      0 /extra1/outfile
    123  1.1  christos      fop_putpage          .  W     8192      8 /extra1/outfile
    124  1.1  christos      fop_putpage          .  W     8192     16 /extra1/outfile
    125  1.1  christos      fop_putpage          .  W     8192     24 /extra1/outfile
    126  1.1  christos      fop_putpage          .  W     8192     32 /extra1/outfile
    127  1.1  christos      fop_putpage          .  W     8192     40 /extra1/outfile
    128  1.1  christos        disk_io         dad1  W    51200      0 /extra1/outfile
    129  1.1  christos 
    130