Skip to content

Commit 64a42f3

Browse files
committed
Add support for fuse to fsdist and fsslower tools
1 parent c351210 commit 64a42f3

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

libbpf-tools/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
/ext4slower
2424
/f2fsdist
2525
/f2fsslower
26+
/fusedist
27+
/fuseslower
2628
/filelife
2729
/filetop
2830
/fsdist

libbpf-tools/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ APPS = \
100100
# export variables that are used in Makefile.btfgen as well.
101101
export OUTPUT BPFTOOL ARCH BTFHUB_ARCHIVE APPS
102102

103-
FSDIST_ALIASES = btrfsdist ext4dist nfsdist xfsdist f2fsdist bcachefsdist zfsdist
104-
FSSLOWER_ALIASES = btrfsslower ext4slower nfsslower xfsslower f2fsslower bcachefsslower zfsslower
103+
FSDIST_ALIASES = btrfsdist ext4dist fusedist nfsdist xfsdist f2fsdist bcachefsdist zfsdist
104+
FSSLOWER_ALIASES = btrfsslower ext4slower fuseslower nfsslower xfsslower f2fsslower bcachefsslower zfsslower
105105
SIGSNOOP_ALIAS = killsnoop
106106
APP_ALIASES = $(FSDIST_ALIASES) $(FSSLOWER_ALIASES) ${SIGSNOOP_ALIAS}
107107

libbpf-tools/fsdist.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ enum fs_type {
3939
F2FS,
4040
BCACHEFS,
4141
ZFS,
42+
FUSE,
4243
};
4344

4445
static struct fs_config {
@@ -94,6 +95,13 @@ static struct fs_config {
9495
[F_FSYNC] = "zpl_fsync",
9596
[F_GETATTR] = NULL, /* not supported */
9697
}},
98+
[FUSE] = { "fuse", {
99+
[F_READ] = "fuse_file_read_iter",
100+
[F_WRITE] = "fuse_file_write_iter",
101+
[F_OPEN] = "fuse_open",
102+
[F_FSYNC] = "fuse_fsync",
103+
[F_GETATTR] = "fuse_getattr",
104+
}},
97105
};
98106

99107
static char *file_op_names[] = {
@@ -134,7 +142,7 @@ static const struct argp_option opts[] = {
134142
{ "timestamp", 'T', NULL, 0, "Print timestamp", 0 },
135143
{ "milliseconds", 'm', NULL, 0, "Millisecond histogram", 0 },
136144
{ "pid", 'p', "PID", 0, "Process ID to trace", 0 },
137-
{ "type", 't', "Filesystem", 0, "Which filesystem to trace, [btrfs/ext4/nfs/xfs/f2fs/bcachefs/zfs]", 0 },
145+
{ "type", 't', "Filesystem", 0, "Which filesystem to trace, [btrfs/ext4/nfs/xfs/f2fs/bcachefs/zfs/fuse]", 0 },
138146
{ "verbose", 'v', NULL, 0, "Verbose debug output", 0 },
139147
{ NULL, 'h', NULL, OPTION_HIDDEN, "Show the full help", 0 },
140148
{},
@@ -169,6 +177,8 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state)
169177
fs_type = BCACHEFS;
170178
} else if (!strcmp(arg, "zfs")) {
171179
fs_type = ZFS;
180+
} else if (!strcmp(arg, "fuse")) {
181+
fs_type = FUSE;
172182
} else {
173183
warn("invalid filesystem\n");
174184
argp_usage(state);
@@ -229,6 +239,8 @@ static void alias_parse(char *prog)
229239
fs_type = BCACHEFS;
230240
} else if (strstr(name, "zfsdist")) {
231241
fs_type = ZFS;
242+
} else if (strstr(name, "fusedist")) {
243+
fs_type = FUSE;
232244
}
233245
}
234246

libbpf-tools/fsslower.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ enum fs_type {
4242
F2FS,
4343
BCACHEFS,
4444
ZFS,
45+
FUSE,
4546
};
4647

4748
static struct fs_config {
@@ -90,6 +91,12 @@ static struct fs_config {
9091
[F_OPEN] = "zpl_open",
9192
[F_FSYNC] = "zpl_fsync",
9293
}},
94+
[FUSE] = { "fuse", {
95+
[F_READ] = "fuse_file_read_iter",
96+
[F_WRITE] = "fuse_file_write_iter",
97+
[F_OPEN] = "fuse_open",
98+
[F_FSYNC] = "fuse_fsync",
99+
}},
93100
};
94101

95102
static char file_op[] = {
@@ -127,7 +134,7 @@ static const struct argp_option opts[] = {
127134
{ "duration", 'd', "DURATION", 0, "Total duration of trace in seconds", 0 },
128135
{ "pid", 'p', "PID", 0, "Process ID to trace", 0 },
129136
{ "min", 'm', "MIN", 0, "Min latency to trace, in ms (default 10)", 0 },
130-
{ "type", 't', "Filesystem", 0, "Which filesystem to trace, [btrfs/ext4/nfs/xfs/f2fs/bcachefs/zfs]", 0 },
137+
{ "type", 't', "Filesystem", 0, "Which filesystem to trace, [btrfs/ext4/nfs/xfs/f2fs/bcachefs/zfs/fuse]", 0 },
131138
{ "verbose", 'v', NULL, 0, "Verbose debug output", 0 },
132139
{ NULL, 'h', NULL, OPTION_HIDDEN, "Show the full help", 0 },
133140
{},
@@ -172,6 +179,8 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state)
172179
fs_type = BCACHEFS;
173180
} else if (!strcmp(arg, "zfs")) {
174181
fs_type = ZFS;
182+
} else if (!strcmp(arg, "fuse")) {
183+
fs_type = FUSE;
175184
} else {
176185
warn("invalid filesystem\n");
177186
argp_usage(state);
@@ -212,6 +221,8 @@ static void alias_parse(char *prog)
212221
fs_type = BCACHEFS;
213222
} else if (!strcmp(name, "zfsslower")) {
214223
fs_type = ZFS;
224+
} else if (!strcmp(name, "fuseslower")) {
225+
fs_type = FUSE;
215226
}
216227
}
217228

0 commit comments

Comments
 (0)