提交 0073794f 编写于 作者: Z ZhaoLong Wang 提交者: Zheng Zengkai

VFS: Rolling Back the fmode macro definition and structure members

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5MFXJ
CVE: NA

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

The readahead feature of the openEuler-22.03-LTS ebpf enhancement
involves interface changes and needs to be compatible with the ebpf
tool of openEuler-1.0-LTS. This patch changes the _ctl_mode to _mode of
fs_file_read_ctx structure.
Signed-off-by: NZhaoLong Wang <wangzhaolong1@huawei.com>
Reviewed-by: NZhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 e73f9ebf
......@@ -1688,7 +1688,7 @@ static void fs_file_read_ctx_init(struct fs_file_read_ctx *ctx,
{
memset(ctx, 0, sizeof(*ctx));
ctx->name = file_dentry(filp)->d_name.name;
ctx->f_ctl_mode = filp->f_ctl_mode;
ctx->f_mode = filp->f_mode;
ctx->key = (unsigned long)filp;
ctx->i_size = file_inode(filp)->i_size;
ctx->prev_index = filp->f_ra.prev_pos >> PAGE_SHIFT;
......@@ -1706,11 +1706,11 @@ void fs_file_read_update_args_by_trace(struct kiocb *iocb)
fs_file_read_ctx_init(&ctx, filp, iocb->ki_pos);
trace_fs_file_read(&ctx, FS_FILE_READ_VERSION);
if (!ctx.set_f_ctl_mode && !ctx.clr_f_ctl_mode)
if (!ctx.set_f_mode && !ctx.clr_f_mode)
return;
filp->f_ctl_mode |= ctx.set_f_ctl_mode & FS_FILE_READ_MODE_MASK;
filp->f_ctl_mode &= ~(ctx.clr_f_ctl_mode & FS_FILE_READ_MODE_MASK);
filp->f_ctl_mode |= ctx.set_f_mode & FS_FILE_READ_MODE_MASK;
filp->f_ctl_mode &= ~(ctx.clr_f_mode & FS_FILE_READ_MODE_MASK);
}
EXPORT_SYMBOL_GPL(fs_file_read_update_args_by_trace);
#endif
......
......@@ -185,10 +185,10 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
#define FMODE_BUF_RASYNC ((__force fmode_t)0x40000000)
/* File mode control flag, expect random access pattern */
#define FMODE_CTL_RANDOM ((__force fmode_t)0x1)
#define FMODE_CTL_RANDOM ((__force fmode_t)0x1000)
/* File mode control flag, will try to read head of the file into pagecache */
#define FMODE_CTL_WILLNEED ((__force fmode_t)0x2)
#define FMODE_CTL_WILLNEED ((__force fmode_t)0x400000)
/*
* Attribute flags. These should be or-ed together to figure out what
......@@ -3565,12 +3565,12 @@ static inline int inode_drain_writes(struct inode *inode)
struct fs_file_read_ctx {
const unsigned char *name;
unsigned int f_ctl_mode;
unsigned int f_mode;
unsigned int rsvd;
/* clear from f_ctl_mode */
unsigned int clr_f_ctl_mode;
unsigned int clr_f_mode;
/* set into f_ctl_mode */
unsigned int set_f_ctl_mode;
unsigned int set_f_mode;
unsigned long key;
/* file size */
long long i_size;
......
......@@ -11,17 +11,17 @@
#endif
/* Need to keep consistent with definitions in include/linux/fs.h */
#define FMODE_CTL_RANDOM 0x1
#define FMODE_CTL_WILLNEED 0x2
#define FMODE_CTL_RANDOM 0x1000
#define FMODE_CTL_WILLNEED 0x400000
struct fs_file_read_ctx {
const unsigned char *name;
unsigned int f_ctl_mode;
unsigned int f_mode;
unsigned int rsvd;
/* clear from f_ctl_mode */
unsigned int clr_f_ctl_mode;
unsigned int clr_f_mode;
/* set into f_ctl_mode */
unsigned int set_f_ctl_mode;
unsigned int set_f_mode;
unsigned long key;
/* file size */
long long i_size;
......@@ -80,7 +80,7 @@ int fs_file_read(struct fs_file_read_args *args)
return 0;
if (rd_ctx->i_size <= (4 << 20)) {
rd_ctx->set_f_ctl_mode = FMODE_CTL_WILLNEED;
rd_ctx->set_f_mode = FMODE_CTL_WILLNEED;
return 0;
}
......@@ -112,9 +112,9 @@ int fs_file_read(struct fs_file_read_args *args)
if (now - hist->last_nsec >= 500000000ULL || hist->tot_nr >= 10) {
if (hist->tot_nr >= 10) {
if (hist->seq_nr <= hist->tot_nr * 3 / 10)
rd_ctx->set_f_ctl_mode = FMODE_CTL_RANDOM;
rd_ctx->set_f_mode = FMODE_CTL_RANDOM;
else if (hist->seq_nr >= hist->tot_nr * 7 / 10)
rd_ctx->clr_f_ctl_mode = FMODE_CTL_RANDOM;
rd_ctx->clr_f_mode = FMODE_CTL_RANDOM;
}
hist->last_nsec = now;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册