-
Notifications
You must be signed in to change notification settings - Fork 3k
NVStore: add the allocate_key API (instead of set_alloc_key) #6480
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
Conversation
features/nvstore/source/nvstore.h
Outdated
* NVSTORE_NO_FREE_KEY Couldn't allocate a key for this call. | ||
* | ||
*/ | ||
int set_alloc_key(uint16_t &key, uint16_t buf_size, const void *buf); | ||
int allocate_key(uint16_t &key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is indeed, but the replaced function (set_alloc_key
) is a new one that was implemented after the 5.8 release. It's still not even documented. Figured that the API we had defined was wrong in that case, hence the change. Can add the "old" API back, but that that would be just dead code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR contains a breaking change, so marked for 5.9.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's OK. It is mainly used for StorageLite feature, which should be out in 5.9.0.
* @param[in] buf_size Buffer size (bytes). | ||
* @param[in] buf Input Buffer. | ||
* @param[in] flags Record flags. | ||
* | ||
* @returns 0 for success, nonzero for failure. | ||
*/ | ||
int do_set(uint16_t &key, uint16_t buf_size, const void *buf, uint16_t flags); | ||
int do_set(uint16_t key, uint16_t buf_size, const void *buf, uint16_t flags); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not a breaking change, as the function is private (maybe the doxy comments are confusing to think it is not).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I missed the private at the top. Thanks.
Anything missing in order for this PR to move forward (not that I'm trying to push anyone)? |
@cmonr @marcuschangarm I said i didn't have a problem to have this fix on a temporary basis, and try resolving that when I'm back. However, until seeing @cmonr's comment, didn't notice the fact that this was on master, while other changes were on the feature branch. This will prevent me from testing any fix properly, as much of the memory consumption based fixes are based on trial and error (to make sure they work on all boards). Maybe it would be better to move this change to the feature branch as well? |
It is a breaking change, that is correct, but what we missed , @davidsaada to confirm - as this functionality that is changing here was just on master (added after 5.8, only available on master). Therefore the reasoning:
This PR should be considered and reviewed. |
Confirmed - the modified API isn't there even on 5.8.1. It was added to master after the 5.8 release, then when found my mistake, fixed it quickly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one small change
features/nvstore/source/nvstore.cpp
Outdated
@@ -597,16 +599,16 @@ int NVStore::do_get(uint16_t key, uint16_t buf_size, void *buf, uint16_t &actual | |||
} | |||
|
|||
_mutex->lock(); | |||
record_offset = _offset_by_key[key]; | |||
|
|||
record_offset = _offset_by_key[key]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
misaligned- tabs here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange, my editor is setup to insert spaces only. Anyway, fixed it.
2155e86
to
f0c9f19
Compare
49cab79
to
c6d2bdd
Compare
/morph build |
Build : SUCCESSBuild number : 1705 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 1339 |
Test : FAILUREBuild number : 1499 |
/morph test |
Test : SUCCESSBuild number : 1525 |
Waiting on @sg- and @SenRamakri for review. |
@davidsaada Also, this looks like it'll need to go through a rebase. |
Add the allocate_key API. This replaces the previously added set_alloc_key API (which allocates a key and sets the value at the same time). Reason for the change: Key allocation will typically be used by other storage features (like StorageLite), keeping the allocated keys in another location. Previous API created problems in the case key allocation and value setting couldn't be done at the same time (for instance, if the set value was derived from the allocated key, such as hash or CMAC).
ead4901
to
c90182a
Compare
Rebased following merge of PR #6864. No longer depending on that PR. |
/morph build |
Build : SUCCESSBuild number : 2029 Triggering tests/morph test |
Test : FAILUREBuild number : 1835 |
Exporter Build : FAILUREBuild number : 1678 |
/morph test |
/morph export-build |
/morph test |
1 similar comment
/morph test |
Test : SUCCESSBuild number : 1849 |
Test : SUCCESSBuild number : 1851 |
Exporter Build : SUCCESSBuild number : 1687 |
@SenRamakri @0xc0170 Are you happy with the updates ? |
Looks like @0xc0170 was already good with the changes. |
Description
Add the allocate_key API. This replaces the previously added set_alloc_key API (which allocates a key and sets the value at the same time).
Reason for the change: Key allocation will typically be used by other storage features (like StorageLite), keeping the allocated keys in another location. Previous API created problems in the case key allocation and value setting couldn't be done at the same time (for instance, if the set value was derived from the allocated key, such as hash or CMAC).
Pull request type
[ ] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[x] Breaking change