]> Sergey Matveev's repositories - public-inbox.git/commitdiff
set nodatacow on more SQLite files
authorEric Wong <e@80x24.org>
Sun, 10 Oct 2021 14:25:13 +0000 (14:25 +0000)
committerEric Wong <e@80x24.org>
Sun, 10 Oct 2021 23:29:51 +0000 (23:29 +0000)
We'll set nodatacow when detecting existing but empty
files, and also their directories in more cases (for
auxiliary -wal, -journal, -shm files).  Hopefully
this keeps performance reasonable on CoW FSes.

lib/PublicInbox/Over.pm
lib/PublicInbox/SharedKV.pm

index 19da056a10aff5de4455e80c1e30b03190352258..98de82c048c86889c543cc3c871d647c5f7642c6 100644 (file)
@@ -16,9 +16,11 @@ use constant DEFAULT_LIMIT => 1000;
 sub dbh_new {
        my ($self, $rw) = @_;
        my $f = delete $self->{filename};
-       if (!-f $f) { # SQLite defaults mode to 0644, we want 0666
+       if (!-s $f) { # SQLite defaults mode to 0644, we want 0666
                if ($rw) {
                        require PublicInbox::Spawn;
+                       my ($dir) = ($f =~ m!(.+)/[^/]+\z!);
+                       PublicInbox::Spawn::nodatacow_dir($dir);
                        open my $fh, '+>>', $f or die "failed to open $f: $!";
                        PublicInbox::Spawn::nodatacow_fd(fileno($fh));
                } else {
index 645bb57c90a63bb29521c9bde2be6ce6328bab1c..398f4ca8dd70ef70af87ecf348689b6561c1532f 100644 (file)
@@ -51,7 +51,8 @@ sub new {
        $base //= '';
        my $f = $self->{filename} = "$dir/$base.sqlite3";
        $self->{lock_path} = $opt->{lock_path} // "$dir/$base.flock";
-       unless (-f $f) {
+       unless (-s $f) {
+               PublicInbox::Spawn::nodatacow_dir($dir); # for journal/shm/wal
                open my $fh, '+>>', $f or die "failed to open $f: $!";
                PublicInbox::Spawn::nodatacow_fd(fileno($fh));
        }