Skip to content

Commit

Permalink
Add support for zfs to fsdist and fsslower tools
Browse files Browse the repository at this point in the history
Add zfs based on zfsdist.py and zfsslower.py.

Signed-off-by: Feng Yang <[email protected]>
  • Loading branch information
Feng Yang authored and yonghong-song committed Oct 30, 2024
1 parent 0d5dcf4 commit d36ab45
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
2 changes: 2 additions & 0 deletions libbpf-tools/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@
/wakeuptime
/xfsdist
/xfsslower
/zfsdist
/zfsslower
4 changes: 2 additions & 2 deletions libbpf-tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ APPS = \
# export variables that are used in Makefile.btfgen as well.
export OUTPUT BPFTOOL ARCH BTFHUB_ARCHIVE APPS

FSDIST_ALIASES = btrfsdist ext4dist nfsdist xfsdist f2fsdist bcachefsdist
FSSLOWER_ALIASES = btrfsslower ext4slower nfsslower xfsslower f2fsslower bcachefsslower
FSDIST_ALIASES = btrfsdist ext4dist nfsdist xfsdist f2fsdist bcachefsdist zfsdist
FSSLOWER_ALIASES = btrfsslower ext4slower nfsslower xfsslower f2fsslower bcachefsslower zfsslower
SIGSNOOP_ALIAS = killsnoop
APP_ALIASES = $(FSDIST_ALIASES) $(FSSLOWER_ALIASES) ${SIGSNOOP_ALIAS}

Expand Down
14 changes: 13 additions & 1 deletion libbpf-tools/fsdist.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum fs_type {
XFS,
F2FS,
BCACHEFS,
ZFS,
};

static struct fs_config {
Expand Down Expand Up @@ -86,6 +87,13 @@ static struct fs_config {
[F_FSYNC] = "bch2_fsync",
[F_GETATTR] = "bch2_getattr",
}},
[ZFS] = { "zfs", {
[F_READ] = "zpl_iter_read",
[F_WRITE] = "zpl_iter_write",
[F_OPEN] = "zpl_open",
[F_FSYNC] = "zpl_fsync",
[F_GETATTR] = NULL, /* not supported */
}},
};

static char *file_op_names[] = {
Expand Down Expand Up @@ -126,7 +134,7 @@ static const struct argp_option opts[] = {
{ "timestamp", 'T', NULL, 0, "Print timestamp", 0 },
{ "milliseconds", 'm', NULL, 0, "Millisecond histogram", 0 },
{ "pid", 'p', "PID", 0, "Process ID to trace", 0 },
{ "type", 't', "Filesystem", 0, "Which filesystem to trace, [btrfs/ext4/nfs/xfs/f2fs/bcachefs]", 0 },
{ "type", 't', "Filesystem", 0, "Which filesystem to trace, [btrfs/ext4/nfs/xfs/f2fs/bcachefs/zfs]", 0 },
{ "verbose", 'v', NULL, 0, "Verbose debug output", 0 },
{ NULL, 'h', NULL, OPTION_HIDDEN, "Show the full help", 0 },
{},
Expand Down Expand Up @@ -159,6 +167,8 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state)
fs_type = F2FS;
} else if (!strcmp(arg, "bcachefs")) {
fs_type = BCACHEFS;
} else if (!strcmp(arg, "zfs")) {
fs_type = ZFS;
} else {
warn("invalid filesystem\n");
argp_usage(state);
Expand Down Expand Up @@ -217,6 +227,8 @@ static void alias_parse(char *prog)
fs_type = F2FS;
} else if (strstr(name, "bcachefsdist")){
fs_type = BCACHEFS;
} else if (strstr(name, "zfsdist")) {
fs_type = ZFS;
}
}

Expand Down
13 changes: 12 additions & 1 deletion libbpf-tools/fsslower.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum fs_type {
XFS,
F2FS,
BCACHEFS,
ZFS,
};

static struct fs_config {
Expand Down Expand Up @@ -83,6 +84,12 @@ static struct fs_config {
[F_OPEN] = "bch2_open",
[F_FSYNC] = "bch2_fsync",
}},
[ZFS] = { "zfs", {
[F_READ] = "zpl_iter_read",
[F_WRITE] = "zpl_iter_write",
[F_OPEN] = "zpl_open",
[F_FSYNC] = "zpl_fsync",
}},
};

static char file_op[] = {
Expand Down Expand Up @@ -120,7 +127,7 @@ static const struct argp_option opts[] = {
{ "duration", 'd', "DURATION", 0, "Total duration of trace in seconds", 0 },
{ "pid", 'p', "PID", 0, "Process ID to trace", 0 },
{ "min", 'm', "MIN", 0, "Min latency to trace, in ms (default 10)", 0 },
{ "type", 't', "Filesystem", 0, "Which filesystem to trace, [btrfs/ext4/nfs/xfs/f2fs/bcachefs]", 0 },
{ "type", 't', "Filesystem", 0, "Which filesystem to trace, [btrfs/ext4/nfs/xfs/f2fs/bcachefs/zfs]", 0 },
{ "verbose", 'v', NULL, 0, "Verbose debug output", 0 },
{ NULL, 'h', NULL, OPTION_HIDDEN, "Show the full help", 0 },
{},
Expand Down Expand Up @@ -163,6 +170,8 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state)
fs_type = F2FS;
} else if (!strcmp(arg, "bcachefs")) {
fs_type = BCACHEFS;
} else if (!strcmp(arg, "zfs")) {
fs_type = ZFS;
} else {
warn("invalid filesystem\n");
argp_usage(state);
Expand Down Expand Up @@ -201,6 +210,8 @@ static void alias_parse(char *prog)
fs_type = F2FS;
} else if (strstr(name, "bcachefsslower")){
fs_type = BCACHEFS;
} else if (!strcmp(name, "zfsslower")) {
fs_type = ZFS;
}
}

Expand Down

0 comments on commit d36ab45

Please sign in to comment.