Skip to content

Backport of estat updates for 6.0.7.0 #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions bpf/estat/iscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

typedef struct {
u64 ts;
u64 flags;
u64 size;
} iscsi_data_t;

Expand All @@ -33,7 +32,6 @@ iscsi_target_start(struct pt_regs *ctx, struct iscsi_conn *conn,
{
iscsi_data_t data = {};
data.ts = bpf_ktime_get_ns();
data.flags = hdr->flags;
data.size = hdr->data_length;
iscsi_base_data.update((u64 *) &cmd, &data);

Expand All @@ -56,6 +54,7 @@ aggregate_data(iscsi_data_t *data, u64 ts, char *opstr)
}

// @@ kprobe|iscsit_build_rsp_pdu|iscsi_target_end
// @@ kprobe|iscsit_build_datain_pdu|iscsi_target_end
int
iscsi_target_end(struct pt_regs *ctx, struct iscsi_cmd *cmd)
{
Expand All @@ -67,9 +66,9 @@ iscsi_target_end(struct pt_regs *ctx, struct iscsi_cmd *cmd)
return (0); // missed issue
}

if (data->flags & ISCSI_FLAG_CMD_READ) {
if (cmd->data_direction == DMA_FROM_DEVICE) {
aggregate_data(data, ts, READ_STR);
} else if (data->flags & ISCSI_FLAG_CMD_WRITE) {
} else if (cmd->data_direction & DMA_TO_DEVICE) {
aggregate_data(data, ts, WRITE_STR);
}
iscsi_base_data.delete((u64 *) &cmd);
Expand Down
30 changes: 15 additions & 15 deletions bpf/estat/zpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ BPF_HASH(io_info_map, u32, io_info_t);
#else
#define POOL (OPTARG)
#endif
#define ZFS_READ_SYNC_LENGTH 14
#define ZFS_READ_ASYNC_LENGTH 15
#define ZFS_WRITE_SYNC_LENGTH 15
#define ZFS_WRITE_ASYNC_LENGTH 16

// TODO factor this out into a helper so that it isn't duplicated
static inline bool
Expand Down Expand Up @@ -97,24 +101,20 @@ zfs_read_write_exit(struct pt_regs *ctx, struct inode *ip, uio_t *uio)

u64 delta = bpf_ktime_get_ns() - info->start_time;

char name[32];
char name[16];
int offset;
if (info->is_write) {
const char s[] = "zfs_write";
__builtin_memcpy(&name, s, sizeof (s));
offset = sizeof (s) - 1;
if (info->is_sync) {
__builtin_memcpy(name, "zfs_write sync", ZFS_WRITE_SYNC_LENGTH);
} else {
__builtin_memcpy(name, "zfs_write async", ZFS_WRITE_ASYNC_LENGTH);
}
} else {
const char s[] = "zfs_read";
__builtin_memcpy(&name, s, sizeof (s));
offset = sizeof (s) - 1;
}

if (info->is_sync) {
const char s[] = " sync";
__builtin_memcpy(name + offset, s, sizeof (s));
} else {
const char s[] = " async";
__builtin_memcpy(name + offset, s, sizeof (s));
if (info->is_sync) {
__builtin_memcpy(name, "zfs_read sync", ZFS_READ_SYNC_LENGTH);
} else {
__builtin_memcpy(name, "zfs_read async", ZFS_READ_ASYNC_LENGTH);
}
}

char axis = 0;
Expand Down
37 changes: 7 additions & 30 deletions bpf/estat/zvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,26 @@
#include <sys/zil_impl.h>
#include <sys/zfs_rlock.h>
#include <sys/spa_impl.h>
#include <sys/zvol.h>
#include <sys/dataset_kstats.h>
#include <sys/zvol_impl.h>


#define ZVOL_WCE 0x8
#define ZVOL_READ 1
#define ZVOL_WRITE 2
#define NAME_LENGTH 6
#define AXIS_LENGTH 5
#define AXIS_LENGTH 6
#define READ_LENGTH 5
#define WRITE_LENGTH 6
#define SYNC_LENGTH 5
#define ASYNC_LENGTH 6

#ifndef OPTARG
#define POOL "domain0"
#else
#define POOL (OPTARG)
#endif

/*
* Copied and duplicated from "module/zfs/zvol.c" of the ZFS repository.
*/
typedef struct zvol_state {
char zv_name[MAXNAMELEN]; /* name */
uint64_t zv_volsize; /* advertised space */
uint64_t zv_volblocksize; /* volume block size */
objset_t *zv_objset; /* objset handle */
uint32_t zv_flags; /* ZVOL_* flags */
uint32_t zv_open_count; /* open counts */
uint32_t zv_changed; /* disk changed */
zilog_t *zv_zilog; /* ZIL handle */
rangelock_t zv_rangelock; /* for range locking */
dnode_t *zv_dn; /* dnode hold */
dev_t zv_dev; /* device id */
struct gendisk *zv_disk; /* generic disk */
struct request_queue *zv_queue; /* request queue */
dataset_kstats_t zv_kstat; /* zvol kstats */
list_node_t zv_next; /* next zvol_state_t linkage */
uint64_t zv_hash; /* name hash */
struct hlist_node zv_hlink; /* hash link */
kmutex_t zv_state_lock; /* protects zvol_state_t */
atomic_t zv_suspend_ref; /* refcount for suspend */
krwlock_t zv_suspend_lock; /* suspend lock */
} zvol_state_t;

// Structure to hold thread local data
typedef struct {
u64 ts;
Expand Down Expand Up @@ -141,10 +118,10 @@ zvol_return(struct pt_regs *ctx)
__builtin_memcpy(&name, "read", READ_LENGTH);
} else if (sync) {
__builtin_memcpy(&name, "write", WRITE_LENGTH);
__builtin_memcpy(&axis, "sync", WRITE_LENGTH);
__builtin_memcpy(&axis, "sync", SYNC_LENGTH);
} else {
__builtin_memcpy(&name, "write", WRITE_LENGTH);
__builtin_memcpy(&axis, "async", WRITE_LENGTH);
__builtin_memcpy(&axis, "async", ASYNC_LENGTH);
}
AGGREGATE_DATA(name, axis, delta, data->bytes);
zvol_base_data.delete(&pid);
Expand Down
1 change: 0 additions & 1 deletion bpf/standalone/arc_prefetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ class ArcLatencyIndex(BCCMapIndex):
"-I/usr/src/zfs-" + KVER + "/include/",
"-I/usr/src/zfs-" + KVER + "/include/spl/",
"-I/usr/src/zfs-" + KVER + "/include/linux",
"-DCC_USING_FENTRY",
"-DNCOUNT_INDEX=" + str(len(ArcCountIndex)),
"-DNAVERAGE_INDEX=" + str(len(ArcLatencyIndex))] \
+ ArcCountIndex.getCDefinitions() \
Expand Down
3 changes: 1 addition & 2 deletions bpf/standalone/txg.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ def print_event(cpu, data, size):
"-I/usr/src/zfs-" + KVER + "/include/",
"-I/usr/src/zfs-" + KVER + "/include/spl",
"-I/usr/src/zfs-" + KVER + "/include/",
"-I/usr/src/zfs-" + KVER + "/include/linux",
"-DCC_USING_FENTRY"])
"-I/usr/src/zfs-" + KVER + "/include/linux"])

b.attach_kprobe(event="spa_sync", fn_name="spa_sync_entry")
b.attach_kretprobe(event="spa_sync", fn_name="spa_sync_return")
Expand Down
3 changes: 1 addition & 2 deletions bpf/stbtrace/zio.st
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ b = BPF(text=bpf_text, cflags=["-include",
"/usr/src/zfs-" + KVER + "/zfs_config.h",
"-I/usr/src/zfs-" + KVER + "/include/",
"-I/usr/src/zfs-" + KVER + "/include/spl/",
"-I/usr/src/zfs-" + KVER + "/include/linux",
"-DCC_USING_FENTRY"])
"-I/usr/src/zfs-" + KVER + "/include/linux"])

b.attach_kretprobe(event="vdev_queue_io_to_issue",
fn_name="vdev_queue_issue_return")
Expand Down
3 changes: 1 addition & 2 deletions bpf/stbtrace/zpl.st
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ b = BPF(text=bpf_text,
"-include",
"/usr/src/zfs-" + KVER + "/include/spl/sys/types.h",
"-I/usr/src/zfs-" + KVER + "/include/",
"-I/usr/src/zfs-" + KVER + "/include/spl/",
"-DCC_USING_FENTRY"])
"-I/usr/src/zfs-" + KVER + "/include/spl/"])

b.attach_kprobe(event="zfs_read", fn_name="zfs_read_start")
b.attach_kprobe(event="zfs_write", fn_name="zfs_write_start")
Expand Down
3 changes: 1 addition & 2 deletions cmd/estat.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,7 @@ class Args:
"-include",
"/usr/src/zfs-" + KVER + "/include/spl/sys/types.h",
"-I/usr/src/zfs-" + KVER + "/include/",
"-I/usr/src/zfs-" + KVER + "/include/spl",
"-DCC_USING_FENTRY"]
"-I/usr/src/zfs-" + KVER + "/include/spl"]
if script_arg:
cflags.append("-DOPTARG=\"" + script_arg + "\"")

Expand Down