Skip to content

Conversation

@MirkoCovizzi
Copy link
Contributor

@MirkoCovizzi MirkoCovizzi commented Nov 17, 2025

Removes global callbacks array and replaces with callback
member inside struct bm_zms_fs.
This fixes a bug where registering multiple callbacks on
the same struct bm_zms_fs would update the user reference
number incrementally and saturate the global callbacks array.
When calling bm_zms_clear, this would only reset to NULL
the last callback set, leaving the rest still set.
This update makes it so that there can only be one callback
per each struct bm_zms_fs instance, mirroring the behavior
of other libraries.
Due to this change, also removes the BM_ZMS_MAX_USERS
Kconfig option.

@MirkoCovizzi MirkoCovizzi self-assigned this Nov 17, 2025
@MirkoCovizzi MirkoCovizzi requested review from a team and rghaddab as code owners November 17, 2025 14:07
@github-actions github-actions bot added the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Nov 17, 2025
@MirkoCovizzi MirkoCovizzi added changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. and removed changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. labels Nov 17, 2025
@github-actions
Copy link

You can find the documentation preview for this PR here.

@MirkoCovizzi MirkoCovizzi force-pushed the zms-register-refactor branch 3 times, most recently from 27aa479 to 564795f Compare November 17, 2025 14:14
@MirkoCovizzi MirkoCovizzi requested a review from a team as a code owner November 17, 2025 14:14
@github-actions github-actions bot added doc-required PR must not be merged without tech writer approval. and removed changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. labels Nov 17, 2025
Removes global callbacks array and replaces with callback
member inside `struct bm_zms_fs`.
This fixes a bug where registering multiple callbacks on
the same `struct bm_zms_fs` would update the user reference
number incrementally and saturate the global callbacks array.
When calling `bm_zms_clear`, this would only reset to NULL
the last callback set, leaving the rest still set.
This update makes it so that there can only be one callback
per each `struct bm_zms_fs` instance, mirroring the behavior
of other libraries.
Due to this change, also removes the `BM_ZMS_MAX_USERS`
Kconfig option.

Signed-off-by: Mirko Covizzi <[email protected]>
Cleans up Doxygen.

Signed-off-by: Mirko Covizzi <[email protected]>
@rghaddab
Copy link
Contributor

@MirkoCovizzi I do not understand this bug.
The current bm_zms behavior should be that only one callback is registered for a bm_zms_fs structure.
The caller will get its user_num which indicates its order in the callback register.
No other bm_zms_register should be called on the same structure before clearing the previous one.
Can you detail the usecases where this could happen ?

@lemrey
Copy link
Contributor

lemrey commented Nov 18, 2025

I suppose that's one way to fix it. It does however add one limitation, which is that only the owner of an instance can receive callbacks from it, thus forcing a single owner for each instance. In practice, it is no longer possible to share a partition, every instance would need its own.

But it may be fine, first, because there a no events that are relevant for the whole application (like GC was). And second, because the application could still be designed in a way that allows to share a partition, by wrapping NVM operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-required PR must not be merged without tech writer approval.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants