From cdc932399a70c9c05078f60996d732a0304451e9 Mon Sep 17 00:00:00 2001 From: shangfan <45649554+sf1999817@users.noreply.github.com> Date: Thu, 5 Sep 2024 08:47:26 +0000 Subject: [PATCH] add block_rq_issue --- .../Filesystem_Subsystem/fs_watcher/block_rq_issue.bpf.c | 2 +- .../Filesystem_Subsystem/fs_watcher/block_rq_issue.c | 1 - .../Filesystem_Subsystem/fs_watcher/block_rq_issue.h | 1 - .../Filesystem_Subsystem/fs_watcher/disk_io_visit.bpf.c | 2 +- eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/fs_watcher.c | 1 - .../Filesystem_Subsystem/fs_watcher/include/fs_watcher.h | 4 ++-- 6 files changed, 4 insertions(+), 7 deletions(-) diff --git a/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/block_rq_issue.bpf.c b/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/block_rq_issue.bpf.c index 039d18b83..192e9ed79 100644 --- a/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/block_rq_issue.bpf.c +++ b/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/block_rq_issue.bpf.c @@ -12,7 +12,7 @@ struct { __uint(max_entries, 256 * 1024); } rb SEC(".maps"); -// Tracepoint 处理程序 +// 这里挂载点必须是struct trace_event_raw_block_rq_completion *ctx SEC("tracepoint/block/block_rq_issue") int tracepoint_block_rq_issue(struct trace_event_raw_block_rq_completion *ctx) { struct event *e; diff --git a/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/block_rq_issue.c b/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/block_rq_issue.c index f8a48527b..bede3f552 100644 --- a/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/block_rq_issue.c +++ b/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/block_rq_issue.c @@ -4,7 +4,6 @@ #include #include "block_rq_issue.h" #include "block_rq_issue.skel.h" -#include // For PRIu64 static int libbpf_print_fn(enum libbpf_print_level level, const char *format, va_list args) { diff --git a/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/block_rq_issue.h b/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/block_rq_issue.h index 90b8cb7d4..229e9ba88 100644 --- a/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/block_rq_issue.h +++ b/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/block_rq_issue.h @@ -3,7 +3,6 @@ #define TASK_COMM_LEN 256 -// 定义事件结构体 struct event { long timestamp; // 时间戳 int dev; // 设备号 diff --git a/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/disk_io_visit.bpf.c b/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/disk_io_visit.bpf.c index 18fc48ed0..8aa7b4aa9 100644 --- a/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/disk_io_visit.bpf.c +++ b/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/disk_io_visit.bpf.c @@ -20,7 +20,7 @@ struct { __type(value, u32); } io_count_map SEC(".maps"); -// Tracepoint 处理程序 +// 这里挂载点得是这个struct trace_event_raw_block_rq_completion *ctx SEC("tracepoint/block/block_rq_complete") int tracepoint_block_visit(struct trace_event_raw_block_rq_completion *ctx) { struct event *e; diff --git a/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/fs_watcher.c b/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/fs_watcher.c index 74ec679d5..fe36747f4 100644 --- a/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/fs_watcher.c +++ b/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/fs_watcher.c @@ -229,7 +229,6 @@ static int handle_event_open(void *ctx, void *data, size_t data_sz) int i = 0; int map_fd = *(int *)ctx;//传递map得文件描述符 - for (; i < e->n_; ++i) { snprintf(fd_path, sizeof(fd_path), "/proc/%d/fd/%d", e->pid_, i); diff --git a/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/include/fs_watcher.h b/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/include/fs_watcher.h index c4f01a662..da78cc0dd 100644 --- a/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/include/fs_watcher.h +++ b/eBPF_Supermarket/Filesystem_Subsystem/fs_watcher/include/fs_watcher.h @@ -1,11 +1,11 @@ #ifndef __FS_WATCHER_H #define __FS_WATCHER_H -/*open*/ + #define path_size 256 #define TASK_COMM_LEN 256 - +/*open*/ struct event_open { int pid_; char path_name_[path_size];