From: Eric Wong Date: Sun, 10 Oct 2021 14:25:13 +0000 (+0000) Subject: set nodatacow on more SQLite files X-Git-Tag: v1.7.0~200 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=e26f235e4534d81efd402d30497ebf58ac4a2f74;p=public-inbox.git set nodatacow on more SQLite files 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. --- 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)); }