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 #!/usr/bin/env -S bpftrace
// Copyright (C) 2019 Nexedi SA and Contributors. // Copyright (C) 2019-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // 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 // it under the terms of the GNU General Public License version 3, or (at your
...@@ -24,26 +24,6 @@ ...@@ -24,26 +24,6 @@
#include <linux/fuse.h> #include <linux/fuse.h>
#include <linux/uio.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 { BEGIN {
@tstart = nsecs; @tstart = nsecs;
...@@ -58,59 +38,59 @@ BEGIN { ...@@ -58,59 +38,59 @@ BEGIN {
//clear(@rpending); // {} (tid,#nr) -> ustack //clear(@rpending); // {} (tid,#nr) -> ustack
//clear(@wpending); // {} (tid,#nw) -> ustack //clear(@wpending); // {} (tid,#nw) -> ustack
// XXX bpftrace does not recognize enum @opcode [FUSE_LOOKUP] = "LOOKUP";
@opcode[ 1] = "LOOKUP"; @opcode [FUSE_FORGET] = "FORGET";
@opcode[ 2] = "FORGET"; @opcode [FUSE_GETATTR] = "GETATTR";
@opcode[ 3] = "GETATTR"; @opcode [FUSE_SETATTR] = "SETATTR";
@opcode[ 4] = "SETATTR"; @opcode [FUSE_READLINK] = "READLINK";
@opcode[ 5] = "READLINK"; @opcode [FUSE_SYMLINK] = "SYMLINK";
@opcode[ 6] = "SYMLINK"; @opcode [FUSE_MKNOD] = "MKNOD";
@opcode[ 8] = "MKNOD"; @opcode [FUSE_MKDIR] = "MKDIR";
@opcode[ 9] = "MKDIR"; @opcode [FUSE_UNLINK] = "UNLINK";
@opcode[10] = "UNLINK"; @opcode [FUSE_RMDIR] = "RMDIR";
@opcode[11] = "RMDIR"; @opcode [FUSE_RENAME] = "RENAME";
@opcode[12] = "RENAME"; @opcode [FUSE_LINK] = "LINK";
@opcode[13] = "LINK"; @opcode [FUSE_OPEN] = "OPEN";
@opcode[14] = "OPEN"; @opcode [FUSE_READ] = "READ";
@opcode[15] = "READ"; @opcode [FUSE_WRITE] = "WRITE";
@opcode[16] = "WRITE"; @opcode [FUSE_STATFS] = "STATFS";
@opcode[17] = "STATFS"; @opcode [FUSE_RELEASE] = "RELEASE";
@opcode[18] = "RELEASE"; @opcode [FUSE_FSYNC] = "FSYNC";
@opcode[20] = "FSYNC"; @opcode [FUSE_SETXATTR] = "SETXATTR";
@opcode[21] = "SETXATTR"; @opcode [FUSE_GETXATTR] = "GETXATTR";
@opcode[22] = "GETXATTR"; @opcode [FUSE_LISTXATTR] = "LISTXATTR";
@opcode[23] = "LISTXATTR"; @opcode [FUSE_REMOVEXATTR] = "REMOVEXATTR";
@opcode[24] = "REMOVEXATTR"; @opcode [FUSE_FLUSH] = "FLUSH";
@opcode[25] = "FLUSH"; @opcode [FUSE_INIT] = "INIT";
@opcode[26] = "INIT"; @opcode [FUSE_OPENDIR] = "OPENDIR";
@opcode[27] = "OPENDIR"; @opcode [FUSE_READDIR] = "READDIR";
@opcode[28] = "READDIR"; @opcode [FUSE_RELEASEDIR] = "RELEASEDIR";
@opcode[29] = "RELEASEDIR"; @opcode [FUSE_FSYNCDIR] = "FSYNCDIR";
@opcode[30] = "FSYNCDIR"; @opcode [FUSE_GETLK] = "GETLK";
@opcode[31] = "GETLK"; @opcode [FUSE_SETLK] = "SETLK";
@opcode[32] = "SETLK"; @opcode [FUSE_SETLKW] = "SETLKW";
@opcode[33] = "SETLKW"; @opcode [FUSE_ACCESS] = "ACCESS";
@opcode[34] = "ACCESS"; @opcode [FUSE_CREATE] = "CREATE";
@opcode[35] = "CREATE"; @opcode [FUSE_INTERRUPT] = "INTERRUPT";
@opcode[36] = "INTERRUPT"; @opcode [FUSE_BMAP] = "BMAP";
@opcode[37] = "BMAP"; @opcode [FUSE_DESTROY] = "DESTROY";
@opcode[38] = "DESTROY"; @opcode [FUSE_IOCTL] = "IOCTL";
@opcode[39] = "IOCTL"; @opcode [FUSE_POLL] = "POLL";
@opcode[40] = "POLL"; @opcode [FUSE_NOTIFY_REPLY] = "NOTIFY_REPLY";
@opcode[41] = "NOTIFY_REPLY"; @opcode [FUSE_BATCH_FORGET] = "BATCH_FORGET";
@opcode[42] = "BATCH_FORGET"; @opcode [FUSE_FALLOCATE] = "FALLOCATE";
@opcode[43] = "FALLOCATE"; @opcode [FUSE_READDIRPLUS] = "READDIRPLUS";
@opcode[44] = "READDIRPLUS"; @opcode [FUSE_RENAME2] = "RENAME2";
@opcode[45] = "RENAME2"; @opcode [FUSE_LSEEK] = "LSEEK";
@opcode[46] = "LSEEK"; // XXX >= Linux x
@opcode[47] = "COPY_FILE_RANGE"; //@opcode[FUSE_COPY_FILE_RANGE] = "COPY_FILE_RANGE";
@notify[1] = "NOTIFY_POLL"; @notify [FUSE_NOTIFY_POLL] = "NOTIFY_POLL";
@notify[2] = "NOTIFY_INVAL_INODE"; @notify [FUSE_NOTIFY_INVAL_INODE] = "NOTIFY_INVAL_INODE";
@notify[3] = "NOTIFY_INVAL_ENTRY"; @notify [FUSE_NOTIFY_INVAL_ENTRY] = "NOTIFY_INVAL_ENTRY";
@notify[4] = "NOTIFY_STORE"; @notify [FUSE_NOTIFY_STORE] = "NOTIFY_STORE";
@notify[5] = "NOTIFY_RETRIEVE"; @notify [FUSE_NOTIFY_RETRIEVE] = "NOTIFY_RETRIEVE";
@notify[6] = "NOTIFY_DELETE"; @notify [FUSE_NOTIFY_DELETE] = "NOTIFY_DELETE";
} }
END { END {
...@@ -133,7 +113,7 @@ kprobe::fuse_dev_read { ...@@ -133,7 +113,7 @@ kprobe::fuse_dev_read {
@rpending[tid,$nr] = ustack; @rpending[tid,$nr] = ustack;
// fuse_dev_do_read advances `to` - fetch/remember buffer pointer before. // 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; $buf = $to->iov->iov_base;
@rbuf[tid] = $buf; @rbuf[tid] = $buf;
...@@ -149,7 +129,7 @@ kretprobe::fuse_dev_read { ...@@ -149,7 +129,7 @@ kretprobe::fuse_dev_read {
@nread[tid] = $rr + 1; @nread[tid] = $rr + 1;
delete(@rpending[tid,$rr]); delete(@rpending[tid,$rr]);
$h = (fuse_in_header *)@rbuf[tid]; $h = (struct fuse_in_header *)@rbuf[tid];
delete(@rbuf[tid]); delete(@rbuf[tid]);
$op = @opcode[$h->opcode]; $op = @opcode[$h->opcode];
...@@ -165,9 +145,9 @@ kprobe::fuse_dev_write { ...@@ -165,9 +145,9 @@ kprobe::fuse_dev_write {
$nw = @nwrite[tid]; $nw = @nwrite[tid];
@wpending[tid,$nw] = ustack; @wpending[tid,$nw] = ustack;
$from = (xiov_iter *)arg1; $from = (struct iov_iter *)arg1;
$wbuf = $from->iov->iov_base; $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); 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