phoenix-rtos / phoenix-rtos-project

Sample project using Phoenix-RTOS
https://phoenix-rtos.com
BSD 3-Clause "New" or "Revised" License
45 stars 32 forks source link

jffs2 readdir skipping entries #1117

Open adamdebek opened 4 months ago

adamdebek commented 4 months ago

During nightly on zynq7000-zedboard, project hash: 6f20df5 was encoutered an error: image There is a check between output of gnu ls and busybox ls, which in our case it's just 2 invocation of busybox ls (which should be fixed), but anyway 2 same execution of ls gave diffrent outputs and it happened in 2 conesecutive testcases, which looks ilke there might be some bug in directory reading in kernel. The issue is hard to reproduce, but if I got some I will put it in the comments section.

adamdebek commented 2 months ago

When directory stream is read the position in this stream with each entry read is incremented by 1. This posistion refers to next element in dirent linked list. But when garbage collector deletes entry which was already read, the linked list shifts but position stayes the same which cause entry which we would next read to fall behind our current postion and that entry will not be seen until next opendir() or rewinddir().

I thought about blocking garbage collector on directory that is currently open, which would fix that, but it entails changing struct jffs2_inode_info by adding variable that would count opened streams on directory but it causes errors in other parts of jffs2. Maybe someone will come up with better solution.

Key functions to look at: