This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: How to get write/read offset?
- From: David Smith <dsmith at redhat dot com>
- To: "Olausson, Bjoern" <contactme at olausson dot de>, systemtap at sourceware dot org
- Date: Thu, 10 Mar 2016 13:12:43 -0600
- Subject: Re: How to get write/read offset?
- Authentication-results: sourceware.org; auth=none
- References: <CAE7O3Tc5T8UfZgJegQ8H6mZ7r+fd+kSMtPUd9EmLvVS=S2ZyVQ at mail dot gmail dot com>
On 03/10/2016 06:32 AM, Olausson, Bjoern wrote:
> Hello Systemtap users,
>
> is there some straight forward way to get the offset for any read,
> write, pwrite etc. syscall?
>
> So for example if I trace the the IO to a file and the program issues
> a "seek" and writes reads n bytes starting from this position, is
> there any way to get that start position (offset) except from probing
> for an "seek" before a write/read?
>
> For example:
>
> probe syscall.write.return {
> if (pid() == target()) {
> time_stamp = timestamp()
> p = pid()
> fd = $fd
> bytes = $return
> latency = gettimeofday_us() - @entry(gettimeofday_us())
> printf("%d;%d;%s;%s;%d;%d;%d\n", p, fd, filehandles[p, fd], name,
> bytes, time_stamp, latency)
> }
> }
>
> If there is no straight forward way to get this information, what is
> the most native way to get the offset alongside with the time, latency
> and bytes_written/read?
To get the file offset, you'll have to probe 1 level down. syscall.read
(sys_read()) is basically a wrapper around vfs.read (vfs_read()).
syscall.write (sys_write()) is basically a wrapper around vfs.write
(vfs_write()).
So, you can (almost) replace syscall.write.return in your example above
with vfs.write.return. One of the differences are that you don't get $fd
anymore, instead you get a 'struct file' pointer.
--
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)