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

New VFS #552

Merged
merged 96 commits into from
Mar 8, 2024
Merged

New VFS #552

merged 96 commits into from
Mar 8, 2024

Conversation

cole-miller
Copy link
Contributor

Very WIP.

Copy link

codecov bot commented Jan 23, 2024

Codecov Report

Attention: Patch coverage is 79.16667% with 190 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (dqlite-next@9578db5). Click here to learn what that means.

Files Patch % Lines
src/vfs2.c 74.96% 98 Missing and 86 partials ⚠️
src/lib/sm.c 28.57% 4 Missing and 1 partial ⚠️
test/unit/test_vfs2.c 99.40% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             dqlite-next     #552   +/-   ##
==============================================
  Coverage               ?   81.15%           
==============================================
  Files                  ?      194           
  Lines                  ?    28045           
  Branches               ?     5211           
==============================================
  Hits                   ?    22761           
  Misses                 ?     3586           
  Partials               ?     1698           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@just-now just-now left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the first pass. Will continue reading the logic.

struct vfs2_wal
{
const char *moving_name; /* e.g. /path/to/my.db-wal */
char *wal_cur_fixed_name; /* e.g. /path/to/my.db-xwal1 */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like wal_prev_fixed_name and wal_cur_fixed_name could be const.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are "owned" and need to be freed at the end of the file object's lifetime, unlike moving_name which is "borrowed" from SQLite (but guaranteed to be valid until xClose, see https://sqlite.org/c3ref/vfs.html. That's why I've left the distinction here

src/vfs2.c Outdated Show resolved Hide resolved
src/vfs2.c Outdated
Comment on lines 203 to 210
const char *walname = cur->wal->wal.moving_name;
const char *dash = strrchr(walname, '-');
assert(dash != NULL);
if (strncmp(walname, f->db_shm.name,
(size_t)(dash - walname)) != 0) {
continue;
}
found = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to be a common part for this and next else if { statement. Consider moving this common part up to the QUEUE__FOREACH() {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The calls are a bit different, it's

strncmp(cur->wal->wal.moving_name, f->db_shm.name, ...)

vs

strncmp(f->wal.moving_name, cur->db->db_shm.name, ...)

I can't see how to factor out what's common without making the code more complicated

src/vfs2.c Outdated Show resolved Hide resolved
src/vfs2.c Outdated Show resolved Hide resolved
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
@cole-miller cole-miller marked this pull request as ready for review March 5, 2024 14:27
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
Signed-off-by: Cole Miller <[email protected]>
@cole-miller
Copy link
Contributor Author

I'm going to merge this into dqlite-next and we can iterate on it there!

@cole-miller cole-miller changed the base branch from master to dqlite-next March 8, 2024 16:13
@cole-miller cole-miller merged commit 3b88f6d into canonical:dqlite-next Mar 8, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants