This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: NFSD tapset: how can I get filename from filehandles ?
- From: David Smith <dsmith at redhat dot com>
- To: sbocahu at bearstech dot com
- Cc: systemtap at sources dot redhat dot com
- Date: Tue, 24 Aug 2010 11:13:50 -0500
- Subject: Re: NFSD tapset: how can I get filename from filehandles ?
- References: <66152641961643b384b762190abb1a70@127.0.0.1>
On 08/24/2010 09:23 AM, sbocahu@bearstech.com wrote:
> Hi all,
>
> I hope I'm not disturbing too much... I'm a new systemtap user without any
> kernel knowledge, trying to write a few scripts.
> Since I fail to write the second one, I would like to ask you for
> pointers:
No problem - ask away.
> I would like to gather some stats from nfsd probes to know which files are
> most accessed/written/read/etc...
> This is pretty easy with the create(), remove() and lookup() nfsops as the
> nfsd tapset exposes the filename variable (wich seems to be easy as well,
> because the filename is given as argument to the call).
>
> The problem is: I can't get the filename for other nfsops. The filename is
> not given as argument.
Right.
> I guess it is possible to get it from the filehandle, though:
> (warning: I might be _totally_ wrong, I just tried to read the source and
> understand things by myself...)
... stuff deleted ...
> I've tried a few things without success... such as:
>
>
> filename = @cast($argp, "nfsd3_writeargs",
> "kernel:nfsd")->fh->fh_dentry->d_name->name
>
>
> which ended with a segfault.
OK, I'm going to need some details here. First, what kernel are you using?
When you say a 'segfault', do you mean the stap executable segfaulted,
or you got a kernel read fault, something like this:
---
ERROR: kernel read fault at 0x0000000000000034 (addr) near identifier
'@cast' at /usr/local/share/systemtap/tapset/dentry.stp:41:15
---
I'll include the script in a sec, but that is systemtap protecting me
from crashing my kernel. Instead of letting me read from that bogus
address, systemtap errors out. This is a good thing.
If the stap executable segfaulted, could you show us your script and
exact output you are seeing?
> Well, would you correct me and give me pointers on how achieving this,
> please ?
I need to do something like this myself, so I've looked into it. Here's
what I started with:
==========
probe nfsd.proc3.write
{
printf("fh = %p\n", fh)
dentry = @cast(fh, "svc_fh", "kernel:nfsd")->fh_dentry
printf("dentry = %p\n", dentry)
printf("writing %s\n", d_name(dentry))
}
==========
That's what gives the kernel read fault I showed above. Here's a
"fixed" version - it doesn't error out, but it doesn't work either.
==========
probe nfsd.proc3.write
{
printf("fh = %p\n", fh)
dentry = @cast(fh, "svc_fh", "kernel:nfsd")->fh_dentry
printf("dentry = %p\n", dentry)
if (dentry)
printf("writing %s\n", d_name(dentry))
else
printf("no dentry!\n")
}
==========
At that point dentry is NULL.
When(/if) I figure out how to get the filename, I'll let you know. If
you figure it out, let me know.
Feel free to email the list with more questions.
--
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)