Commit 027f9a6b authored by Kirill Smelkov's avatar Kirill Smelkov

X wcfs/fusetrace: Update to recent bpftrace

- don't need to manually declare iov_iter struct
- can use enums
- have to use `struct` in casts.
parent d1cd128c
#!/usr/bin/env -S bpftrace
// Copyright (C) 2019 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Copyright (C) 2019-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
......@@ -24,26 +24,6 @@
#include <linux/fuse.h>
#include <linux/uio.h>
// FIXME https://github.com/iovisor/bpftrace/issues/406
struct xiov_iter {
unsigned int type;
size_t iov_offset;
size_t count;
union {
struct iovec *iov;
struct kvec *kvec;
struct bio_vec *bvec;
struct pipe_inode_info *pipe;
};
union {
unsigned long nr_segs;
struct {
int idx;
int start_idx;
};
};
};
BEGIN {
@tstart = nsecs;
......@@ -58,59 +38,59 @@ BEGIN {
//clear(@rpending); // {} (tid,#nr) -> ustack
//clear(@wpending); // {} (tid,#nw) -> ustack
// XXX bpftrace does not recognize enum
@opcode[ 1] = "LOOKUP";
@opcode[ 2] = "FORGET";
@opcode[ 3] = "GETATTR";
@opcode[ 4] = "SETATTR";
@opcode[ 5] = "READLINK";
@opcode[ 6] = "SYMLINK";
@opcode[ 8] = "MKNOD";
@opcode[ 9] = "MKDIR";
@opcode[10] = "UNLINK";
@opcode[11] = "RMDIR";
@opcode[12] = "RENAME";
@opcode[13] = "LINK";
@opcode[14] = "OPEN";
@opcode[15] = "READ";
@opcode[16] = "WRITE";
@opcode[17] = "STATFS";
@opcode[18] = "RELEASE";
@opcode[20] = "FSYNC";
@opcode[21] = "SETXATTR";
@opcode[22] = "GETXATTR";
@opcode[23] = "LISTXATTR";
@opcode[24] = "REMOVEXATTR";
@opcode[25] = "FLUSH";
@opcode[26] = "INIT";
@opcode[27] = "OPENDIR";
@opcode[28] = "READDIR";
@opcode[29] = "RELEASEDIR";
@opcode[30] = "FSYNCDIR";
@opcode[31] = "GETLK";
@opcode[32] = "SETLK";
@opcode[33] = "SETLKW";
@opcode[34] = "ACCESS";
@opcode[35] = "CREATE";
@opcode[36] = "INTERRUPT";
@opcode[37] = "BMAP";
@opcode[38] = "DESTROY";
@opcode[39] = "IOCTL";
@opcode[40] = "POLL";
@opcode[41] = "NOTIFY_REPLY";
@opcode[42] = "BATCH_FORGET";
@opcode[43] = "FALLOCATE";
@opcode[44] = "READDIRPLUS";
@opcode[45] = "RENAME2";
@opcode[46] = "LSEEK";
@opcode[47] = "COPY_FILE_RANGE";
@notify[1] = "NOTIFY_POLL";
@notify[2] = "NOTIFY_INVAL_INODE";
@notify[3] = "NOTIFY_INVAL_ENTRY";
@notify[4] = "NOTIFY_STORE";
@notify[5] = "NOTIFY_RETRIEVE";
@notify[6] = "NOTIFY_DELETE";
@opcode [FUSE_LOOKUP] = "LOOKUP";
@opcode [FUSE_FORGET] = "FORGET";
@opcode [FUSE_GETATTR] = "GETATTR";
@opcode [FUSE_SETATTR] = "SETATTR";
@opcode [FUSE_READLINK] = "READLINK";
@opcode [FUSE_SYMLINK] = "SYMLINK";
@opcode [FUSE_MKNOD] = "MKNOD";
@opcode [FUSE_MKDIR] = "MKDIR";
@opcode [FUSE_UNLINK] = "UNLINK";
@opcode [FUSE_RMDIR] = "RMDIR";
@opcode [FUSE_RENAME] = "RENAME";
@opcode [FUSE_LINK] = "LINK";
@opcode [FUSE_OPEN] = "OPEN";
@opcode [FUSE_READ] = "READ";
@opcode [FUSE_WRITE] = "WRITE";
@opcode [FUSE_STATFS] = "STATFS";
@opcode [FUSE_RELEASE] = "RELEASE";
@opcode [FUSE_FSYNC] = "FSYNC";
@opcode [FUSE_SETXATTR] = "SETXATTR";
@opcode [FUSE_GETXATTR] = "GETXATTR";
@opcode [FUSE_LISTXATTR] = "LISTXATTR";
@opcode [FUSE_REMOVEXATTR] = "REMOVEXATTR";
@opcode [FUSE_FLUSH] = "FLUSH";
@opcode [FUSE_INIT] = "INIT";
@opcode [FUSE_OPENDIR] = "OPENDIR";
@opcode [FUSE_READDIR] = "READDIR";
@opcode [FUSE_RELEASEDIR] = "RELEASEDIR";
@opcode [FUSE_FSYNCDIR] = "FSYNCDIR";
@opcode [FUSE_GETLK] = "GETLK";
@opcode [FUSE_SETLK] = "SETLK";
@opcode [FUSE_SETLKW] = "SETLKW";
@opcode [FUSE_ACCESS] = "ACCESS";
@opcode [FUSE_CREATE] = "CREATE";
@opcode [FUSE_INTERRUPT] = "INTERRUPT";
@opcode [FUSE_BMAP] = "BMAP";
@opcode [FUSE_DESTROY] = "DESTROY";
@opcode [FUSE_IOCTL] = "IOCTL";
@opcode [FUSE_POLL] = "POLL";
@opcode [FUSE_NOTIFY_REPLY] = "NOTIFY_REPLY";
@opcode [FUSE_BATCH_FORGET] = "BATCH_FORGET";
@opcode [FUSE_FALLOCATE] = "FALLOCATE";
@opcode [FUSE_READDIRPLUS] = "READDIRPLUS";
@opcode [FUSE_RENAME2] = "RENAME2";
@opcode [FUSE_LSEEK] = "LSEEK";
// XXX >= Linux x
//@opcode[FUSE_COPY_FILE_RANGE] = "COPY_FILE_RANGE";
@notify [FUSE_NOTIFY_POLL] = "NOTIFY_POLL";
@notify [FUSE_NOTIFY_INVAL_INODE] = "NOTIFY_INVAL_INODE";
@notify [FUSE_NOTIFY_INVAL_ENTRY] = "NOTIFY_INVAL_ENTRY";
@notify [FUSE_NOTIFY_STORE] = "NOTIFY_STORE";
@notify [FUSE_NOTIFY_RETRIEVE] = "NOTIFY_RETRIEVE";
@notify [FUSE_NOTIFY_DELETE] = "NOTIFY_DELETE";
}
END {
......@@ -133,7 +113,7 @@ kprobe::fuse_dev_read {
@rpending[tid,$nr] = ustack;
// fuse_dev_do_read advances `to` - fetch/remember buffer pointer before.
$to = (xiov_iter *)arg1;
$to = (struct iov_iter *)arg1;
$buf = $to->iov->iov_base;
@rbuf[tid] = $buf;
......@@ -149,7 +129,7 @@ kretprobe::fuse_dev_read {
@nread[tid] = $rr + 1;
delete(@rpending[tid,$rr]);
$h = (fuse_in_header *)@rbuf[tid];
$h = (struct fuse_in_header *)@rbuf[tid];
delete(@rbuf[tid]);
$op = @opcode[$h->opcode];
......@@ -165,9 +145,9 @@ kprobe::fuse_dev_write {
$nw = @nwrite[tid];
@wpending[tid,$nw] = ustack;
$from = (xiov_iter *)arg1;
$from = (struct iov_iter *)arg1;
$wbuf = $from->iov->iov_base;
$wh = (fuse_out_header *)$wbuf;
$wh = (struct fuse_out_header *)$wbuf;
printf("P%d %d.%d /dev/fuse <- write %s/%d_%d_w:\n", cpu, $tw/1000000, $tw%1000000, comm, tid, $nw);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment