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

Refactor vfs2 #631

Merged
merged 29 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7a60686
vfs2: Large refactor
cole-miller Mar 14, 2024
9b4f115
Work on support for nonleaders
cole-miller Mar 21, 2024
82a24de
Read locks
cole-miller Apr 1, 2024
2634044
Invariant helpers
cole-miller Apr 1, 2024
24a56f3
Clean up pseudo_read_begin
cole-miller Apr 2, 2024
7ab97c0
Work on pseudo_read, use it internally
cole-miller Apr 2, 2024
c980c93
WAL_NREADER
cole-miller Apr 2, 2024
9c1b568
Update vfs2 unit test
cole-miller Apr 2, 2024
cd668e7
Fix refcount handling at open
cole-miller Apr 2, 2024
44cf5c1
Remove interloper sqlite3_free
cole-miller Apr 2, 2024
e1f1c31
Allow transition EMPTY -> BASE
cole-miller Apr 2, 2024
12d0ac7
Work on problems with transition to BASE
cole-miller Apr 2, 2024
794b80a
Move `mx < cursor` check later in the invariant
cole-miller Apr 2, 2024
fcd92c1
Save the header just after WAL swap
cole-miller Apr 2, 2024
8f3dc13
Keep working on fixing basic test
cole-miller Apr 3, 2024
1af546f
Reset wal_cursor on abort
cole-miller Apr 3, 2024
754b519
Allow BASE -> EMPTY
cole-miller Apr 3, 2024
b9e2273
sm: Trace states by name
cole-miller Apr 3, 2024
f6b5c49
Get vfs2/basic unit test passing
cole-miller Apr 3, 2024
edaa607
Refine pending_txn testing in invariant
cole-miller Apr 3, 2024
acb826f
Tests pass again
cole-miller Apr 5, 2024
abb9b39
Fix memory leaks
cole-miller Apr 5, 2024
c7464b5
Address review comments
cole-miller Apr 16, 2024
da3a279
Switch to CHECK as expression
cole-miller Apr 16, 2024
4c8cb1d
Fix up vfs2_close after unsuccessful open
cole-miller Apr 16, 2024
7e0bba9
Check return value of xRead in vfs2_read_wal
cole-miller Apr 16, 2024
7cda21e
WIP
cole-miller Apr 17, 2024
79fc956
Fix memory leak in vfs2_read_wal
cole-miller Apr 18, 2024
4d74efa
Document the state machine more
cole-miller Apr 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/lib/byte.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ DQLITE_INLINE uint32_t ByteGetBe32(const uint8_t *buf)
return w | x | y | z;
}

DQLITE_INLINE uint32_t ByteGetLe32(const uint8_t *buf)
{
uint32_t w = buf[0];
uint32_t x = buf[1];
uint32_t y = buf[2];
uint32_t z = buf[3];
z <<= 24;
y <<= 16;
x <<= 8;
return w | x | y | z;
}

DQLITE_INLINE void BytePutBe32(uint32_t v, uint8_t *buf)
{
buf[0] = (uint8_t)(v >> 24);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void sm_move(struct sm *m, int next_state)
{
int prev = sm_state(m);

tracef("SM_MOVE %d => %d", prev, next_state);
tracef("SM_MOVE %s => %s", m->conf[prev].name, m->conf[next_state].name);

PRE(sm_is_locked(m));
PRE(m->conf[sm_state(m)].allowed & BITS(next_state));
Expand Down
2 changes: 1 addition & 1 deletion src/lib/sm.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#define BITS(state) (1ULL << (state))

#define CHECK(cond) if (!sm_check((cond), __FILE__, __LINE__, #cond)) return false
#define CHECK(cond) sm_check((cond), __FILE__, __LINE__, #cond)

enum {
SM_PREV_NONE = -1,
Expand Down
5 changes: 5 additions & 0 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define DQLITE_UTILS_H_

#include <assert.h>
#include <stdbool.h>
#include <stdint.h>

/* Various utility functions and macros */
Expand All @@ -21,4 +22,8 @@
#define POST(cond) assert((cond))
#define ERGO(a, b) (!(a) || (b))

static inline bool is_po2(unsigned long n) {
return n > 0 && (n & (n - 1)) == 0;
}

#endif /* DQLITE_UTILS_H_ */
Loading
Loading