fix rwlock cause schedule bug if pagefault or wait for read file page
Signed-off-by: liqiang <liqiang64@huawei.com>
This commit is contained in:
parent
3287ea19f9
commit
52b330afd2
166
0001-refactor-syscall-wrapper-for-aarch64-reduce-the-memo.patch
Normal file
166
0001-refactor-syscall-wrapper-for-aarch64-reduce-the-memo.patch
Normal file
@ -0,0 +1,166 @@
|
||||
From 6a43e037faab2f3d084fce8b16d864f18b033a48 Mon Sep 17 00:00:00 2001
|
||||
From: liqiang <liqiang64@huawei.com>
|
||||
Date: Mon, 17 Jun 2024 11:18:43 +0800
|
||||
Subject: [PATCH] refactor syscall wrapper for aarch64, reduce the memory range
|
||||
to o be writable
|
||||
|
||||
Signed-off-by: liqiang <liqiang64@huawei.com>
|
||||
---
|
||||
qtfs/include/symbol_wrapper.h | 14 ++++++++++++--
|
||||
qtfs/qtfs/syscall.c | 25 ++++++++++++-------------
|
||||
qtfs/qtfs_common/symbol_wrapper.c | 18 ++++++------------
|
||||
3 files changed, 30 insertions(+), 27 deletions(-)
|
||||
|
||||
diff --git a/qtfs/include/symbol_wrapper.h b/qtfs/include/symbol_wrapper.h
|
||||
index cef2cd9..4ce500f 100644
|
||||
--- a/qtfs/include/symbol_wrapper.h
|
||||
+++ b/qtfs/include/symbol_wrapper.h
|
||||
@@ -72,8 +72,18 @@ static inline int make_ro(unsigned long address)
|
||||
|
||||
#ifdef __aarch64__
|
||||
extern void (*update_mapping_prot)(phys_addr_t phys, unsigned long virt, phys_addr_t size, pgprot_t prot);
|
||||
-extern unsigned long start_rodata, end_rodata;
|
||||
-#define section_size (end_rodata - start_rodata)
|
||||
+static inline int make_rw(unsigned long address)
|
||||
+{
|
||||
+ update_mapping_prot(__pa_symbol(address & PAGE_MASK), (unsigned long)(address & PAGE_MASK), PAGE_SIZE, PAGE_KERNEL);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static inline int make_ro(unsigned long address)
|
||||
+{
|
||||
+ update_mapping_prot(__pa_symbol(address & PAGE_MASK), (unsigned long)(address & PAGE_MASK), PAGE_SIZE, PAGE_KERNEL_RO);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
#endif
|
||||
|
||||
int qtfs_syscall_replace_start(void);
|
||||
diff --git a/qtfs/qtfs/syscall.c b/qtfs/qtfs/syscall.c
|
||||
index a02a225..7b139a4 100644
|
||||
--- a/qtfs/qtfs/syscall.c
|
||||
+++ b/qtfs/qtfs/syscall.c
|
||||
@@ -441,22 +441,22 @@ int qtfs_syscall_init(void)
|
||||
symbols_origin[SYMBOL_SYSCALL_MOUNT] = qtfs_kern_syms.sys_call_table[__NR_mount];
|
||||
symbols_origin[SYMBOL_SYSCALL_UMOUNT] = qtfs_kern_syms.sys_call_table[__NR_umount2];
|
||||
symbols_origin[SYMBOL_SYSCALL_EPOLL_CTL] = qtfs_kern_syms.sys_call_table[__NR_epoll_ctl];
|
||||
-#ifdef __x86_64__
|
||||
+
|
||||
make_rw((unsigned long)qtfs_kern_syms.sys_call_table);
|
||||
+ make_rw((unsigned long)qtfs_kern_syms.sys_call_table + PAGE_SIZE);
|
||||
+#ifdef __x86_64__
|
||||
qtfs_kern_syms.sys_call_table[__NR_mount] = (unsigned long *)__x64_sys_qtfs_mount;
|
||||
qtfs_kern_syms.sys_call_table[__NR_umount2] = (unsigned long *)__x64_sys_qtfs_umount;
|
||||
qtfs_kern_syms.sys_call_table[__NR_epoll_ctl] = (unsigned long *)__x64_sys_qtfs_epoll_ctl;
|
||||
- make_ro((unsigned long)qtfs_kern_syms.sys_call_table);
|
||||
#endif
|
||||
#ifdef __aarch64__
|
||||
- // disable write protection
|
||||
- update_mapping_prot(__pa_symbol(start_rodata), (unsigned long)start_rodata, section_size, PAGE_KERNEL);
|
||||
qtfs_kern_syms.sys_call_table[__NR_mount] = (unsigned long *)__arm64_sys_qtfs_mount;
|
||||
qtfs_kern_syms.sys_call_table[__NR_umount2] = (unsigned long *)__arm64_sys_qtfs_umount;
|
||||
qtfs_kern_syms.sys_call_table[__NR_epoll_ctl] = (unsigned long *)__arm64_sys_qtfs_epoll_ctl;
|
||||
- // enable write protection
|
||||
- update_mapping_prot(__pa_symbol(start_rodata), (unsigned long)start_rodata, section_size, PAGE_KERNEL_RO);
|
||||
#endif
|
||||
+ // enable write protection
|
||||
+ make_ro((unsigned long)qtfs_kern_syms.sys_call_table);
|
||||
+ make_ro((unsigned long)qtfs_kern_syms.sys_call_table + PAGE_SIZE);
|
||||
qtfs_debug("qtfs use qtfs_mount instead of mount and umount\n");
|
||||
qtfs_debug("qtfs use qtfs_epoll_ctl instead of epoll_ctl\n");
|
||||
return 0;
|
||||
@@ -464,23 +464,22 @@ int qtfs_syscall_init(void)
|
||||
|
||||
int qtfs_syscall_fini(void)
|
||||
{
|
||||
-#ifdef __x86_64__
|
||||
make_rw((unsigned long)qtfs_kern_syms.sys_call_table);
|
||||
+ make_rw((unsigned long)qtfs_kern_syms.sys_call_table + PAGE_SIZE);
|
||||
+#ifdef __x86_64__
|
||||
qtfs_kern_syms.sys_call_table[__NR_mount] = (unsigned long *)symbols_origin[SYMBOL_SYSCALL_MOUNT];
|
||||
qtfs_kern_syms.sys_call_table[__NR_umount2] = (unsigned long *)symbols_origin[SYMBOL_SYSCALL_UMOUNT];
|
||||
qtfs_kern_syms.sys_call_table[__NR_epoll_ctl] = (unsigned long *)symbols_origin[SYMBOL_SYSCALL_EPOLL_CTL];
|
||||
- /*set mkdir syscall to the original one */
|
||||
- make_ro((unsigned long)qtfs_kern_syms.sys_call_table);
|
||||
#endif
|
||||
#ifdef __aarch64__
|
||||
- // disable write protection
|
||||
- update_mapping_prot(__pa_symbol(start_rodata), (unsigned long)start_rodata, section_size, PAGE_KERNEL);
|
||||
qtfs_kern_syms.sys_call_table[__NR_mount] = (unsigned long *)symbols_origin[SYMBOL_SYSCALL_MOUNT];
|
||||
qtfs_kern_syms.sys_call_table[__NR_umount2] = (unsigned long *)symbols_origin[SYMBOL_SYSCALL_UMOUNT];
|
||||
qtfs_kern_syms.sys_call_table[__NR_epoll_ctl] = (unsigned long *)symbols_origin[SYMBOL_SYSCALL_EPOLL_CTL];
|
||||
- // enable write protection
|
||||
- update_mapping_prot(__pa_symbol(start_rodata), (unsigned long)start_rodata, section_size, PAGE_KERNEL_RO);
|
||||
#endif
|
||||
+ // enable write protection
|
||||
+ make_ro((unsigned long)qtfs_kern_syms.sys_call_table);
|
||||
+ make_ro((unsigned long)qtfs_kern_syms.sys_call_table + PAGE_SIZE);
|
||||
+
|
||||
qtfs_info("qtfs mount umount and epoll_ctl resumed\n");
|
||||
atomic_inc(&replace_available);
|
||||
return 0;
|
||||
diff --git a/qtfs/qtfs_common/symbol_wrapper.c b/qtfs/qtfs_common/symbol_wrapper.c
|
||||
index 84c1bd5..5ceaf5f 100644
|
||||
--- a/qtfs/qtfs_common/symbol_wrapper.c
|
||||
+++ b/qtfs/qtfs_common/symbol_wrapper.c
|
||||
@@ -55,7 +55,6 @@ struct pt_regs;
|
||||
#endif
|
||||
#ifdef __aarch64__
|
||||
void (*update_mapping_prot)(phys_addr_t phys, unsigned long virt, phys_addr_t size, pgprot_t prot);
|
||||
-unsigned long start_rodata, end_rodata;
|
||||
|
||||
// symbols not finded in sys call table
|
||||
enum qtfs_sym_a64 {
|
||||
@@ -132,9 +131,7 @@ int qtfs_kallsyms_hack_init(void)
|
||||
|
||||
#ifdef __aarch64__
|
||||
update_mapping_prot = (void *)qtfs_kallsyms_lookup_name("update_mapping_prot");
|
||||
- start_rodata = (unsigned long)qtfs_kallsyms_lookup_name("__start_rodata");
|
||||
- end_rodata = (unsigned long)qtfs_kallsyms_lookup_name("__end_rodata");
|
||||
- if (update_mapping_prot == NULL || (void *)start_rodata == NULL || (void *)end_rodata == NULL) {
|
||||
+ if (update_mapping_prot == NULL) {
|
||||
qtfs_err("failed to init memory protect handler");
|
||||
return -1;
|
||||
}
|
||||
@@ -170,33 +167,30 @@ int qtfs_syscall_replace_start(void)
|
||||
}
|
||||
|
||||
symbols_origin[SYMBOL_SYSCALL_CONNECT] = qtfs_kern_syms.sys_call_table[__NR_connect];
|
||||
+ make_rw((unsigned long)&qtfs_kern_syms.sys_call_table[__NR_connect]);
|
||||
#ifdef __x86_64__
|
||||
- make_rw((unsigned long)qtfs_kern_syms.sys_call_table);
|
||||
qtfs_kern_syms.sys_call_table[__NR_connect] = (unsigned long *)__x64_sys_qtfs_connect;
|
||||
- make_ro((unsigned long)qtfs_kern_syms.sys_call_table);
|
||||
#endif
|
||||
|
||||
#ifdef __aarch64__
|
||||
- update_mapping_prot(__pa_symbol(start_rodata), (unsigned long)start_rodata, section_size, PAGE_KERNEL);
|
||||
qtfs_kern_syms.sys_call_table[__NR_connect] = (unsigned long *)__arm64_sys_qtfs_connect;
|
||||
- update_mapping_prot(__pa_symbol(start_rodata), (unsigned long)start_rodata, section_size, PAGE_KERNEL_RO);
|
||||
#endif
|
||||
+ make_ro((unsigned long)&qtfs_kern_syms.sys_call_table[__NR_connect]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void qtfs_syscall_replace_stop(void)
|
||||
{
|
||||
+ make_rw((unsigned long)&qtfs_kern_syms.sys_call_table[__NR_connect]);
|
||||
#ifdef __x86_64__
|
||||
- make_rw((unsigned long)qtfs_kern_syms.sys_call_table);
|
||||
qtfs_kern_syms.sys_call_table[__NR_connect] = (void *)qtfs_kallsyms_lookup_name("__x64_sys_connect");
|
||||
- make_ro((unsigned long)qtfs_kern_syms.sys_call_table);
|
||||
#endif
|
||||
|
||||
#ifdef __aarch64__
|
||||
- update_mapping_prot(__pa_symbol(start_rodata), (unsigned long)start_rodata, section_size, PAGE_KERNEL);
|
||||
qtfs_kern_syms.sys_call_table[__NR_connect] = (void *)qtfs_kallsyms_lookup_name("__arm64_sys_connect");
|
||||
- update_mapping_prot(__pa_symbol(start_rodata), (unsigned long)start_rodata, section_size, PAGE_KERNEL_RO);
|
||||
#endif
|
||||
+ make_ro((unsigned long)&qtfs_kern_syms.sys_call_table[__NR_connect]);
|
||||
+
|
||||
atomic_inc(&replace_available);
|
||||
}
|
||||
|
||||
--
|
||||
2.37.1 (Apple Git-137.1)
|
||||
|
||||
45
0002-fix-readdir-bug-in-devtmpfs.patch
Normal file
45
0002-fix-readdir-bug-in-devtmpfs.patch
Normal file
@ -0,0 +1,45 @@
|
||||
From 645c009ced7f759d0d26c6f0a0b53a084cf82db5 Mon Sep 17 00:00:00 2001
|
||||
From: liqiang <liqiang64@huawei.com>
|
||||
Date: Wed, 10 Jul 2024 02:37:00 +0000
|
||||
Subject: [PATCH] fix readdir bug in devtmpfs if /dev/ have a large number of
|
||||
files, readdir can't get whole informations, because of direct save and use
|
||||
file->f_pos is not correct in devtmpfs
|
||||
|
||||
Just use vfs_llseek to instead.
|
||||
|
||||
Signed-off-by: liqiang <liqiang64@huawei.com>
|
||||
---
|
||||
qtfs/qtfs_server/fsops.c | 12 +++++++++---
|
||||
1 file changed, 9 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/qtfs/qtfs_server/fsops.c b/qtfs/qtfs_server/fsops.c
|
||||
index cd7365d..f2f3749 100644
|
||||
--- a/qtfs/qtfs_server/fsops.c
|
||||
+++ b/qtfs/qtfs_server/fsops.c
|
||||
@@ -668,14 +668,20 @@ static int handle_readdir(struct qtserver_arg *arg)
|
||||
rsp->d.vldcnt = 0;
|
||||
return sizeof(struct qtrsp_readdir) - sizeof(rsp->dirent);
|
||||
}
|
||||
- file->f_pos = req->pos;
|
||||
+ if (vfs_llseek(file, req->pos, SEEK_SET) < 0) {
|
||||
+ qtfs_err("handle readdir error, file path:%s seek set:%lld failed", req->path, req->pos);
|
||||
+ rsp->d.ret = QTFS_ERR;
|
||||
+ rsp->d.vldcnt = 0;
|
||||
+ filp_close(file, NULL);
|
||||
+ return sizeof(struct qtrsp_readdir) - sizeof(rsp->dirent);
|
||||
+ }
|
||||
ret = iterate_dir(file, &buf.ctx);
|
||||
- rsp->d.pos = file->f_pos;
|
||||
+ rsp->d.pos = vfs_llseek(file, 0, SEEK_CUR);
|
||||
rsp->d.ret = QTFS_OK;
|
||||
rsp->d.vldcnt = buf.vldcnt;
|
||||
rsp->d.over = (req->pos == rsp->d.pos) ? 1 : 0;
|
||||
qtfs_info("handle readdir ret:%d, pos:%lld path:%s, valid count:%d, leftcount:%d validbyte:%lu\n",
|
||||
- ret, req->pos, req->path, buf.vldcnt, buf.count, sizeof(rsp->dirent) - buf.count);
|
||||
+ ret, req->pos, req->path, buf.vldcnt, buf.count, req->count - buf.count);
|
||||
filp_close(file, NULL);
|
||||
|
||||
return sizeof(struct qtrsp_readdir_len) + req->count;
|
||||
--
|
||||
2.37.1 (Apple Git-137.1)
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
From 682168145e892229f39ed66d9f21dd221782a9f9 Mon Sep 17 00:00:00 2001
|
||||
From: liqiang <liqiang64@huawei.com>
|
||||
Date: Fri, 19 Jul 2024 11:55:23 +0000
|
||||
Subject: [PATCH] Change the maximum number of qtfs links from 16 to 64
|
||||
|
||||
Signed-off-by: liqiang <liqiang64@huawei.com>
|
||||
---
|
||||
qtfs/include/comm.h | 2 +-
|
||||
qtfs/qtfs_common/conn.c | 4 ++++
|
||||
2 files changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/qtfs/include/comm.h b/qtfs/include/comm.h
|
||||
index faa8ce3..b2c4c97 100644
|
||||
--- a/qtfs/include/comm.h
|
||||
+++ b/qtfs/include/comm.h
|
||||
@@ -73,7 +73,7 @@ enum {
|
||||
#define QTINFO_MAX_EVENT_TYPE 36 // look qtreq_type at req.h
|
||||
#define QTFS_FUNCTION_LEN 64
|
||||
|
||||
-#define QTFS_MAX_THREADS 16
|
||||
+#define QTFS_MAX_THREADS 64
|
||||
#define QTFS_LOGLEVEL_STRLEN 6
|
||||
|
||||
struct qtfs_server_userp_s {
|
||||
diff --git a/qtfs/qtfs_common/conn.c b/qtfs/qtfs_common/conn.c
|
||||
index fa3c1b9..5f080cd 100644
|
||||
--- a/qtfs/qtfs_common/conn.c
|
||||
+++ b/qtfs/qtfs_common/conn.c
|
||||
@@ -667,6 +667,10 @@ static void parse_param(void)
|
||||
int qtfs_conn_param_init(void)
|
||||
{
|
||||
#ifdef QTFS_CLIENT
|
||||
+ if (qtfs_conn_max_conn > QTFS_MAX_THREADS) {
|
||||
+ qtfs_err("QTFS parameter qtfs_conn_max_conn(%d) is invalid, max conn:%d", qtfs_conn_max_conn, QTFS_MAX_THREADS);
|
||||
+ return -1;
|
||||
+ }
|
||||
qtfs_fifo_pvar_cache = kmem_cache_create("qtfs_fifo_pvar",
|
||||
sizeof(struct qtfs_conn_var_s),
|
||||
0,
|
||||
--
|
||||
2.37.1 (Apple Git-137.1)
|
||||
|
||||
370
0004-add-compile-option-of-EPOLL_PROXY-and-fix-some-probl.patch
Normal file
370
0004-add-compile-option-of-EPOLL_PROXY-and-fix-some-probl.patch
Normal file
@ -0,0 +1,370 @@
|
||||
From 77a98b652e40ed72dbf8f72be0a17bc7f3b3967b Mon Sep 17 00:00:00 2001
|
||||
From: liqiang <liqiang64@huawei.com>
|
||||
Date: Tue, 6 Aug 2024 19:52:06 +0800
|
||||
Subject: [PATCH 3/3] add compile option of EPOLL_PROXY and fix some problem of
|
||||
vsock connection
|
||||
|
||||
Signed-off-by: liqiang <liqiang64@huawei.com>
|
||||
---
|
||||
qtfs/qtfs/Makefile | 3 +++
|
||||
qtfs/qtfs/qtfs-mod.c | 13 ++++++++++++-
|
||||
qtfs/qtfs_common/conn.c | 10 ++++++++++
|
||||
qtfs/qtfs_common/misc.c | 2 ++
|
||||
qtfs/qtfs_common/socket.c | 8 +++++++-
|
||||
qtfs/qtfs_common/user_engine.c | 12 +++++++++++-
|
||||
qtfs/qtfs_server/Makefile | 4 ++++
|
||||
qtfs/qtfs_server/qtfs-server.c | 12 ++++++++++++
|
||||
8 files changed, 61 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/qtfs/qtfs/Makefile b/qtfs/qtfs/Makefile
|
||||
index 9b3ebe5..a6a6dca 100644
|
||||
--- a/qtfs/qtfs/Makefile
|
||||
+++ b/qtfs/qtfs/Makefile
|
||||
@@ -3,6 +3,9 @@ ccflags-y += -I$(src)/../ -I$(src)/../utils/ -I$(src)/../include/ -I$(src)/../ip
|
||||
else
|
||||
ccflags-y += -I$(src)/../ -I$(src)/../utils/ -I$(src)/../include/ -I$(src)/../ipc/ -I$(src) -DQTFS_CLIENT
|
||||
endif
|
||||
+ifdef EPOLL_PROXY
|
||||
+ccflags-y += -DEPOLL_PROXY
|
||||
+endif
|
||||
|
||||
KBUILD=/lib/modules/$(shell uname -r)/build/
|
||||
COMM=../qtfs_common/
|
||||
diff --git a/qtfs/qtfs/qtfs-mod.c b/qtfs/qtfs/qtfs-mod.c
|
||||
index 0ce43fb..79256ad 100644
|
||||
--- a/qtfs/qtfs/qtfs-mod.c
|
||||
+++ b/qtfs/qtfs/qtfs-mod.c
|
||||
@@ -33,8 +33,9 @@ static struct file_system_type qtfs_fs_type = {
|
||||
};
|
||||
MODULE_ALIAS_FS("qtfs");
|
||||
struct kmem_cache *qtfs_inode_priv_cache;
|
||||
+#ifdef EPOLL_PROXY
|
||||
struct task_struct *g_qtfs_epoll_thread = NULL;
|
||||
-
|
||||
+#endif
|
||||
/*
|
||||
* 转发框架层:
|
||||
* 1. 调用者先在pvar里预留框架头后,填好自己的私有发送数据。
|
||||
@@ -124,6 +125,7 @@ retry:
|
||||
return pvar->conn_ops->get_conn_msg_buf(pvar, QTFS_RECV);
|
||||
}
|
||||
|
||||
+#ifdef EPOLL_PROXY
|
||||
static int qtfs_epoll_thread(void *data)
|
||||
{
|
||||
struct qtfs_conn_var_s *pvar = NULL;
|
||||
@@ -202,6 +204,7 @@ end:
|
||||
g_qtfs_epoll_thread = NULL;
|
||||
return 0;
|
||||
}
|
||||
+#endif
|
||||
|
||||
struct file_operations qtfs_misc_fops = {
|
||||
.owner=THIS_MODULE,
|
||||
@@ -236,12 +239,14 @@ static int __init qtfs_init(void)
|
||||
goto conn_init_err;
|
||||
}
|
||||
qtfs_whitelist_initset();
|
||||
+#ifdef EPOLL_PROXY
|
||||
g_qtfs_epoll_thread = kthread_run(qtfs_epoll_thread, NULL, "qtfs_epoll");
|
||||
if (IS_ERR_OR_NULL(g_qtfs_epoll_thread)) {
|
||||
qtfs_err("qtfs epoll thread run failed.\n");
|
||||
ret = QTFS_PTR_ERR(g_qtfs_epoll_thread);
|
||||
goto epoll_thread_err;
|
||||
}
|
||||
+#endif
|
||||
qtfs_diag_info = (struct qtinfo *)kmalloc(sizeof(struct qtinfo), GFP_KERNEL);
|
||||
if (qtfs_diag_info == NULL) {
|
||||
qtfs_err("kmalloc qtfs diag info failed.");
|
||||
@@ -278,7 +283,9 @@ syscall_replace_err:
|
||||
misc_register_err:
|
||||
kfree(qtfs_diag_info);
|
||||
diag_malloc_err:
|
||||
+#ifdef EPOLL_PROXY
|
||||
kthread_stop(g_qtfs_epoll_thread);
|
||||
+#endif
|
||||
epoll_thread_err:
|
||||
qtfs_conn_param_fini();
|
||||
conn_init_err:
|
||||
@@ -293,18 +300,22 @@ static void __exit qtfs_exit(void)
|
||||
int ret;
|
||||
qtfs_mod_exiting = true;
|
||||
|
||||
+#ifdef EPOLL_PROXY
|
||||
if (g_qtfs_epoll_thread) {
|
||||
kthread_stop(g_qtfs_epoll_thread);
|
||||
}
|
||||
+#endif
|
||||
|
||||
qtfs_conn_param_fini();
|
||||
qtfs_misc_destroy();
|
||||
+#ifdef EPOLL_PROXY
|
||||
if (qtfs_epoll_var != NULL) {
|
||||
qtfs_epoll_cut_conn(qtfs_epoll_var);
|
||||
qtfs_epoll_var->conn_ops->conn_var_fini(qtfs_epoll_var);
|
||||
kfree(qtfs_epoll_var);
|
||||
qtfs_epoll_var = NULL;
|
||||
}
|
||||
+#endif
|
||||
qtfs_whitelist_exit();
|
||||
|
||||
kfree(qtfs_diag_info);
|
||||
diff --git a/qtfs/qtfs_common/conn.c b/qtfs/qtfs_common/conn.c
|
||||
index 5f080cd..fd5f654 100644
|
||||
--- a/qtfs/qtfs_common/conn.c
|
||||
+++ b/qtfs/qtfs_common/conn.c
|
||||
@@ -42,7 +42,9 @@ static struct mutex g_param_mutex;
|
||||
static struct mutex g_fifo_mutex;
|
||||
int qtfs_mod_exiting = false;
|
||||
struct qtfs_conn_var_s *qtfs_thread_var[QTFS_MAX_THREADS] = {NULL};
|
||||
+#ifdef EPOLL_PROXY
|
||||
struct qtfs_conn_var_s *qtfs_epoll_var = NULL;
|
||||
+#endif
|
||||
#ifdef QTFS_SERVER
|
||||
struct qtfs_server_userp_s *qtfs_userps = NULL;
|
||||
#endif
|
||||
@@ -520,7 +522,11 @@ void *qtfs_conn_msg_buf(struct qtfs_conn_var_s *pvar, int dir)
|
||||
static int qtfs_sm_connecting(struct qtfs_conn_var_s *pvar)
|
||||
{
|
||||
int ret = QTERROR;
|
||||
+#ifdef QTFS_CLIENT
|
||||
int retry = 3;
|
||||
+#else
|
||||
+ int retry = 1;
|
||||
+#endif
|
||||
while (qtfs_mod_exiting == false && retry-- > 0) {
|
||||
ret = pvar->conn_ops->conn_new_connection(&pvar->conn_var, pvar->user_type);
|
||||
if (ret == 0) {
|
||||
@@ -873,6 +879,7 @@ retry:
|
||||
return pvar;
|
||||
}
|
||||
|
||||
+#ifdef EPOLL_PROXY
|
||||
struct qtfs_conn_var_s *qtfs_epoll_establish_conn(void)
|
||||
{
|
||||
struct qtfs_conn_var_s *pvar = NULL;
|
||||
@@ -920,6 +927,7 @@ struct qtfs_conn_var_s *qtfs_epoll_establish_conn(void)
|
||||
qtfs_info("qtfs create new epoll param state:%s", QTCONN_CUR_STATE(pvar));
|
||||
return pvar;
|
||||
}
|
||||
+#endif
|
||||
|
||||
void qtfs_conn_put_param(struct qtfs_conn_var_s *pvar)
|
||||
{
|
||||
@@ -944,6 +952,7 @@ void qtfs_conn_put_param(struct qtfs_conn_var_s *pvar)
|
||||
mutex_unlock(&g_param_mutex);
|
||||
}
|
||||
|
||||
+#ifdef EPOLL_PROXY
|
||||
void qtfs_epoll_cut_conn(struct qtfs_conn_var_s *pvar)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -958,6 +967,7 @@ void qtfs_epoll_cut_conn(struct qtfs_conn_var_s *pvar)
|
||||
qtfs_err("qtfs epoll put param exit failed, ret:%d state:%s", ret, QTCONN_CUR_STATE(pvar));
|
||||
}
|
||||
}
|
||||
+#endif
|
||||
|
||||
#ifdef QTFS_CLIENT
|
||||
/* fifo的机制有所不同,每一个pvar对应唯一一个fifo的访问,生命周期贯穿
|
||||
diff --git a/qtfs/qtfs_common/misc.c b/qtfs/qtfs_common/misc.c
|
||||
index e1c3520..3adfb57 100644
|
||||
--- a/qtfs/qtfs_common/misc.c
|
||||
+++ b/qtfs/qtfs_common/misc.c
|
||||
@@ -68,7 +68,9 @@ void qtfs_misc_flush_threadstate(void)
|
||||
}
|
||||
qtfs_diag_info->thread_state[i] = qtfs_thread_var[i]->state;
|
||||
}
|
||||
+#ifdef EPOLL_PROXY
|
||||
qtfs_diag_info->epoll_state = (qtfs_epoll_var == NULL) ? -1 : qtfs_epoll_var->state;
|
||||
+#endif
|
||||
}
|
||||
|
||||
void qtfs_req_size(void)
|
||||
diff --git a/qtfs/qtfs_common/socket.c b/qtfs/qtfs_common/socket.c
|
||||
index f247be0..233a1ce 100644
|
||||
--- a/qtfs/qtfs_common/socket.c
|
||||
+++ b/qtfs/qtfs_common/socket.c
|
||||
@@ -162,6 +162,11 @@ static int qtfs_conn_sock_server_accept(void *connvar, qtfs_conn_type_e type)
|
||||
mutex_unlock(&qtfs_server_main_sock[type].lock);
|
||||
return -EFAULT;
|
||||
}
|
||||
+ if (qtfs_server_thread_run == 0) {
|
||||
+ qtfs_err("engine is exit now, return right now.");
|
||||
+ mutex_unlock(&qtfs_server_main_sock[type].lock);
|
||||
+ return -EINTR;
|
||||
+ }
|
||||
sock = qtfs_server_main_sock[type].sock;
|
||||
|
||||
if (sock == NULL) {
|
||||
@@ -246,7 +251,7 @@ static int qtfs_conn_sock_init(void *connvar, qtfs_conn_type_e type)
|
||||
}
|
||||
|
||||
qtfs_info("qtfs socket init sock OK, type:%d!", type);
|
||||
- qtfs_sock_recvtimeo_set(sock, 0, 100000);
|
||||
+ qtfs_sock_recvtimeo_set(sock, 1, 0);
|
||||
qtfs_server_main_sock[type].sock = sock;
|
||||
mutex_unlock(&qtfs_server_main_sock[type].lock);
|
||||
return 0;
|
||||
@@ -282,6 +287,7 @@ static int qtfs_conn_sock_client_connect(void *connvar, qtfs_conn_type_e type)
|
||||
|
||||
ret = sock->ops->connect(sock, (struct sockaddr *)&saddr, sizeof(saddr), 0);
|
||||
if (ret < 0) {
|
||||
+ qtfs_err("qtfs client connect failed, ret:%d", ret);
|
||||
return ret;
|
||||
}
|
||||
#ifdef QTFS_TEST_MODE
|
||||
diff --git a/qtfs/qtfs_common/user_engine.c b/qtfs/qtfs_common/user_engine.c
|
||||
index a3edac2..a602980 100644
|
||||
--- a/qtfs/qtfs_common/user_engine.c
|
||||
+++ b/qtfs/qtfs_common/user_engine.c
|
||||
@@ -177,8 +177,8 @@ static void *qtfs_engine_kthread(void *arg)
|
||||
break;
|
||||
}
|
||||
if (sig_int_flag == 1) {
|
||||
+ sig_int_flag = 0;
|
||||
engine_out("qtfs engine recv SIGINT.");
|
||||
-
|
||||
if (qtfs_fd < 0) {
|
||||
engine_err("qtfs engine signal int file:%s open failed, fd:%d.", QTFS_SERVER_FILE, qtfs_fd);
|
||||
continue;
|
||||
@@ -204,6 +204,7 @@ static void qtfs_signal_int(int signum)
|
||||
return;
|
||||
}
|
||||
|
||||
+#ifdef EPOLL_PROXY
|
||||
static void *qtfs_engine_epoll_thread(void *data)
|
||||
{
|
||||
struct engine_arg *arg = (struct engine_arg *)data;
|
||||
@@ -264,6 +265,7 @@ int qtfs_epoll_init(int fd)
|
||||
|
||||
return epfd;
|
||||
}
|
||||
+#endif
|
||||
|
||||
static void qtfs_whitelist_free_items(char **items, gsize count)
|
||||
{
|
||||
@@ -498,11 +500,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
qtfs_fd = fd;
|
||||
// init epoll
|
||||
+#ifdef EPOLL_PROXY
|
||||
int epfd = qtfs_epoll_init(fd);
|
||||
if (epfd < 0) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
+#endif
|
||||
ret = ioctl(fd, QTFS_IOCTL_EXIT, 1);
|
||||
if (ret == QTERROR) {
|
||||
goto end;
|
||||
@@ -539,7 +543,9 @@ int main(int argc, char *argv[])
|
||||
arg[i].thread_idx = i;
|
||||
(void)pthread_create(&texec[i], NULL, qtfs_engine_kthread, &arg[i]);
|
||||
}
|
||||
+#ifdef EPOLL_PROXY
|
||||
(void)pthread_create(&tepoll, NULL, qtfs_engine_epoll_thread, &arg[0]);
|
||||
+#endif
|
||||
|
||||
#ifdef QTFS_TEST_MODE
|
||||
fifo_arg.addr = argv[3];
|
||||
@@ -566,14 +572,18 @@ int main(int argc, char *argv[])
|
||||
pthread_join(texec[i], NULL);
|
||||
engine_out("qtfs engine join thread %d.", i);
|
||||
}
|
||||
+#ifdef EPOLL_PROXY
|
||||
pthread_join(tepoll, NULL);
|
||||
+#endif
|
||||
pthread_join(tfifo, NULL);
|
||||
engine_free:
|
||||
qtfs_engine_userp_free(userp, thread_nums);
|
||||
engine_out("qtfs engine join epoll thread.");
|
||||
end:
|
||||
(void)ioctl(fd, QTFS_IOCTL_EXIT, 0);
|
||||
+#ifdef EPOLL_PROXY
|
||||
close(epfd);
|
||||
+#endif
|
||||
close(fd);
|
||||
engine_out("qtfs engine over.");
|
||||
return ret;
|
||||
diff --git a/qtfs/qtfs_server/Makefile b/qtfs/qtfs_server/Makefile
|
||||
index 4608365..765567a 100644
|
||||
--- a/qtfs/qtfs_server/Makefile
|
||||
+++ b/qtfs/qtfs_server/Makefile
|
||||
@@ -4,6 +4,10 @@ CFLAGS += -DUDS_TEST_MODE -DQTFS_TEST_MODE
|
||||
else
|
||||
ccflags-y += -I$(src)/../ -I$(src) -I$(src)/../ipc/ -I$(src)/../include/ -DQTFS_SERVER
|
||||
endif
|
||||
+ifdef EPOLL_PROXY
|
||||
+ccflags-y += -DEPOLL_PROXY
|
||||
+CFLAGS += -DEPOLL_PROXY
|
||||
+endif
|
||||
|
||||
CFLAGS += -g -O2
|
||||
CFLAGS += -fstack-protector-strong
|
||||
diff --git a/qtfs/qtfs_server/qtfs-server.c b/qtfs/qtfs_server/qtfs-server.c
|
||||
index f4e201c..48248ba 100644
|
||||
--- a/qtfs/qtfs_server/qtfs-server.c
|
||||
+++ b/qtfs/qtfs_server/qtfs-server.c
|
||||
@@ -59,6 +59,7 @@ void qtfs_server_epoll_exit(void)
|
||||
return;
|
||||
}
|
||||
|
||||
+#ifdef EPOLL_PROXY
|
||||
long qtfs_server_epoll_thread(struct qtfs_conn_var_s *pvar)
|
||||
{
|
||||
int n;
|
||||
@@ -170,6 +171,7 @@ long qtfs_server_epoll_init(void)
|
||||
|
||||
return QTOK;
|
||||
}
|
||||
+#endif
|
||||
|
||||
int qtfs_server_fd_bitmap_init(void)
|
||||
{
|
||||
@@ -308,11 +310,16 @@ long qtfs_server_misc_ioctl(struct file *file, unsigned int cmd, unsigned long a
|
||||
write_unlock(&qtfs_epoll_rwlock);
|
||||
break;
|
||||
case QTFS_IOCTL_EPOLL_THREAD_INIT:
|
||||
+#ifdef EPOLL_PROXY
|
||||
write_lock(&qtfs_epoll_rwlock);
|
||||
ret = qtfs_server_epoll_init();
|
||||
write_unlock(&qtfs_epoll_rwlock);
|
||||
+#else
|
||||
+ qtfs_warn("Qtfs not support epoll proxy, please compile with EPOLL_PROXY=1 to enable it.");
|
||||
+#endif
|
||||
break;
|
||||
case QTFS_IOCTL_EPOLL_THREAD_RUN:
|
||||
+#ifdef EPOLL_PROXY
|
||||
write_lock(&qtfs_epoll_rwlock);
|
||||
if (qtfs_epoll_var == NULL) {
|
||||
qtfs_err("qtfs epoll thread run failed, var is invalid.");
|
||||
@@ -326,6 +333,9 @@ long qtfs_server_misc_ioctl(struct file *file, unsigned int cmd, unsigned long a
|
||||
qtfs_info("qtfs epoll thread exit.");
|
||||
qtfs_epoll_cut_conn(qtfs_epoll_var);
|
||||
}
|
||||
+#else
|
||||
+ qtfs_warn("Qtfs not support epoll proxy, please compile with EPOLL_PROXY=1 to enable it.");
|
||||
+#endif
|
||||
break;
|
||||
case QTFS_IOCTL_EXIT:
|
||||
if (arg != 0 && arg != 1) {
|
||||
@@ -403,6 +413,7 @@ static void __exit qtfs_server_exit(void)
|
||||
|
||||
qtfs_conn_param_fini();
|
||||
|
||||
+#ifdef EPOLL_PROXY
|
||||
if (qtfs_epoll_var != NULL) {
|
||||
qtfs_epoll_cut_conn(qtfs_epoll_var);
|
||||
qtfs_conn_fini(qtfs_epoll_var);
|
||||
@@ -410,6 +421,7 @@ static void __exit qtfs_server_exit(void)
|
||||
kfree(qtfs_epoll_var);
|
||||
qtfs_epoll_var = NULL;
|
||||
}
|
||||
+#endif
|
||||
if (qtfs_diag_info != NULL) {
|
||||
kfree(qtfs_diag_info);
|
||||
qtfs_diag_info = NULL;
|
||||
--
|
||||
2.37.1 (Apple Git-137.1)
|
||||
|
||||
59
0005-resolve-migration-issues.patch
Normal file
59
0005-resolve-migration-issues.patch
Normal file
@ -0,0 +1,59 @@
|
||||
From e0ab70d68bcda40cd5cfd504f4da4d1d093d1996 Mon Sep 17 00:00:00 2001
|
||||
From: l30022887 <liweiqiang24@huawei.com>
|
||||
Date: Mon, 21 Oct 2024 19:51:38 +0800
|
||||
Subject: [PATCH] resolve-migration-issues
|
||||
|
||||
---
|
||||
qtfs/config/rexec/whitelist | 2 +-
|
||||
qtfs/ipc/uds_main.c | 7 ++++++-
|
||||
qtfs/rexec/rexec_sock.c | 2 +-
|
||||
3 files changed, 8 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/qtfs/config/rexec/whitelist b/qtfs/config/rexec/whitelist
|
||||
index b7f34b5..6a959d6 100644
|
||||
--- a/qtfs/config/rexec/whitelist
|
||||
+++ b/qtfs/config/rexec/whitelist
|
||||
@@ -1 +1 @@
|
||||
-/usr/bin/qemu-kvm
|
||||
+/usr/bin/qemu-kvm
|
||||
diff --git a/qtfs/ipc/uds_main.c b/qtfs/ipc/uds_main.c
|
||||
index 65468b8..4bc01a9 100644
|
||||
--- a/qtfs/ipc/uds_main.c
|
||||
+++ b/qtfs/ipc/uds_main.c
|
||||
@@ -255,6 +255,8 @@ int uds_set_nonblock(int fd)
|
||||
int uds_build_tcp_connection(struct uds_conn_arg *arg)
|
||||
{
|
||||
int family = AF_VSOCK;
|
||||
+ int retry = 3;
|
||||
+ int ret = 0;
|
||||
if (arg->cs > UDS_SOCKET_SERVER) {
|
||||
uds_err("cs type %d is error.", arg->cs);
|
||||
return -1;
|
||||
@@ -305,7 +307,10 @@ int uds_build_tcp_connection(struct uds_conn_arg *arg)
|
||||
sock_addr.svm_port = p_uds_var->vsock.peerport;
|
||||
sock_addr.svm_cid = p_uds_var->vsock.peercid;
|
||||
#endif
|
||||
- if (connect(arg->sockfd, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) < 0) {
|
||||
+ do {
|
||||
+ ret = connect(arg->sockfd, (struct sockaddr *)&sock_addr, sizeof(sock_addr));
|
||||
+ } while ((ret != 0) && (retry--));
|
||||
+ if (ret < 0) {
|
||||
goto close_and_return;
|
||||
}
|
||||
arg->connfd = sock_fd;
|
||||
diff --git a/qtfs/rexec/rexec_sock.c b/qtfs/rexec/rexec_sock.c
|
||||
index e8750c5..f7495e5 100644
|
||||
--- a/qtfs/rexec/rexec_sock.c
|
||||
+++ b/qtfs/rexec/rexec_sock.c
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
int rexec_build_unix_connection(struct rexec_conn_arg *arg)
|
||||
{
|
||||
- const int sock_max_conn = 5;
|
||||
+ const int sock_max_conn = 32;
|
||||
if (arg->cs > REXEC_SOCK_SERVER) {
|
||||
rexec_err("cs type %d is error.", arg->cs);
|
||||
return -1;
|
||||
--
|
||||
2.20.1
|
||||
|
||||
404
0006-fix-rwlock-cause-schedule-bug-if-pagefault-or-wait-f.patch
Normal file
404
0006-fix-rwlock-cause-schedule-bug-if-pagefault-or-wait-f.patch
Normal file
@ -0,0 +1,404 @@
|
||||
From c2cfb702946d01480236b34c1dacaeca0758cff0 Mon Sep 17 00:00:00 2001
|
||||
From: liqiang <liqiang64@huawei.com>
|
||||
Date: Fri, 22 Nov 2024 09:31:03 +0800
|
||||
Subject: [PATCH] fix rwlock cause schedule bug if pagefault or wait for read
|
||||
file page
|
||||
|
||||
Signed-off-by: liqiang <liqiang64@huawei.com>
|
||||
---
|
||||
qtfs/include/conn.h | 2 +-
|
||||
qtfs/qtfs_common/conn.c | 4 +--
|
||||
qtfs/qtfs_common/misc.c | 24 +++++++-------
|
||||
qtfs/qtfs_server/fsops.c | 8 ++---
|
||||
qtfs/qtfs_server/qtfs-server.c | 57 +++++++++++++++++-----------------
|
||||
qtfs/qtfs_server/qtfs-server.h | 2 +-
|
||||
6 files changed, 49 insertions(+), 48 deletions(-)
|
||||
|
||||
diff --git a/qtfs/include/conn.h b/qtfs/include/conn.h
|
||||
index 5f74a46..aaf746c 100644
|
||||
--- a/qtfs/include/conn.h
|
||||
+++ b/qtfs/include/conn.h
|
||||
@@ -206,7 +206,7 @@ struct qtfs_wl_cap {
|
||||
};
|
||||
|
||||
struct qtfs_wl {
|
||||
- rwlock_t rwlock;
|
||||
+ struct rw_semaphore rwlock;
|
||||
struct qtfs_wl_cap cap[QTFS_WHITELIST_MAX];
|
||||
};
|
||||
|
||||
diff --git a/qtfs/qtfs_common/conn.c b/qtfs/qtfs_common/conn.c
|
||||
index fd5f654..1569bf8 100644
|
||||
--- a/qtfs/qtfs_common/conn.c
|
||||
+++ b/qtfs/qtfs_common/conn.c
|
||||
@@ -116,7 +116,7 @@ static int qtfs_uds_remote_whitelist(char *path)
|
||||
int i;
|
||||
int ret = 1;
|
||||
struct qtfs_wl_cap *cap;
|
||||
- read_lock(&g_qtfs_wl.rwlock);
|
||||
+ down_read(&g_qtfs_wl.rwlock);
|
||||
cap = &g_qtfs_wl.cap[QTFS_WHITELIST_UDSCONNECT];
|
||||
for (i = 0; i < cap->nums; i++) {
|
||||
if (qtfs_white_list_match(path, cap->item[i], strlen(cap->item[i]), WHITELIST_MATCH_PREFIX)) {
|
||||
@@ -124,7 +124,7 @@ static int qtfs_uds_remote_whitelist(char *path)
|
||||
break;
|
||||
}
|
||||
}
|
||||
- read_unlock(&g_qtfs_wl.rwlock);
|
||||
+ up_read(&g_qtfs_wl.rwlock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
diff --git a/qtfs/qtfs_common/misc.c b/qtfs/qtfs_common/misc.c
|
||||
index 3adfb57..1c57a85 100644
|
||||
--- a/qtfs/qtfs_common/misc.c
|
||||
+++ b/qtfs/qtfs_common/misc.c
|
||||
@@ -137,7 +137,7 @@ void qtfs_req_size(void)
|
||||
void qtfs_whitelist_initset(void)
|
||||
{
|
||||
int type;
|
||||
- rwlock_init(&g_qtfs_wl.rwlock);
|
||||
+ init_rwsem(&g_qtfs_wl.rwlock);
|
||||
for (type = 0; type < QTFS_WHITELIST_MAX; type++) {
|
||||
memset(&g_qtfs_wl.cap[type], 0, sizeof(struct qtfs_wl_cap));
|
||||
}
|
||||
@@ -158,7 +158,7 @@ static int qtfs_whitelist_add(struct qtfs_wl_item *uitem)
|
||||
{
|
||||
// uitem->type is checked
|
||||
struct qtfs_wl_cap *cap = &g_qtfs_wl.cap[uitem->type];
|
||||
- write_lock(&g_qtfs_wl.rwlock);
|
||||
+ down_write(&g_qtfs_wl.rwlock);
|
||||
if (cap->nums >= QTFS_WL_MAX_NUM) {
|
||||
qtfs_err("qtfs add white list failed, nums:%u reach upper limit:%d", cap->nums, QTFS_WL_MAX_NUM);
|
||||
goto err_end;
|
||||
@@ -178,11 +178,11 @@ static int qtfs_whitelist_add(struct qtfs_wl_item *uitem)
|
||||
}
|
||||
qtfs_info("Successed to add white list type:%u len:%u path:[%s]", uitem->type, uitem->len, cap->item[cap->nums]);
|
||||
cap->nums++;
|
||||
- write_unlock(&g_qtfs_wl.rwlock);
|
||||
+ up_write(&g_qtfs_wl.rwlock);
|
||||
return 0;
|
||||
|
||||
err_end:
|
||||
- write_unlock(&g_qtfs_wl.rwlock);
|
||||
+ up_write(&g_qtfs_wl.rwlock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ static int qtfs_whitelist_del(struct qtfs_wl_item *uitem)
|
||||
{
|
||||
// type is checked
|
||||
struct qtfs_wl_cap *cap = &g_qtfs_wl.cap[uitem->type];
|
||||
- write_lock(&g_qtfs_wl.rwlock);
|
||||
+ down_write(&g_qtfs_wl.rwlock);
|
||||
if (uitem->index >= cap->nums) {
|
||||
qtfs_err("White list del type:%u nums:%u, invalid index:%u", uitem->type, cap->nums, uitem->index);
|
||||
goto err_end;
|
||||
@@ -206,10 +206,10 @@ static int qtfs_whitelist_del(struct qtfs_wl_item *uitem)
|
||||
qtfs_info("white list del type:%u total nums:%u delindex:%u", uitem->type, cap->nums, uitem->index);
|
||||
|
||||
cap->nums--;
|
||||
- write_unlock(&g_qtfs_wl.rwlock);
|
||||
+ up_write(&g_qtfs_wl.rwlock);
|
||||
return 0;
|
||||
err_end:
|
||||
- write_unlock(&g_qtfs_wl.rwlock);
|
||||
+ up_write(&g_qtfs_wl.rwlock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ static int qtfs_whitelist_get(struct qtfs_wl_item *uitem)
|
||||
// type is checked
|
||||
struct qtfs_wl_cap *cap = &g_qtfs_wl.cap[uitem->type];
|
||||
int len;
|
||||
- read_lock(&g_qtfs_wl.rwlock);
|
||||
+ down_read(&g_qtfs_wl.rwlock);
|
||||
if (uitem->index >= cap->nums) {
|
||||
qtfs_err("query white list invalid index:%u type:%u total nums:%u", uitem->index, uitem->type, cap->nums);
|
||||
goto err_end;
|
||||
@@ -233,11 +233,11 @@ static int qtfs_whitelist_get(struct qtfs_wl_item *uitem)
|
||||
goto err_end;
|
||||
}
|
||||
qtfs_info("white list query type:%u total nums:%u index:%u len:%d", uitem->type, cap->nums, uitem->index, len);
|
||||
- read_unlock(&g_qtfs_wl.rwlock);
|
||||
+ up_read(&g_qtfs_wl.rwlock);
|
||||
return 0;
|
||||
|
||||
err_end:
|
||||
- read_unlock(&g_qtfs_wl.rwlock);
|
||||
+ up_read(&g_qtfs_wl.rwlock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ void qtfs_whitelist_clearall(void)
|
||||
struct qtfs_wl_cap *cap = NULL;
|
||||
int type;
|
||||
int item;
|
||||
- write_lock(&g_qtfs_wl.rwlock);
|
||||
+ down_write(&g_qtfs_wl.rwlock);
|
||||
for (type = 0; type < QTFS_WHITELIST_MAX; type++) {
|
||||
cap = &g_qtfs_wl.cap[type];
|
||||
for (item = 0; item < cap->nums; item++) {
|
||||
@@ -255,7 +255,7 @@ void qtfs_whitelist_clearall(void)
|
||||
}
|
||||
cap->nums = 0;
|
||||
}
|
||||
- write_unlock(&g_qtfs_wl.rwlock);
|
||||
+ up_write(&g_qtfs_wl.rwlock);
|
||||
return;
|
||||
}
|
||||
|
||||
diff --git a/qtfs/qtfs_server/fsops.c b/qtfs/qtfs_server/fsops.c
|
||||
index f2f3749..f0dce2c 100644
|
||||
--- a/qtfs/qtfs_server/fsops.c
|
||||
+++ b/qtfs/qtfs_server/fsops.c
|
||||
@@ -62,7 +62,7 @@ static bool _in_white_list(char *path, int type, int match_type)
|
||||
return false;
|
||||
}
|
||||
|
||||
- read_lock(&g_qtfs_wl.rwlock);
|
||||
+ down_read(&g_qtfs_wl.rwlock);
|
||||
cap = &g_qtfs_wl.cap[type];
|
||||
for (i = 0; i < cap->nums; i++) {
|
||||
if (qtfs_white_list_match(path, cap->item[i], strlen(cap->item[i]), match_type)) {
|
||||
@@ -70,7 +70,7 @@ static bool _in_white_list(char *path, int type, int match_type)
|
||||
break;
|
||||
}
|
||||
}
|
||||
- read_unlock(&g_qtfs_wl.rwlock);
|
||||
+ up_read(&g_qtfs_wl.rwlock);
|
||||
return in_wl != -1;
|
||||
}
|
||||
|
||||
@@ -1736,12 +1736,12 @@ int qtfs_conn_server_run(struct qtfs_conn_var_s *pvar)
|
||||
qtfs_err("qtfs server req type:%u precheck failed.", req->type);
|
||||
goto out;
|
||||
}
|
||||
- read_lock(&g_userp_rwlock);
|
||||
+ down_read(&g_userp_rwlock);
|
||||
arg.userp = &qtfs_userps[pvar->cur_threadidx];
|
||||
if (arg.userp->userp == NULL || arg.userp->userp2 == NULL)
|
||||
qtfs_err("server run userp or userp2 is invalid");
|
||||
rsp->len = qtfs_server_handles[req->type].handle(&arg);
|
||||
- read_unlock(&g_userp_rwlock);
|
||||
+ up_read(&g_userp_rwlock);
|
||||
rsp->type = req->type;
|
||||
rsp->err = QTFS_OK;
|
||||
totalproc++;
|
||||
diff --git a/qtfs/qtfs_server/qtfs-server.c b/qtfs/qtfs_server/qtfs-server.c
|
||||
index 48248ba..f7907ca 100644
|
||||
--- a/qtfs/qtfs_server/qtfs-server.c
|
||||
+++ b/qtfs/qtfs_server/qtfs-server.c
|
||||
@@ -28,7 +28,7 @@
|
||||
#define QTFS_EPOLL_RETRY_INTVL 500 // unit ms
|
||||
|
||||
int qtfs_server_thread_run = 1;
|
||||
-DEFINE_RWLOCK(g_userp_rwlock);
|
||||
+struct rw_semaphore g_userp_rwlock;
|
||||
struct qtserver_fd_bitmap qtfs_fd_bitmap;
|
||||
|
||||
long qtfs_server_misc_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
|
||||
@@ -44,18 +44,18 @@ struct qtfs_server_epoll_s qtfs_epoll = {
|
||||
.events = NULL,
|
||||
.kevents = NULL,
|
||||
};
|
||||
-rwlock_t qtfs_epoll_rwlock;
|
||||
+struct rw_semaphore qtfs_epoll_rwlock;
|
||||
|
||||
void qtfs_server_epoll_exit(void)
|
||||
{
|
||||
- write_lock(&qtfs_epoll_rwlock);
|
||||
+ down_write(&qtfs_epoll_rwlock);
|
||||
if (qtfs_epoll.kevents == NULL) {
|
||||
- write_unlock(&qtfs_epoll_rwlock);
|
||||
+ up_write(&qtfs_epoll_rwlock);
|
||||
return;
|
||||
}
|
||||
kfree(qtfs_epoll.kevents);
|
||||
qtfs_epoll.kevents = NULL;
|
||||
- write_unlock(&qtfs_epoll_rwlock);
|
||||
+ up_write(&qtfs_epoll_rwlock);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -211,35 +211,35 @@ long qtfs_server_misc_ioctl(struct file *file, unsigned int cmd, unsigned long a
|
||||
} else {
|
||||
qtfs_conn_put_param(pvar);
|
||||
}
|
||||
- if (!write_trylock(&g_userp_rwlock)) {
|
||||
+ if (!down_write_trylock(&g_userp_rwlock)) {
|
||||
qtfs_err("try lock userps failed.");
|
||||
return QTERROR;
|
||||
}
|
||||
if (qtfs_server_fd_bitmap_init() < 0) {
|
||||
qtfs_err("fd bitmap init failed.");
|
||||
- write_unlock(&g_userp_rwlock);
|
||||
+ up_write(&g_userp_rwlock);
|
||||
return QTERROR;
|
||||
}
|
||||
if (copy_from_user(&init_userp, (void __user *)arg, sizeof(struct qtfs_thread_init_s))) {
|
||||
qtfs_err("qtfs ioctl thread init copy from user failed.");
|
||||
- write_unlock(&g_userp_rwlock);
|
||||
+ up_write(&g_userp_rwlock);
|
||||
return QTERROR;
|
||||
}
|
||||
if (qtfs_userps == NULL || init_userp.thread_nums > QTFS_MAX_THREADS || init_userp.thread_nums == 0) {
|
||||
qtfs_err("qtfs ioctl thread init userps invalid thread nums:%d.", init_userp.thread_nums);
|
||||
- write_unlock(&g_userp_rwlock);
|
||||
+ up_write(&g_userp_rwlock);
|
||||
return QTERROR;
|
||||
}
|
||||
memset(qtfs_userps, 0, QTFS_MAX_THREADS * sizeof(struct qtfs_server_userp_s));
|
||||
if (init_userp.thread_nums > QTFS_MAX_THREADS) {
|
||||
qtfs_err("qtfs ioctl thread init invalid input thread_num:%d", init_userp.thread_nums);
|
||||
- write_unlock(&g_userp_rwlock);
|
||||
+ up_write(&g_userp_rwlock);
|
||||
return QTERROR;
|
||||
}
|
||||
if (copy_from_user(qtfs_userps, (void __user *)init_userp.userp,
|
||||
init_userp.thread_nums * sizeof(struct qtfs_server_userp_s))) {
|
||||
qtfs_err("qtfs ioctl thread init copy from userp failed.");
|
||||
- write_unlock(&g_userp_rwlock);
|
||||
+ up_write(&g_userp_rwlock);
|
||||
return QTERROR;
|
||||
}
|
||||
for (i = 0; i < init_userp.thread_nums; i++) {
|
||||
@@ -248,12 +248,12 @@ long qtfs_server_misc_ioctl(struct file *file, unsigned int cmd, unsigned long a
|
||||
!access_ok(qtfs_userps[i].userp2, qtfs_userps[i].size)) {
|
||||
qtfs_err("userp set failed");
|
||||
ret = QTERROR;
|
||||
- write_unlock(&g_userp_rwlock);
|
||||
+ up_write(&g_userp_rwlock);
|
||||
break;
|
||||
}
|
||||
qtfs_info("userp set idx:%d size:%lu", i, qtfs_userps[i].size);
|
||||
}
|
||||
- write_unlock(&g_userp_rwlock);
|
||||
+ up_write(&g_userp_rwlock);
|
||||
break;
|
||||
case QTFS_IOCTL_THREAD_RUN:
|
||||
pvar = qtfs_conn_get_param();
|
||||
@@ -268,7 +268,7 @@ long qtfs_server_misc_ioctl(struct file *file, unsigned int cmd, unsigned long a
|
||||
qtfs_conn_put_param(pvar);
|
||||
break;
|
||||
case QTFS_IOCTL_EPFDSET:
|
||||
- write_lock(&qtfs_epoll_rwlock);
|
||||
+ down_write(&qtfs_epoll_rwlock);
|
||||
if (qtfs_epoll.kevents != NULL) {
|
||||
kfree(qtfs_epoll.kevents);
|
||||
qtfs_epoll.kevents = NULL;
|
||||
@@ -276,25 +276,25 @@ long qtfs_server_misc_ioctl(struct file *file, unsigned int cmd, unsigned long a
|
||||
if (copy_from_user(&qtfs_epoll, (void __user *)arg, sizeof(struct qtfs_server_epoll_s))) {
|
||||
qtfs_err("copy epoll struct from arg failed.");
|
||||
ret = QTERROR;
|
||||
- write_unlock(&qtfs_epoll_rwlock);
|
||||
+ up_write(&qtfs_epoll_rwlock);
|
||||
break;
|
||||
}
|
||||
if (qtfs_epoll.event_nums > QTFS_MAX_EPEVENTS_NUM || qtfs_epoll.event_nums == 0) {
|
||||
qtfs_err("epoll arg set failed, event nums:%d too big", qtfs_epoll.event_nums);
|
||||
ret = QTERROR;
|
||||
- write_unlock(&qtfs_epoll_rwlock);
|
||||
+ up_write(&qtfs_epoll_rwlock);
|
||||
break;
|
||||
}
|
||||
if (qtfs_epoll.epfd < 3) {
|
||||
qtfs_err("epoll epfd set failed, epfd:%d should be greater than 2", qtfs_epoll.epfd);
|
||||
ret = QTERROR;
|
||||
- write_unlock(&qtfs_epoll_rwlock);
|
||||
+ up_write(&qtfs_epoll_rwlock);
|
||||
break;
|
||||
}
|
||||
if (!access_ok(qtfs_epoll.events, qtfs_epoll.event_nums * sizeof(struct epoll_event))) {
|
||||
qtfs_err("epoll events set failed, check pointer of qtfs_epoll.events failed");
|
||||
ret = QTERROR;
|
||||
- write_unlock(&qtfs_epoll_rwlock);
|
||||
+ up_write(&qtfs_epoll_rwlock);
|
||||
break;
|
||||
}
|
||||
qtfs_info("epoll arg set, epfd:%d event nums:%d events.",
|
||||
@@ -304,31 +304,31 @@ long qtfs_server_misc_ioctl(struct file *file, unsigned int cmd, unsigned long a
|
||||
if (qtfs_epoll.kevents == NULL) {
|
||||
qtfs_err("epoll kernel events kmalloc failed.");
|
||||
ret = QTERROR;
|
||||
- write_unlock(&qtfs_epoll_rwlock);
|
||||
+ up_write(&qtfs_epoll_rwlock);
|
||||
break;
|
||||
}
|
||||
- write_unlock(&qtfs_epoll_rwlock);
|
||||
+ up_write(&qtfs_epoll_rwlock);
|
||||
break;
|
||||
case QTFS_IOCTL_EPOLL_THREAD_INIT:
|
||||
#ifdef EPOLL_PROXY
|
||||
- write_lock(&qtfs_epoll_rwlock);
|
||||
+ down_write(&qtfs_epoll_rwlock);
|
||||
ret = qtfs_server_epoll_init();
|
||||
- write_unlock(&qtfs_epoll_rwlock);
|
||||
+ up_write(&qtfs_epoll_rwlock);
|
||||
#else
|
||||
qtfs_warn("Qtfs not support epoll proxy, please compile with EPOLL_PROXY=1 to enable it.");
|
||||
#endif
|
||||
break;
|
||||
case QTFS_IOCTL_EPOLL_THREAD_RUN:
|
||||
#ifdef EPOLL_PROXY
|
||||
- write_lock(&qtfs_epoll_rwlock);
|
||||
+ down_write(&qtfs_epoll_rwlock);
|
||||
if (qtfs_epoll_var == NULL) {
|
||||
qtfs_err("qtfs epoll thread run failed, var is invalid.");
|
||||
ret = QTERROR;
|
||||
- write_unlock(&qtfs_epoll_rwlock);
|
||||
+ up_write(&qtfs_epoll_rwlock);
|
||||
break;
|
||||
}
|
||||
ret = qtfs_server_epoll_thread(qtfs_epoll_var);
|
||||
- write_unlock(&qtfs_epoll_rwlock);
|
||||
+ up_write(&qtfs_epoll_rwlock);
|
||||
if (ret == QTEXIT) {
|
||||
qtfs_info("qtfs epoll thread exit.");
|
||||
qtfs_epoll_cut_conn(qtfs_epoll_var);
|
||||
@@ -367,9 +367,10 @@ long qtfs_server_misc_ioctl(struct file *file, unsigned int cmd, unsigned long a
|
||||
static int __init qtfs_server_init(void)
|
||||
{
|
||||
qtfs_log_init(qtfs_log_level, sizeof(qtfs_log_level));
|
||||
+ init_rwsem(&g_userp_rwlock);
|
||||
if (qtfs_kallsyms_hack_init() != 0)
|
||||
return -1;
|
||||
- rwlock_init(&qtfs_epoll_rwlock);
|
||||
+ init_rwsem(&qtfs_epoll_rwlock);
|
||||
qtfs_whitelist_initset();
|
||||
|
||||
qtfs_diag_info = (struct qtinfo *)kmalloc(sizeof(struct qtinfo), GFP_KERNEL);
|
||||
@@ -426,7 +427,7 @@ static void __exit qtfs_server_exit(void)
|
||||
kfree(qtfs_diag_info);
|
||||
qtfs_diag_info = NULL;
|
||||
}
|
||||
- write_lock(&g_userp_rwlock);
|
||||
+ down_write(&g_userp_rwlock);
|
||||
if (qtfs_userps != NULL) {
|
||||
kfree(qtfs_userps);
|
||||
qtfs_userps = NULL;
|
||||
@@ -436,7 +437,7 @@ static void __exit qtfs_server_exit(void)
|
||||
qtfs_fd_bitmap.bitmap = NULL;
|
||||
qtfs_fd_bitmap.nbits = 0;
|
||||
}
|
||||
- write_unlock(&g_userp_rwlock);
|
||||
+ up_write(&g_userp_rwlock);
|
||||
qtfs_whitelist_exit();
|
||||
qtfs_server_epoll_exit();
|
||||
|
||||
diff --git a/qtfs/qtfs_server/qtfs-server.h b/qtfs/qtfs_server/qtfs-server.h
|
||||
index 8135dbb..fa49ad9 100644
|
||||
--- a/qtfs/qtfs_server/qtfs-server.h
|
||||
+++ b/qtfs/qtfs_server/qtfs-server.h
|
||||
@@ -17,7 +17,7 @@
|
||||
extern int qtfs_server_thread_run;
|
||||
extern struct qtfs_server_epoll_s qtfs_epoll;
|
||||
extern int qtfs_mod_exiting;
|
||||
-extern rwlock_t g_userp_rwlock;
|
||||
+extern struct rw_semaphore g_userp_rwlock;
|
||||
extern struct qtserver_fd_bitmap qtfs_fd_bitmap;
|
||||
|
||||
struct qtserver_arg {
|
||||
--
|
||||
2.39.2 (Apple Git-143)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Name: dpu-utilities
|
||||
Summary: openEuler dpu utilities
|
||||
Version: 1.5
|
||||
Release: 1
|
||||
Version: 1.10
|
||||
Release: 7
|
||||
License: GPL-2.0
|
||||
Source: https://gitee.com/openeuler/dpu-utilities/repository/archive/v%{version}.tar.gz
|
||||
ExclusiveOS: linux
|
||||
@ -13,6 +13,13 @@ Provides: %{name} = %{version}-%{release}
|
||||
%define kernel_version %(ver=`rpm -qa|grep kernel-devel`;echo ${ver#*kernel-devel-})
|
||||
BuildRequires: kernel-devel >= 5.10, gcc, make, json-c-devel, glib2-devel
|
||||
|
||||
Patch1: 0001-refactor-syscall-wrapper-for-aarch64-reduce-the-memo.patch
|
||||
Patch2: 0002-fix-readdir-bug-in-devtmpfs.patch
|
||||
Patch3: 0003-Change-the-maximum-number-of-qtfs-links-from-16-to-6.patch
|
||||
Patch4: 0004-add-compile-option-of-EPOLL_PROXY-and-fix-some-probl.patch
|
||||
Patch5: 0005-resolve-migration-issues.patch
|
||||
Patch6: 0006-fix-rwlock-cause-schedule-bug-if-pagefault-or-wait-f.patch
|
||||
|
||||
%description
|
||||
This package contains the software utilities on dpu.
|
||||
|
||||
@ -139,6 +146,48 @@ sed -i '/# product cut_conf/a\dpuos kiwi/minios/cfg_dpuos yes' /opt/imageT
|
||||
sed -i '/<repository_rule>/a\dpuos 1 rpm-dir euler_base' /opt/imageTailor/repos/RepositoryRule.conf
|
||||
|
||||
%changelog
|
||||
* Fri Nov 22 2024 liqiang <liqiang64@huawei.com> 1.10-7
|
||||
- Fix rwlock caused schedule bug, change to semaphore
|
||||
|
||||
* Mon Oct 21 2024 l30022887 <liweiqiang24@huawei.com> 1.10-6
|
||||
- resolve migration issues
|
||||
|
||||
* Tue Sep 10 2024 liqiang <liqiang64@huawei.com> 1.10-5
|
||||
- Add compile option for epoll proxy thread
|
||||
|
||||
* Tue Jul 23 2024 liqiang <liqiang64@huawei.com> 1.10-4
|
||||
- Change the maximum number of qtfs links from 16 to 64
|
||||
|
||||
* Wed Jul 10 2024 liqiang <liqiang64@huawei.com> 1.10-3
|
||||
- Fix readdir bug in devtmpfs
|
||||
|
||||
* Mon Jun 24 2024 liqiang <liqiang64@huawei.com> 1.10-2
|
||||
- Refactor syscall wrapper for aarch64 reduce the memory
|
||||
|
||||
* Fri May 24 2024 liqiang <liqiang64@huawei.com> 1.10-1
|
||||
- Update to v1.10 for some features and bugfix
|
||||
|
||||
* Tue Dec 26 2023 liqiang <liqiang64@huawei.com> 1.6-7
|
||||
- Update recent bugfixes
|
||||
|
||||
* Sat Dec 16 2023 liqiang <liqiang64@huawei.com> 1.6-6
|
||||
- Update readme description and fix a bug
|
||||
|
||||
* Sat Dec 16 2023 liqiang <liqiang64@huawei.com> 1.6-5
|
||||
- fix event misalignment problem
|
||||
|
||||
* Thu Dec 14 2023 liqiang <liqiang64@huawei.com> 1.6-4
|
||||
- Fix suspend and fd leak of fifo
|
||||
|
||||
* Wed Dec 13 2023 liqiang <liqiang64@huawei.com> 1.6-3
|
||||
- Update some bugfix
|
||||
|
||||
* Sat Dec 9 2023 liqiang <liqiang64@huawei.com> 1.6-2
|
||||
- fix some problem of fifo, resolve problem in libvirt
|
||||
|
||||
* Fri Dec 1 2023 Guangxing Deng <dengguangxing@huawei.com> 1.6-1
|
||||
- Upgrade dpu-utilities version to 1.6
|
||||
|
||||
* Thu Nov 23 2023 Guangxing Deng <dengguangxing@huawei.com> 1.5-1
|
||||
- Upgrade dpu-utilities version to 1.5
|
||||
|
||||
|
||||
BIN
v1.10.tar.gz
Normal file
BIN
v1.10.tar.gz
Normal file
Binary file not shown.
BIN
v1.5.tar.gz
BIN
v1.5.tar.gz
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user