Skip to content
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

unknown type name 'xfs_ino_t' #2094

Closed
Rtoax opened this issue Dec 21, 2021 · 5 comments
Closed

unknown type name 'xfs_ino_t' #2094

Rtoax opened this issue Dec 21, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@Rtoax
Copy link
Contributor

Rtoax commented Dec 21, 2021

What reproduces the bug?

when i execute the following bpftrace scription:

#!/usr/bin/env bpftrace

/**
 *	fs/xfs/xfs_linux.h 
 *
 *	See https://github.com/iovisor/bpftrace/issues/2094
 */
//typedef unsigned long long	xfs_ino_t;

BEGIN
{
	printf("Tracing XFS calls... Hit Ctrl-C to end.\n");
}

tracepoint:xfs:xfs_setfilesize
{
	$offset = args->offset;
	$size = args->size;
	printf("%-8d %-16s %-8d %-8d \n", pid, comm, $offset, $size);
}

END
{
	printf("Bye.\n");
}

get

$ sudo ./xfs_setfilesize-tp.bt
definitions.h:13:3: error: unknown type name 'xfs_ino_t'
ERROR: Include headers with missing type definitions or install BTF information to your system.

bpftrace --info

$ sudo bpftrace --info
System
  OS: Linux 5.14.0 #7 SMP Thu Nov 11 15:15:29 CST 2021
  Arch: x86_64

Build
  version: v0.14.0-13-gd431-dirty
  LLVM: 12.0.1
  ORC: v2
  foreach_sym: yes
  unsafe uprobe: no
  bfd: yes
  bpf_attach_kfunc: yes
  bcc_usdt_addsem: yes
  bcc bpf_attach_uprobe refcount: yes
  bcc library path resolution: yes
  libbpf: yes
  libbpf btf dump: yes
  libbpf btf dump type decl: yes
  libdw (DWARF support): yes

Kernel helpers
  probe_read: yes
  probe_read_str: yes
  probe_read_user: yes
  probe_read_user_str: yes
  probe_read_kernel: yes
  probe_read_kernel_str: yes
  get_current_cgroup_id: yes
  send_signal: yes
  override_return: no
  get_boot_ns: yes
  dpath: yes

Kernel features
  Instruction limit: 1000000
  Loop support: yes
  btf (depends on Build:libbpf): yes
  map batch (depends on Build:libbpf): yes
  uprobe refcount (depends on Build:bcc bpf_attach_uprobe refcount): yes

Map types
  hash: yes
  percpu hash: yes
  array: yes
  percpu array: yes
  stack_trace: yes
  perf_event_array: yes

Probe types
  kprobe: yes
  tracepoint: yes
  perf_event: yes
  kfunc: yes
  iter:task: yes
  iter:task_file: yes
@Rtoax Rtoax added the bug Something isn't working label Dec 21, 2021
@fbs
Copy link
Contributor

fbs commented Dec 24, 2021

Did you try #include <fs/xfs/xfs_linux.h> or what ever the correct import is?

@viktormalik
Copy link
Contributor

fs/xfs/xfs_linux.h is an internal kernel header, so bpftrace won't find it. A possible way would be to install the XFS development package (xfsprogs-devel on Fedora) and then include xfs/linux.h which contains a user-space definition of xfs_ino_t.

Unfortunately, that won't currently work either as the file includes stdbool.h which we don't have, yet (that should be easy to fix, though).

@StingerXIII
Copy link

I used to include a custom header file with typedef uint64_t xfs_ino_t; as a crutch. At least this allows you to use the tracepoint.

@viktormalik
Copy link
Contributor

I investigated this issue a bit more. Since xfs_ino_t is defined in an internal header, it cannot be included from a bpftrace script.

On the other hand, it should be possible to pull the type definition from BTF. The problem is that xfs is usually loaded as a kernel module and BTF for modules is not supported for tracepoints at the moment. I tried to implement it in #2479 so it would be great if you could give it a try.

I tried to run the above script but it didn't work since the tracepoint doesn't seem to have the size parameter:

# bpftrace -lv 'tracepoint:xfs:xfs_setfilesize'
tracepoint:xfs:xfs_setfilesize
    dev_t dev
    xfs_ino_t ino
    loff_t isize
    loff_t disize
    loff_t offset
    size_t count

When using count instead of size, I was able to run the script.

Btw. the script would also work if you replaced the tracepoint by kfunc:xfs_setfilesize.

@viktormalik
Copy link
Contributor

Fixed by #2479.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants