-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update LittleFS, fix some memory leaks and remove limits to number of opened files #6
Conversation
Forgot to add, that if you disable path storage toward only storing hashes, then |
hey @X-Ryl669 ! I'll review this over the coming days, thanks for the contribution! |
…anymore but instead is based on dynamic allocation. Fix many lock issues (lock not released on error path and so on) Remove the limit to the number of opened file descriptor Some documentation work
Fix tests changes
Ok, I've fixed the conflict with new fsync support, everything should apply correctly from now on. |
I'm making my own tweaks (code comments, checks, other stuff) to your pr on branch pr6. Or is there a way i can directly edit your PR? Regardless, I'll let you know when i'm done fiddling wtih it. |
I've commented in your commits. Overall, that's great additions (and one bug I've missed! Thanks)
There is one mistake about the hash comparison you're removing. Computing hash is not only useful for removing file's path storage, it's also a huge time saver while searching for file based on their file path (a very common operation in the FS).
So when using hashes, you ends up with a much lower computation time with almost no overhead. It's a shame we can't use C++ as we could be even be able to compute hash at compile-time and remove all |
alright @X-Ryl669 I think pr6 is ready. Let me know if you think any changes need to be made before merging to master. The hardest thing to debug was figuring out why the heap was corrupting when disabling |
actually there seems to be some peculiar deadlock when using filepaths; investigating... seems to be related to using filepaths along with my mtime stuff. I'll have to investigate more tomorrow. |
It's a shame because I've did almost the same as you did about enabling heap checking (except that I've enabled heap leaking). I haven't committed those changes since I thought that they are only "test" code and not actual useful code. BTW, there are many leaks in the current code, due to esp-idf allocating locks on-the-fly in the VFS and never deallocating them. Here are the stack for each allocation without deallocation:
For the deadlock you're seeing, I've spot that |
alright, i fixed the deadlock, and i don't think any of those "memory leaks" are real. Wish there was a way to ignore these false positives. |
Seems like it's good to go! |
one last change im making; I'm making HASH_ONLY not the default option; this is just to maintain 100% backwards compatability and to default to a "safer" (barely) option. People can reconfigure this in their menuconfig or sdkconfig.defaults |
This is a large PR, but I can't really split it in smaller one.
I've:
Just a note on how the new table of file descriptor is written:
lfs_file_t
is now a chained list (this is used for deallocating files upon unmounting), and it's not using a static char array anymore for storing file path (if selected in menuconfig, the file path string is allocated at the same time as the file descriptor)void *
). I've removed all the cruft aboutfd_used
bitfield. Do you know that bitfields are useless without#pragma pack
because compiler will align the next field anyway so you're not saving anything here, and also generate more code than plain word usage because of required masking and shifting?acquire_fd
/free_fd
/search_fd
so it does not need recursive mutex anymore, and also not leaking anymore upon error.