@@ -22,49 +22,19 @@ typedef struct {
2222// Map of thread id to info about an in-progress IO
2323BPF_HASH (io_info_map , u32 , io_info_t );
2424
25- #ifndef OPTARG
26- #define POOL "domain0"
27- #else
28- #define POOL (OPTARG)
29- #endif
3025#define ZFS_READ_SYNC_LENGTH 14
3126#define ZFS_READ_ASYNC_LENGTH 15
3227#define ZFS_WRITE_SYNC_LENGTH 15
3328#define ZFS_WRITE_ASYNC_LENGTH 16
3429
35- // TODO factor this out into a helper so that it isn't duplicated
36- static inline bool
37- equal_to_pool (char * str )
38- {
39- char comparand [sizeof (POOL )];
40- bpf_probe_read (& comparand , sizeof (comparand ), str );
41- char compare [] = POOL ;
42- for (int i = 0 ; i < sizeof (comparand ); ++ i )
43- if (compare [i ] != comparand [i ])
44- return (false);
45- return (true);
46- }
47-
4830static inline int
4931zfs_read_write_entry (io_info_t * info , struct znode * zn , zfs_uio_t * uio , int flags )
5032{
51- // Essentially ITOZSB, but written explicitly so that BCC can insert
52- // the necessary calls to bpf_probe_read.
53- zfsvfs_t * zfsvfs = zn -> z_inode .i_sb -> s_fs_info ;
54-
55- objset_t * z_os = zfsvfs -> z_os ;
56- spa_t * spa = z_os -> os_spa ;
57-
58- if (!equal_to_pool (spa -> spa_name ))
59- return (0 );
60-
6133 info -> start_time = bpf_ktime_get_ns ();
6234 info -> bytes = uio -> uio_resid ;
63- info -> is_sync =
64- z_os -> os_sync == ZFS_SYNC_ALWAYS || (flags & (O_SYNC | O_DSYNC ));
35+ info -> is_sync = (flags & (O_SYNC | O_DSYNC ));
6536
6637 u32 tid = bpf_get_current_pid_tgid ();
67- io_info_t * infop = io_info_map .lookup (& tid );
6838 io_info_map .update (& tid , info );
6939
7040 return (0 );
@@ -91,7 +61,7 @@ zfs_write_entry(struct pt_regs *ctx, struct znode *zn, zfs_uio_t *uio, int flags
9161// @@ kretprobe|zfs_read|zfs_read_write_exit
9262// @@ kretprobe|zfs_write|zfs_read_write_exit
9363int
94- zfs_read_write_exit (struct pt_regs * ctx , struct znode * zn , zfs_uio_t * uio )
64+ zfs_read_write_exit (struct pt_regs * ctx )
9565{
9666 u32 tid = bpf_get_current_pid_tgid ();
9767 io_info_t * info = io_info_map .lookup (& tid );
@@ -110,11 +80,7 @@ zfs_read_write_exit(struct pt_regs *ctx, struct znode *zn, zfs_uio_t *uio)
11080 __builtin_memcpy (name , "zfs_write async" , ZFS_WRITE_ASYNC_LENGTH );
11181 }
11282 } else {
113- if (info -> is_sync ) {
114- __builtin_memcpy (name , "zfs_read sync" , ZFS_READ_SYNC_LENGTH );
115- } else {
116- __builtin_memcpy (name , "zfs_read async" , ZFS_READ_ASYNC_LENGTH );
117- }
83+ __builtin_memcpy (name , "zfs_read" , ZFS_READ_SYNC_LENGTH );
11884 }
11985
12086 char axis = 0 ;
0 commit comments