about summary refs log tree commit homepage
path: root/lib/PublicInbox
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-10-10 14:25:13 +0000
committerEric Wong <e@80x24.org>2021-10-10 23:29:51 +0000
commite26f235e4534d81efd402d30497ebf58ac4a2f74 (patch)
treeefece35962d30c474e47f92a42f1da177e097937 /lib/PublicInbox
parent0e71e72e39472832c97866c7f32f4a62d7b7e6a0 (diff)
downloadpublic-inbox-e26f235e4534d81efd402d30497ebf58ac4a2f74.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r--lib/PublicInbox/Over.pm4
-rw-r--r--lib/PublicInbox/SharedKV.pm3
2 files changed, 5 insertions, 2 deletions
diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm
index 19da056a..98de82c0 100644
--- a/lib/PublicInbox/Over.pm
+++ b/lib/PublicInbox/Over.pm
@@ -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 {
diff --git a/lib/PublicInbox/SharedKV.pm b/lib/PublicInbox/SharedKV.pm
index 645bb57c..398f4ca8 100644
--- a/lib/PublicInbox/SharedKV.pm
+++ b/lib/PublicInbox/SharedKV.pm
@@ -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));
         }