diff options
author | Eric Wong <e@80x24.org> | 2021-10-10 14:25:13 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-10-10 23:29:51 +0000 |
commit | e26f235e4534d81efd402d30497ebf58ac4a2f74 (patch) | |
tree | efece35962d30c474e47f92a42f1da177e097937 /lib/PublicInbox | |
parent | 0e71e72e39472832c97866c7f32f4a62d7b7e6a0 (diff) | |
download | public-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.pm | 4 | ||||
-rw-r--r-- | lib/PublicInbox/SharedKV.pm | 3 |
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)); } |