From: Hou Tao houtao1@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4H3JT CVE: NA
---------------------------
There are two issues with the current solution: 1) tracepoint xfs_read_file is visible in tracefs It forms an ABI for userspace. It is bad because new field may be added into xfs_writable_file to export more information to userspace.
2) tracepoint xfs_read_file is specific to xfs HDFS can be stacked on ext4.
This reverts commit 38abc1bb82c913b6548067195beb5894d994bd5d.
Signed-off-by: Hou Tao houtao1@huawei.com Reviewed-by: Kuohai Xu xukuohai@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- tools/include/uapi/linux/xfs.h | 4 +- tools/testing/selftests/bpf/Makefile | 2 +- .../selftests/bpf/test_clear_xfs_file.c | 43 ------------------- tools/testing/selftests/bpf/test_xfs_file.c | 11 ++--- 4 files changed, 5 insertions(+), 55 deletions(-) delete mode 100644 tools/testing/selftests/bpf/test_clear_xfs_file.c
diff --git a/tools/include/uapi/linux/xfs.h b/tools/include/uapi/linux/xfs.h index a0d37e411ee18..2c4c61d5ba539 100644 --- a/tools/include/uapi/linux/xfs.h +++ b/tools/include/uapi/linux/xfs.h @@ -9,11 +9,9 @@
struct xfs_writable_file { const unsigned char *name; - unsigned int clear_f_mode; /* can be cleared from file->f_mode */ unsigned int f_mode; /* can be set into file->f_mode */ long long i_size; /* file size */ - long long prev_pos; /* ra->prev_pos page index */ - long long pos; /* iocb->ki_pos page index */ + long long prev_pos; /* ra->prev_pos */ };
#endif /* _UAPI_LINUX_XFS_H */ diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 8d2737285f185..1ba656a8ed656 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -36,7 +36,7 @@ TEST_GEN_FILES = test_pkt_access.o test_xdp.o test_l4lb.o test_tcp_estats.o test test_get_stack_rawtp.o test_sockmap_kern.o test_sockhash_kern.o \ test_lwt_seg6local.o sendmsg4_prog.o sendmsg6_prog.o test_lirc_mode2_kern.o \ get_cgroup_id_kern.o socket_cookie_prog.o test_select_reuseport_kern.o \ - test_skb_cgroup_id_kern.o test_set_xfs_file.o test_clear_xfs_file.o + test_skb_cgroup_id_kern.o test_set_xfs_file.o
# Order correspond to 'make run_tests' order TEST_PROGS := test_kmod.sh \ diff --git a/tools/testing/selftests/bpf/test_clear_xfs_file.c b/tools/testing/selftests/bpf/test_clear_xfs_file.c deleted file mode 100644 index 167ee63207232..0000000000000 --- a/tools/testing/selftests/bpf/test_clear_xfs_file.c +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 - -#include <linux/bpf.h> -#include "bpf_helpers.h" -#include <string.h> -#include <linux/xfs.h> - -/* from /sys/kernel/debug/tracing/events/xfs/xfs_read_file */ -struct xfs_read_buffer_args { - struct xfs_writable_file *file; -}; - -SEC("tracepoint/xfs/xfs_file_read") -int bpf_prog1(struct xfs_read_buffer_args *ctx) -{ - char fmt[] = "name: %s, clear_f_mode: %u, f_mode: %u\n"; - struct xfs_writable_file *file = ctx->file; - char name[64] = {}; - char *tmp; - unsigned long i_size; - int len; - - bpf_probe_read(&tmp, 8, &(file->name)); - len = bpf_probe_read_str(name, 64, tmp); - bpf_probe_read(&i_size, 8, &(file->i_size)); - - if (!strncmp("blk_", name, 4)) { - /* blk_xxx.meta or blk_xxx with size < 2M */ - if (len == 27 || (len == 15 && i_size <= 2 * 1024 * 1024)) { - file->f_mode |= FMODE_WILLNEED; - /* blk_xxx */ - } else if (len == 15) { - if (file->prev_pos == file->pos) - file->clear_f_mode |= FMODE_RANDOM; - } - bpf_trace_printk(fmt, sizeof(fmt), name, file->clear_f_mode, - file->f_mode); - } - return 0; -} - -char _license[] SEC("license") = "GPL"; -__u32 _version SEC("version") = 1; diff --git a/tools/testing/selftests/bpf/test_xfs_file.c b/tools/testing/selftests/bpf/test_xfs_file.c index 247c42be029b2..d0bc971d93bf9 100644 --- a/tools/testing/selftests/bpf/test_xfs_file.c +++ b/tools/testing/selftests/bpf/test_xfs_file.c @@ -18,22 +18,17 @@
int main(int argc, char *argv[]) { - const char *set_file = "./test_set_xfs_file.o"; - const char *clear_file = "./test_clear_xfs_file.o"; - const char *file = set_file; + const char *file = "./test_set_xfs_file.o"; struct bpf_object *obj; int efd, err, prog_fd; int delay = SLEEP_SECS; char *endptr, *str;
- if (argc == 3) { - str = argv[2]; + if (argc == 2) { + str = argv[1]; delay = strtol(str, &endptr, 10); }
- if (argc >= 2 && !strcmp("clear", argv[1])) - file = clear_file; - err = bpf_prog_load(file, BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE, &obj, &prog_fd); if (err) {