From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5C1911FA10 for ; Sun, 10 Oct 2021 14:25:19 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/8] set nodatacow on more SQLite files Date: Sun, 10 Oct 2021 14:25:13 +0000 Message-Id: <20211010142518.7012-4-e@80x24.org> In-Reply-To: <20211010142518.7012-1-e@80x24.org> References: <20211010142518.7012-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 | 4 +++- 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)); }