szaydel
11/15/2016 - 10:48 PM

Dtrace snippets for ZFS write cache flushing observations

Dtrace snippets for ZFS write cache flushing observations

dtrace -qn '
    /* Check whether or not the flush write cache bit is set
    * by checking for the DKIOCFLUSHWRITECACHE value in the zio->io_cmd.
    * See usr/src/uts/common/sys/dkio.h for more information.
    */
    inline int DKIOCFLUSHWRITECACHE = (0x04 << 8)|34 ;
    ::vdev_disk_io_start:entry 
        /args[0]->io_cmd == DKIOCFLUSHWRITECACHE 
        && args[0]->io_vd->vdev_path != NULL/ {
        this->vpath = args[0]->io_vd->vdev_path ;
        @yes[stringof(this->vpath)] = count();
    }
    ::vdev_disk_io_start:entry 
        /args[0]->io_cmd != DKIOCFLUSHWRITECACHE
        && args[0]->io_vd->vdev_path != NULL/ {
        this->vpath = args[0]->io_vd->vdev_path ;
        @no[stringof(this->vpath)] = count() ;
    }
    END {
        printa("%-32s flush=%@d no-flush=%@d\n", @yes, @no);
    }'
dtrace -qn '
inline int FSYNC    = 0x10;
inline int FDSYNC   = 0x40;
inline int FRSYNC   = 0x8000;
inline int NOSYNC   = 0;
    BEGIN {
        map[FSYNC]  = "FSYNC";
        map[FDSYNC] = "FDSYNC";
        map[FRSYNC] = "FRSYNC";
        map[NOSYNC] = "NOSYNC";
    }
    ::zfs_write:entry {
        this->vn = args[0]; 
        this->f = args[2] & (FSYNC|FDSYNC|FRSYNC);
        @[stringof(this->vn->v_path), map[this->f]] = count(); 
}'