13 Star 2 Fork 18

src-openEuler/dpu-utilities

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0002-fix-readdir-bug-in-devtmpfs.patch 1.70 KB
一键复制 编辑 原始数据 按行查看 历史
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)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/dpu-utilities.git
git@gitee.com:src-openeuler/dpu-utilities.git
src-openeuler
dpu-utilities
dpu-utilities
master

搜索帮助