fix readdir problem in devtmpfs

Signed-off-by: liqiang <liqiang64@huawei.com>
This commit is contained in:
liqiang 2024-07-10 15:19:23 +08:00
parent 4f035a807b
commit 42fa65e11e
2 changed files with 50 additions and 1 deletions

View 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)

View File

@ -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 '/<repository_rule>/a\dpuos 1 rpm-dir euler_base' /opt/imageTailor/repos/RepositoryRule.conf
%changelog
* 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