Friday July 08, 2005 | Richard McDougall's Weblog Commentary from Race Control |
|
Tracing the Solaris 10 File System Interface Here's a quick script to trace activity though the central file system interface. Until there is a general file system provider, this script should serve as a basic framework help construct other file system tracing scripts.
# ./voptrace.d /tmp Event Device Path RW Size Offset fop_putpage - /tmp//filebench/bin/i386/fastsu - 4096 4096 fop_inactive - /tmp//filebench/bin/i386/fastsu - 0 0 fop_putpage - /tmp//filebench/xanadu/WEB-INF/lib/classes12.jar - 4096 204800 fop_inactive - /tmp//filebench/xanadu/WEB-INF/lib/classes12.jar - 0 0 fop_putpage - /tmp/filebench1.63_s10_x86_sparc_pkg.tar.Z - 4096 7655424 fop_inactive - /tmp/filebench1.63_s10_x86_sparc_pkg.tar.Z - 0 0 fop_putpage - /tmp//filebench/xanadu/WEB-INF/lib/classes12.jar - 4096 782336 fop_inactive - /tmp//filebench/xanadu/WEB-INF/lib/classes12.jar - 0 0 fop_putpage - /tmp//filebench/bin/amd64/filebench - 4096 36864
The source is below:
#!/usr/sbin/dtrace -s
/*
* Trace the vnode interface
*
* USAGE: voptrace.d [/all | /mountname ]
*
* Author: Richard McDougall
*
* 7/8/2005
*/
#pragma D option quiet
:::BEGIN
{
printf("%-15s %-10s %51s %2s %8s %8s\n",
"Event", "Device", "Path", "RW", "Size", "Offset");
self->trace = 0;
self->path = "";
}
::fop_*:entry
/self->trace == 0/
{
/* Get vp: fop_open has a pointer to vp */
self->vpp = (vnode_t **)arg0;
self->vp = (vnode_t *)arg0;
self->vp = probefunc == "fop_open" ? (vnode_t *)*self->vpp : self->vp;
/* And the containing vfs */
self->vfsp = self->vp ? self->vp->v_vfsp : 0;
/* And the paths for the vp and containing vfs */
self->vfsvp = self->vfsp ? (struct vnode *)((vfs_t *)self->vfsp)->vfs_vnodecovered : 0;
self->vfspath = self->vfsvp ? stringof(self->vfsvp->v_path) : "unknown";
/* Check if we should trace the root fs */
($1 == "/all" ||
($1 == "/" && self->vfsp && \
(self->vfsp == `rootvfs))) ? self->trace = 1 : self->trace;
/* Check if we should trace the fs */
($1 == "/all" || (self->vfspath == $1)) ? self->trace = 1 : self->trace;
}
/*
* Trace the entry point to each fop
*
*/
::fop_*:entry
/self->trace/
{
self->path = (self->vp != NULL && self->vp->v_path) ? stringof(self->vp->v_path) : "unknown";
self->len = 0;
self->off = 0;
/* Some fops has the len in arg2 */
(probefunc == "fop_getpage" || \
probefunc == "fop_putpage" || \
probefunc == "fop_none") ? self->len = arg2 : 1;
/* Some fops has the len in arg3 */
(probefunc == "fop_pageio" || \
probefunc == "fop_none") ? self->len = arg3 : 1;
/* Some fops has the len in arg4 */
(probefunc == "fop_addmap" || \
probefunc == "fop_map" || \
probefunc == "fop_delmap") ? self->len = arg4 : 1;
/* Some fops has the offset in arg1 */
(probefunc == "fop_addmap" || \
probefunc == "fop_map" || \
probefunc == "fop_getpage" || \
probefunc == "fop_putpage" || \
probefunc == "fop_seek" || \
probefunc == "fop_delmap") ? self->off = arg1 : 1;
/* Some fops has the offset in arg3 */
(probefunc == "fop_close" || \
probefunc == "fop_pageio") ? self->off = arg3 : 1;
/* Some fops has the offset in arg4 */
probefunc == "fop_frlock" ? self->off = arg4 : 1;
/* Some fops has the pathname in arg1 */
self->path = (probefunc == "fop_create" || \
probefunc == "fop_mkdir" || \
probefunc == "fop_rmdir" || \
probefunc == "fop_remove" || \
probefunc == "fop_lookup") ?
strjoin(self->path, strjoin("/", stringof(arg1))) : self->path;
printf("%-15s %-10s %51s %2s %8d %8d\n",
probefunc,
"-", self->path, "-", self->len, self->off);
self->type = probefunc;
}
::fop_*:return
/self->trace == 1/
{
self->trace = 0;
}
/* Capture any I/O within this fop */
io:::start
/self->trace/
{
printf("%-15s %-10s %51s %2s %8d %8u\n",
self->type, args[1]->dev_statname,
self->path, args[0]->b_flags & B_READ ? "R" : "W",
args[0]->b_bcount, args[0]->b_blkno);
}
Technorati Tag: OpenSolaris Technorati Tag: Solaris Technorati Tag: DTrace ( Jul 08 2005, 04:05:55 PM PDT ) Permalink Comments [1]
Trackback URL: http://blogs.sun.com/rmc/entry/tracing_the_solaris_10_file
Post a Comment: |
|
||||
<a href="http://vclosets.com">closet organizers</a>
Posted by closet organizers on November 29, 2008 at 11:54 AM PST #