1 Star 0 Fork 25

mszjaas/nfs-utils_1

forked from src-openEuler/nfs-utils 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0004-export-move-cache_open-before-workers-are-forked.patch 2.35 KB
一键复制 编辑 原始数据 按行查看 历史
wguanghao 提交于 2024-01-10 09:57 . upgrade version to 2.6.3
From e115a6edfaa07203c6d6d40eba9e4f097efe0cf2 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.de>
Date: Wed, 25 Oct 2023 12:40:24 -0400
Subject: [PATCH] export: move cache_open() before workers are forked.
If each worker has a separate open on a cache channel, then each worker
will potentially receive every upcall request resulting in duplicated
work.
A worker will only not see a request that another worker sees if that
other worker answers the request before this worker gets a chance to
read it.
To avoid duplicate effort between threads and so get maximum benefit
from multiple threads, open the cache channels before forking.
Note that the kernel provides locking so that only one thread can be
reading to writing to any channel at any given moment.
Fixes: 5fc3bac9e0c3 ("mountd: Ensure we don't share cache file descriptors among processes.")
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Steve Dickson <steved@redhat.com>
---
utils/exportd/exportd.c | 8 ++++++--
utils/mountd/mountd.c | 8 ++++++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/utils/exportd/exportd.c b/utils/exportd/exportd.c
index 2dd12cb..6f86644 100644
--- a/utils/exportd/exportd.c
+++ b/utils/exportd/exportd.c
@@ -289,12 +289,16 @@ main(int argc, char **argv)
else if (num_threads > MAX_THREADS)
num_threads = MAX_THREADS;
+ /* Open cache channel files BEFORE forking so each upcall is
+ * only handled by one thread. Kernel provides locking for both
+ * read and write.
+ */
+ cache_open();
+
if (num_threads > 1)
fork_workers();
- /* Open files now to avoid sharing descriptors among forked processes */
- cache_open();
v4clients_init();
/* Process incoming upcalls */
diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c
index bcf749f..f9c62cd 100644
--- a/utils/mountd/mountd.c
+++ b/utils/mountd/mountd.c
@@ -916,12 +916,16 @@ main(int argc, char **argv)
else if (num_threads > MAX_THREADS)
num_threads = MAX_THREADS;
+ /* Open cache channel files BEFORE forking so each upcall is
+ * only handled by one thread. Kernel provides locking for both
+ * read and write.
+ */
+ cache_open();
+
if (num_threads > 1)
fork_workers();
nfsd_path_init();
- /* Open files now to avoid sharing descriptors among forked processes */
- cache_open();
v4clients_init();
xlog(L_NOTICE, "Version " VERSION " starting");
--
1.8.3.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mszjaas/nfs-utils_1.git
git@gitee.com:mszjaas/nfs-utils_1.git
mszjaas
nfs-utils_1
nfs-utils_1
master

搜索帮助