title: How to account for VFS operations at the block device layer?
body: <p>I want to measure how much could be gained by placing some of a filesystem data on a fast device, vs regular spinning disks. As an example, measure extended attribute (xattr) operations, vs regular reads and writes.</p>
  
  <p>I started with the "bpftrace" tool, following individual VFS calls with a thread local variable.
  Attempting to catch the associated block device requests fails, probably because the actual IO is done by a "kworker" process.</p>
  
  <p>Here is the naive code:</p>
  
  <pre><code>kprobe:vfs_getxattr,
  kprobe:vfs_setxattr,
  kprobe:vfs_read*,
  kprobe:vfs_write*
  /comm == "some-process"/
  {
      @start[tid] = nsecs;
      @name[tid] = func;
  }
  
  tracepoint:block:block_rq_issue
  /@start[tid]/
  {
      @bio[@name[tid]] = count();
  }
  
  kretprobe:vfs_getxattr,
  kretprobe:vfs_setxattr,
  kretprobe:vfs_read*,
  kretprobe:vfs_write*
  /@start[tid]/
  {
      @count[@name[tid]] = count();
      delete(@start[tid]);
      delete(@name[tid]);
  }
  </code></pre>
  
  <p>Is there any way I could follow the VFS calls down to block device IO?</p>