This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

NFSD tapset: how can I get filename from filehandles ?


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:

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.


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...)


from the nfsd tapset, nfsd.proc3.write:

    fh = & @cast($argp, "nfsd3_writeargs", "kernel:nfsd")->fh

* fh seems to be of type of svc_fh:

linux/include/linux/nfsd/xdr3.h:

    struct nfsd3_writeargs {
            svc_fh                  fh;
            __u64                   offset;
            __u32                   count;
            int                     stable;
            __u32                   len;
            int                     vlen;
    };

* svc_fh seems to contain a dentry* member

linux/nfsd/nfsfh.h:

    typedef struct svc_fh {
            struct knfsd_fh         fh_handle;      /* FH data */
            struct dentry *         fh_dentry;      /* validated dentry */
            struct svc_export *     fh_export;      /* export pointer */

            ...

* there should be a qstr member in dentry...

linux/dcache.h:

    struct dentry {
            atomic_t d_count;
            ...
            struct qstr d_name;
            ...

* ... which contains the filename

linux/dcache.h:

    struct qstr {
            unsigned int hash;
            unsigned int len;
            const unsigned char *name;
    };


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.


Well, would you correct me and give me pointers on how achieving this,
please ?

Thanks a lot !
Best regards,

SÃbastien


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]