提交 fdd92676 编写于 作者: H Hou Tao 提交者: Zheng Zengkai

vfs: add bare tracepoints for vfs read and release

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I53R0H
CVE: NA
backport: openEuler-22.03-LTS

---------------------------

Add a writable bare tracepoint fs_file_read() and a bare
tracepoint fs_file_release().

A version field is added to fs_file_read() to support
extension of fs_file_read_ctx in future.

These two tracepoints need to be exported and will be
used by filesystem kernel module.
Signed-off-by: NHou Tao <houtao1@huawei.com>
Acked-by: Nfang wei <fangwei1@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NZhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 c515ac65
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <asm/unistd.h> #include <asm/unistd.h>
#define CREATE_TRACE_POINTS
#include <trace/events/fs.h>
const struct file_operations generic_ro_fops = { const struct file_operations generic_ro_fops = {
.llseek = generic_file_llseek, .llseek = generic_file_llseek,
...@@ -1679,3 +1681,6 @@ int generic_file_rw_checks(struct file *file_in, struct file *file_out) ...@@ -1679,3 +1681,6 @@ int generic_file_rw_checks(struct file *file_in, struct file *file_out)
return 0; return 0;
} }
EXPORT_TRACEPOINT_SYMBOL_GPL(fs_file_read);
EXPORT_TRACEPOINT_SYMBOL_GPL(fs_file_release);
...@@ -3562,4 +3562,21 @@ static inline int inode_drain_writes(struct inode *inode) ...@@ -3562,4 +3562,21 @@ static inline int inode_drain_writes(struct inode *inode)
return filemap_write_and_wait(inode->i_mapping); return filemap_write_and_wait(inode->i_mapping);
} }
struct fs_file_read_ctx {
const unsigned char *name;
unsigned int f_ctl_mode;
unsigned int rsvd;
/* clear from f_ctl_mode */
unsigned int clr_f_ctl_mode;
/* set into f_ctl_mode */
unsigned int set_f_ctl_mode;
unsigned long key;
/* file size */
long long i_size;
/* previous page index */
long long prev_index;
/* current page index */
long long index;
};
#endif /* _LINUX_FS_H */ #endif /* _LINUX_FS_H */
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM fs
#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_FS_H
#include <linux/types.h>
#include <linux/tracepoint.h>
#include <linux/fs.h>
#undef FS_DECLARE_TRACE
#ifdef DECLARE_TRACE_WRITABLE
#define FS_DECLARE_TRACE(call, proto, args, size) \
DECLARE_TRACE_WRITABLE(call, PARAMS(proto), PARAMS(args), size)
#else
#define FS_DECLARE_TRACE(call, proto, args, size) \
DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))
#endif
FS_DECLARE_TRACE(fs_file_read,
TP_PROTO(struct fs_file_read_ctx *ctx, int version),
TP_ARGS(ctx, version),
sizeof(struct fs_file_read_ctx));
DECLARE_TRACE(fs_file_release,
TP_PROTO(struct inode *inode, struct file *filp),
TP_ARGS(inode, filp));
#endif /* _TRACE_FS_H */
/* This part must be outside protection */
#include <trace/define_trace.h>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册