rt-thread icon indicating copy to clipboard operation
rt-thread copied to clipboard

[Bug] [DFS] 调用dfs_file_close处基本没有执行vnode->ref_count--操作

Open wdfk-prog opened this issue 2 months ago • 0 comments

RT-Thread Version

master

Hardware Type/Architectures

stm32和07

Develop Toolchain

Other

Describe the bug

  1. 多次使用cat进行open/close同一个文件
  2. 使用list fs观察 计数情况
  3. 发现ref一直在增加,这样就算没有使用这个文件了,这个malloc一直存在
msh /flash/log>list fd
fd type    ref magic  path
-- ------  --- ----- ------
 3 file      3 fdfd  /log/flash_sys.log
 4 file      1 fdfd  /log/motion.log
  1. 原因.dfs_file_close中没有对vnode->ref_count进行减一操作.

  2. 发现vnode->ref_count--操作在fdt_fd_release函数调用.该函数在close中有调用...

  3. 查看DFSV2代码逻辑,应该也有这么问题

  4. 解决方案:

  • 要么把dfs_file_close的调用都检查一遍都加入fdt_fd_release.或者替换为close函数
  • 要么dfs_file_close中加入vnode->ref_count--操作,fdt_fd_release函数中不执行这个逻辑

Other additional context

No response

wdfk-prog avatar Oct 25 '25 07:10 wdfk-prog