Skip to content
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

fs: littlefs: Fix cache and lookahead size checks in littlefs_fs for block devices #82880

Conversation

DNedic
Copy link
Contributor

@DNedic DNedic commented Dec 11, 2024

This fixes an issue where wrong values were checked against block device defaults. Kconfig values are used when no filesystem config values are provided, and the buffers are sized according to the Kconfig values, but the checks were only performed against filesystem instance specific config variables.

@DNedic
Copy link
Contributor Author

DNedic commented Dec 11, 2024

I'm interested in why cache and lookahead buffer values are being reduced, especially when buffers have been already assigned.

@DNedic DNedic force-pushed the fs/littlefs/fix_block_device_size_checks branch from 17bfe5d to e729977 Compare December 11, 2024 19:52
This fixes an issue where wrong values were checked against block device
defaults. Kconfig values are used when no filesystem config values are
provided, and the buffers are sized according to the Kconfig values,
but the checks were only performed against filesystem config variables.

Signed-off-by: Djordje Nedic <[email protected]>
@DNedic DNedic force-pushed the fs/littlefs/fix_block_device_size_checks branch from e729977 to 84c3740 Compare December 11, 2024 19:56
@de-nordic
Copy link
Collaborator

I'm interested in why cache and lookahead buffer values are being reduced, especially when buffers have been already assigned.

To align with block size of a device: 09574e6

@de-nordic
Copy link
Collaborator

This fixes an issue where wrong values were checked against block device defaults. Kconfig values are used when no filesystem config values are provided, and the buffers are sized according to the Kconfig values, but the checks were only performed against filesystem config variables.

The default are only used when not instance specific not provided.

@DNedic
Copy link
Contributor Author

DNedic commented Dec 11, 2024

I'm interested in why cache and lookahead buffer values are being reduced, especially when buffers have been already assigned.

To align with block size of a device: 09574e6

In that case wouldn't it make more sense to round down to the closest smaller multiple of block size? With a cache size set to 2047, it will still be reduced to 512 despite 1536 being smaller than 2047 and a multiple of 512.

@DNedic
Copy link
Contributor Author

DNedic commented Dec 11, 2024

This fixes an issue where wrong values were checked against block device defaults. Kconfig values are used when no filesystem config values are provided, and the buffers are sized according to the Kconfig values, but the checks were only performed against filesystem config variables.

The default are only used when not instance specific not provided.

Exactly, however in this case we are only checking against instance specific, which is 0 when nothing is provided.

@de-nordic
Copy link
Collaborator

The default are only used when not instance specific not provided.

Exactly, however in this case we are only checking against instance specific, which is 0 when nothing is provided.

Ah, right. There is a bug because the cache_size serves as test variable that is set between lines 780-784 to either instance specific or default, so the comparison in these lines was not actually testing the right variable in the end.

@DNedic
Copy link
Contributor Author

DNedic commented Dec 11, 2024

I'm also going to submit a new PR to change the block alignment behavior for these values, but it might be better to merge this as a quick fix since it breaks using block devices without instance specific configs or devicetree defined.

@de-nordic de-nordic added bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug Regression Something, which was working, does not anymore backport v4.0-branch Backport to the v4.0-branch labels Dec 12, 2024
@de-nordic de-nordic added this to the v4.1.0 milestone Dec 12, 2024
@Laczen Laczen removed their request for review December 13, 2024 13:51
@kartben kartben merged commit 2750492 into zephyrproject-rtos:main Dec 16, 2024
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: File System backport v4.0-branch Backport to the v4.0-branch bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug Regression Something, which was working, does not anymore
Projects
None yet
5 participants