[RFC PATCH bpf-next 0/4] Introduce bpf iterators for file-system

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Hou Tao <houtao1@xxxxxxxxxx>

Hi,

The patchset is in a hurry and far from complete, but it is better to
provide some code/demo first for disussion in LSF/MM/BPF.

The patchset attempts to provide more observability for the file-system
as proposed in [0]. Compared to drgn [1], the bpf iterator for file-system
has fewer dependencies (e.g., no need for vmlinux) and more accurate
results.

Two types of file-system iterator are provided: fs_inode and fs_mnt.
fs_inode is for a specific inode and fs_mnt is for a specifc mount. More
type (e.g., all inodes in a file-system) could be added if in need. Both
of these two iterators work by getting a file-description and a bpf
program as the input. BPF iterator will pass the fd-related inode or
mount to the bpf program, the bpf program can dump the needed
information of the inode or mount to a seq_file owned by iterator fd
by using all kinds of bpf helpers and the user can read the iterator fd
to get the final information. The following is an example when trying to
dump the detailed information of a XFS inode:

  sb: bsize 4096 s_op xfs_super_operations s_type xfs_fs_type name xfs
  ino: inode nlink 1 inum 131 size 10485760, name inode.test
  cache: cached 2560 dirty 0 wb 0 evicted 0
  orders:
    page offset 0 order 2
    page offset 4 order 2
    page offset 8 order 2
    page offset 12 order 2
    page offset 16 order 4
    page offset 32 order 4
    page offset 48 order 4
    page offset 64 order 5
    page offset 96 order 4
    page offset 112 order 4
    page offset 128 order 5
    page offset 160 order 4
    page offset 176 order 0
    ...

More details can be found in the individual patches. And suggestions and
comments are always welcome.

[0]: https://lore.kernel.org/bpf/0a6f0513-b4b3-9349-cee5-b0ad38c81d2e@xxxxxxxxxxxxxxx
[1]: https://github.com/osandov/drgn

Hou Tao (4):
  bpf: Introduce bpf iterator for file-system inode
  bpf: Add three kfunc helpers for bpf fs inode iterator
  bpf: Introduce bpf iterator for file system mount
  selftests/bpf: Add test cases for bpf file-system iterator

 include/linux/bpf.h                           |   2 +
 include/linux/btf_ids.h                       |   6 +-
 include/linux/fs.h                            |   4 +
 include/uapi/linux/bpf.h                      |   9 +
 include/uapi/linux/mman.h                     |   8 +
 kernel/bpf/Makefile                           |   1 +
 kernel/bpf/fs_iter.c                          | 216 ++++++++++++++++++
 kernel/bpf/helpers.c                          |  26 +++
 mm/filemap.c                                  |  77 +++++++
 tools/include/uapi/linux/bpf.h                |   9 +
 .../selftests/bpf/prog_tests/bpf_iter_fs.c    | 184 +++++++++++++++
 .../testing/selftests/bpf/progs/bpf_iter_fs.c | 122 ++++++++++
 12 files changed, 663 insertions(+), 1 deletion(-)
 create mode 100644 kernel/bpf/fs_iter.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/bpf_iter_fs.c
 create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_fs.c

-- 
2.29.2




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux