From 42fa65e11ec230b61df2340c51879ce31d51e60c Mon Sep 17 00:00:00 2001 From: liqiang Date: Wed, 10 Jul 2024 15:19:23 +0800 Subject: [PATCH] fix readdir problem in devtmpfs Signed-off-by: liqiang --- 0002-fix-readdir-bug-in-devtmpfs.patch | 45 ++++++++++++++++++++++++++ dpu-utilities.spec | 6 +++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 0002-fix-readdir-bug-in-devtmpfs.patch diff --git a/0002-fix-readdir-bug-in-devtmpfs.patch b/0002-fix-readdir-bug-in-devtmpfs.patch new file mode 100644 index 0000000..c49680b --- /dev/null +++ b/0002-fix-readdir-bug-in-devtmpfs.patch @@ -0,0 +1,45 @@ +From 645c009ced7f759d0d26c6f0a0b53a084cf82db5 Mon Sep 17 00:00:00 2001 +From: liqiang +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 +--- + 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) + diff --git a/dpu-utilities.spec b/dpu-utilities.spec index 43372b8..7197cd7 100644 --- a/dpu-utilities.spec +++ b/dpu-utilities.spec @@ -1,7 +1,7 @@ Name: dpu-utilities Summary: openEuler dpu utilities Version: 1.10 -Release: 2 +Release: 3 License: GPL-2.0 Source: https://gitee.com/openeuler/dpu-utilities/repository/archive/v%{version}.tar.gz ExclusiveOS: linux @@ -14,6 +14,7 @@ Provides: %{name} = %{version}-%{release} 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 %description This package contains the software utilities on dpu. @@ -141,6 +142,9 @@ sed -i '/# product cut_conf/a\dpuos kiwi/minios/cfg_dpuos yes' /opt/imageT sed -i '//a\dpuos 1 rpm-dir euler_base' /opt/imageTailor/repos/RepositoryRule.conf %changelog +* Wed Jul 10 2024 liqiang 1.10-3 +- Fix readdir bug in devtmpfs + * Mon Jun 24 2024 liqiang 1.10-2 - Refactor syscall wrapper for aarch64 reduce the memory -- Gitee