Commit Graph

17 Commits

Author SHA1 Message Date
Wyatt Hepler
486ac57fef pw_kvs: Small test cleanup
- Reorder entry_test.cc and add an additional test for Copy.
- Add comments to key_value_store_map_test.cc.

Change-Id: Icd02db02e6a8be63b7a09688c997c3dd72c45ad9
2020-03-13 09:19:23 -07:00
David Rogers
f3884eb9d4 pw_kvs: Fix garbage collection for redundant entries
Fix garbage collection when using redudant entries.
- Improve "find sector to write entry to" and "find sector to GC"
  algorithms so they work better with redundant entries.
- Add support in GC to be aware of partially written keys, where the
  first entry is written to flash, but GC is needed to free space for
  the redundant entries to have space to be written.

Tested with kEntryRedundancy up to 2.

Change-Id: Iff88d970714fa1ece634af926a1838a5f7d5d7e7
2020-03-10 23:18:58 +00:00
Wyatt Hepler
7bc766e0f0 pw_kvs: Map-backed test updates
- Improve logging.
- Check KVS size before and after every operation.

Change-Id: I89c6098323da0186b045b79b2e6589462eb75c3b
2020-03-10 11:28:08 -07:00
David Rogers
a2562b5ebe pw_kvs: Add support for multiple redundant copies of entries
Add support to KVS for storing multiple identical copies of key-value
entries.

Currently only tested for kEntryRedundancy = 1.

Change-Id: Ibb8e5667f1f8406070a8d8854c1145daa76c5aea
2020-03-07 00:35:27 +00:00
Wyatt Hepler
22d0d9fcb0 pw_kvs: Support multiple entry formats
Change-Id: If25ea00210178b8495585a651d3df6ad8347ee82
2020-03-05 17:36:45 -08:00
David Rogers
c8fe1f5748 FIX bad merge: pw_kvs: Add public garbage collection methods and prep for redundancy
- Add public methods to do full garbage collect and partial garbage
  collect.
- Do clean up related to finding sector to write entry to that is in
  preparation for adding redundancy support.

Change-Id: Ib7e43aa8955a292b025cdff712e4af1745229a69
2020-02-28 13:11:39 -08:00
David Rogers
cd87c32d67 pw_kvs: Add public garbage collection methods and prep for redundancy
- Add public methods to do full garbage collect and partial garbage
collect.
- Do clean up related to finding sector to write entry to that is in
preparation for adding redundancy support.

Change-Id: I42686e60ff53a7372303cf61895a4a937dc2bfb9
2020-02-28 20:17:15 +00:00
Wyatt Hepler
88adfe8b91 pw_kvs: Move EntryHeaderFormat to pw_kvs/format.h
- Move EntryHeaderFormat and the EntryHeader struct to pw_kvs/format.h.
- Rename EntryHeaderFormat to EntryFormat.

Change-Id: Ic5e53c688cd3a483101c7985def6e4bef9c3cbaf
2020-02-21 09:34:31 -08:00
Wyatt Hepler
e2a36a25e4 pw_kvs: Map-backed test updates
- Test calling Init() at random points.
- Test using only two sectors and using many smaller sectors.
- Delete tests that will never work, since alignments must be a multiple
  of 16.

Change-Id: Ia2c580ddf81367587f140ededc5ee1b15833e4b7
2020-02-21 17:09:29 +00:00
Wyatt Hepler
bdd8e5a77b pw_kvs: Move entry.h to public/pw_kvs/internal
Move entry.h so that the KeyValueStore class can reference it in the
header.

Change-Id: Ib5a7f194db8dd9af1e8f3d8c9c7c25b8409acfe0
2020-02-20 19:30:47 -08:00
Wyatt Hepler
1fc1104cb5 pw_kvs: Transcation ID and key descriptor refactor
- Switch from per-key versions to a monotonically increasing KVS-global
  transcation ID.
- Move KeyDescriptor and the hash function to their own files.

Change-Id: I05287137579d4fe2d72c6e176969d46006c2aae6
2020-02-20 16:26:27 -08:00
Wyatt Hepler
38ce30f766 pw_kvs: Allow specifying max entries and sectors
Move the KeyDescriptor and SectorDescriptor lists to a templated derived
KeyValueStoreBuffer class. This allows multiple KVSs supporting
different numbers of keys and sectors to exist side-by-side.

Change-Id: I43d0647382e763008ae3b08580c736c1978793dd
2020-02-21 00:25:43 +00:00
Wyatt Hepler
a00d1ef82c pw_kvs: Expand Entry tests; fix issues
- Expand the tests for the KVS entry class.
- Fix a few minor issues found by the tests.

Change-Id: I92b5dd614d2a726c912b7b1bf1f9ebd47a702be4
2020-02-19 11:12:01 -08:00
Wyatt Hepler
cdd6dfcfc6 pw_kvs: FlashMemory updates; test utilities
- Update comments for FlashMemory class.
- Split InMemoryFakeFlash to move the fixed-size buffer into the
  derived FakeFlashBuffer class.
- Support initializing FakeFlashBuffer to data provided at construction.
- Allow direct access to the underlying fake flash buffer for testing.
- Create utilities for working with byte arrays in byte_utils.h.

Change-Id: I90d33621cb91da079d7213fe7d33823494120e48
2020-02-19 19:10:32 +00:00
Wyatt Hepler
e541e075d4 pw_kvs: Move reading and writing to Entry class
- Add the FlashPartition and address to the Entry class.
- Move functions for reading or writing the entry header, key, and value
  to the Entry class.

Change-Id: I0af3c140a519c8b050fcef81eca4f3b45560f75c
2020-02-14 16:21:29 -08:00
Wyatt Hepler
0af6ad9365 pw_kvs: Use key's current state in RelocateEntry
When moving tombstone entries for deleted keys, RelocateEntry would
cause them to become present again.

Expand key_value_store_map_test.cc and add a test that covers this case
specifically.

Change-Id: I846cb155bffb25198377e04752cace971555d32b
2020-02-14 00:50:52 +00:00
Wyatt Hepler
495b6ee5ce pw_kvs: Map-backed tests
Introduce a system for writing tests against flash memories with
different parameters. The tests use a std::unordered_map as an oracle,
and all operations are checked against it. Invalid inputs and the KVS
filling up are handled.

Disable most of the tests because they are currently failing.

Change-Id: Ib817e30a199c81b3146823252be91e0db016c9b3
2020-02-13 21:50:30 +00:00