[PATCH v4 0/8] reftable: a couple of improvements for libgit2
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Aug 13, 2025, 06:25 UTC
- Message-ID
- <20250813-pks-reftable-fixes-for-libgit2-v4-0-42b5544c8e2a@pks.im>
- In-Reply-To
- <20250801-pks-reftable-fixes-for-libgit2-v1-0-f446e1c33cb9@pks.im>
Hi,
this small patch series contains a couple of improvements I required for libgit2. With those changes libgit2 is now able to run its full test suite with reftable-enabled repositories. I still need to invest a bit of work to make it memory-leak free and compile on Windows, but overall I think that support for reftables is almost ready.
Changes in v2:
- Another commit that fixes handling of outdated stacks when doing
compaction. This issue is hit in libgit2, which has a test that
performs writes with a couple dozen concurrent threads.
- Add a link to past discussions around `{0}` vs `{{0}}` as provided
by Eric.
- Link to v1: https://lore.kernel.org/r/20250801-pks-reftable-fixes-for-libgit2-v1-0-f446e1c33cb9@pks.imChanges in v3:
- Adapt `reftable_stack_init_addition()` to `memset()` the addition
instead of using `{{0}}`.
- Add another commit on top that makes the `flock` interface more
robust by not relying on `errno`.
- Add another commit to fix races with concurrent writers caused by
the backend not passing `REFTABLE_STACK_NEW_ADDITION_RELOAD`.
- Link to v2: https://lore.kernel.org/r/20250804-pks-reftable-fixes-for-libgit2-v2-0-fef06209a984@pks.imChanges in v4: - Adjust stale commit message. - Fix a typo while at it. - Link to v3: https://lore.kernel.org/r/20250812-pks-reftable-fixes-for-libgit2-v3-0-cf3b2267867e@pks.im
Thanks!
Patrick
---
Patrick Steinhardt (8):
reftable/writer: fix type used for number of records
reftable/writer: drop Git-specific `QSORT()` macro
reftable/stack: reorder code to avoid forward declarations
reftable/stack: fix compiler warning due to missing braces
reftable/stack: allow passing flags to `reftable_stack_add()`
reftable/stack: handle outdated stacks when compacting
reftable: don't second-guess errors from flock interface
refs/reftable: always reload stacks when creating lockrefs/reftable-backend.c | 23 ++- reftable/reftable-stack.h | 9 +- reftable/reftable-writer.h | 4 +- reftable/stack.c | 439 +++++++++++++++++++--------------------- reftable/system.c | 2 +- reftable/system.h | 4 +- reftable/writer.c | 23 ++- t/unit-tests/t-reftable-stack.c | 50 ++--- 8 files changed, 275 insertions(+), 279 deletions(-)
Range-diff versus v3:
1: afb757e6c1 = 1: 631293a69e reftable/writer: fix type used for number of records
2: 75dd5f6cb6 = 2: a583b9f51c reftable/writer: drop Git-specific `QSORT()` macro
3: 6badd0ae26 = 3: 7153526268 reftable/stack: reorder code to avoid forward declarations
4: 9f5aa7f808 = 4: 7372cbe037 reftable/stack: fix compiler warning due to missing braces
5: d4fea00eb2 ! 5: 57810b984e reftable/stack: allow passing flags to `reftable_stack_add()`
@@ Commit message
stack.
Add a `flags` field to plug this gap and pass it through accordingly.
- For now this new flag won't be used by us, but it will be used by
- libgit2.
+ This flag will be used in a subsequent patch and by libgit2.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
6: d2cdd89280 = 6: 211d3f646e reftable/stack: handle outdated stacks when compacting
7: 635dd20dcd ! 7: f8d541af00 reftable: don't second-guess errors from flock interface
@@ reftable/system.h: struct reftable_flock {
* we block indefinitely.
*
- * Retrun 0 on success, a reftable error code on error.
-+ * Retrun 0 on success, a reftable error code on error. Specifically,
++ * Return 0 on success, a reftable error code on error. Specifically,
+ * `REFTABLE_LOCK_ERROR` should be returned in case the target path is already
+ * locked.
*/
8: 4396793747 = 8: 912d00a4a8 refs/reftable: always reload stacks when creating lock--- base-commit: e813a0200a7121b97fec535f0d0b460b0a33356c change-id: 20250801-pks-reftable-fixes-for-libgit2-562b959a5603