Skip to content

Conversation

mzagrabski
Copy link

Introduce lfs_fs_gc via api call fc_gc.

Copy link

dkalowsk
dkalowsk previously approved these changes Aug 22, 2025
Copy link
Contributor

@dkalowsk dkalowsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a nice clean set of changes to me. Thanks for the addition!

Copy link
Contributor

@de-nordic de-nordic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API call requires test case.
Changes requested.

* @param path Path to the file or directory.
* @return 0 on success, negative errno code on fail.
*/
int (*gc)(struct fs_mount_t *mountp, const char *path);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No path, only mount point. Unless you have an implementation case for it, but you do not in this PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleared implementation, removed path entirely.

* @retval -ENOTSUP when not implemented by underlying file system driver;
* @retval <0 an other negative errno code on error.
*/
int fs_gc(const char *path);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this to something like 'fs_gc_by_path' or similar; I would rather have short name, default one, to be reserved for gc by mount point object pointer.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed logic, so now fs_gc accepts mount point pointer.

.mkdir = littlefs_mkdir,
.stat = littlefs_stat,
.statvfs = littlefs_statvfs,
.gc = littlefs_gc,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be default. Most systems do not have this.
I would rather guard this by Kconfig option, selectable by systems that support it, and on included on demand by users that need the call.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guarded new functions by CONFIG_FILE_SYSTEM_GC, default n.

@dkalowsk
Copy link
Contributor

dkalowsk commented Sep 9, 2025

@mzagrabski are you able to address the change requests?

@mzagrabski
Copy link
Author

@de-nordic Added very simple test case for new api call, let me know if you would like to see more complex test case here.

dkalowsk
dkalowsk previously approved these changes Oct 9, 2025

config FILE_SYSTEM_GC
bool "Allow explicit garbage collector call"
default n
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually we do not set "default n", that is actually default.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mzagrabski - can you address this review comment please?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cfriedt both issues fixed


fs_lock(fs);

ssize_t ret = lfs_fs_gc(lfs);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to define variables on top of the function.

de-nordic
de-nordic previously approved these changes Oct 9, 2025
Copy link
Contributor

@de-nordic de-nordic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK.
Comments left, but can be addressed later.

@de-nordic de-nordic added this to the v4.3.0 milestone Oct 9, 2025
Copy link
Member

@cfriedt cfriedt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporary nak to remove the default n

Lfs provide lfs_fs_gc function for some time now.
Function allow offloading of expensive block allocation scan.

Introduce lfs_fs_gc via api call fc_gc.

Signed-off-by: Maciej Zagrabski <[email protected]>
@mzagrabski mzagrabski dismissed stale reviews from de-nordic and dkalowsk via b054935 October 10, 2025 09:42
@zephyrbot zephyrbot added the area: Tests Issues related to a particular existing or missing test label Oct 10, 2025
Copy link

@mzagrabski mzagrabski requested a review from cfriedt October 10, 2025 10:24
@cfriedt cfriedt merged commit b69b064 into zephyrproject-rtos:main Oct 10, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: File System area: Tests Issues related to a particular existing or missing test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants