From: Eric Wong <e@yhbt.net>
To: meta@public-inbox.org
Subject: [PATCH 2/1] xapcmd: -xcpdb and -compact disable CoW, too
Date: Wed, 29 Jul 2020 11:20:00 +0000 [thread overview]
Message-ID: <20200729112000.GA25039@dcvr> (raw)
In-Reply-To: <20200728222158.17457-1-e@yhbt.net>
This gives an opportunity for users already suffering from CoW
fragmentation to at least get the Xapian DBs off CoW. Aside
from over.sqlite3 in v1, the SQLite DBs remain untouched; though
VACUUM support may come in the future.
---
lib/PublicInbox/SearchIdx.pm | 11 ++++++++---
lib/PublicInbox/Xapcmd.pm | 5 ++++-
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index aa8d8ce3..080aca7c 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -21,7 +21,7 @@ use PublicInbox::OverIdx;
use PublicInbox::Spawn qw(spawn);
use PublicInbox::Git qw(git_unquote);
use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp);
-our @EXPORT_OK = qw(crlf_adjust log2stack is_ancestor check_size);
+our @EXPORT_OK = qw(crlf_adjust log2stack is_ancestor check_size nodatacow_dir);
my $X = \%PublicInbox::Search::X;
my ($DB_CREATE_OR_OPEN, $DB_OPEN);
our $DB_NO_SYNC = 0;
@@ -110,6 +110,12 @@ sub load_xapian_writable () {
1;
}
+sub nodatacow_dir ($) {
+ my ($dir) = @_;
+ opendir my $dh, $dir or die "opendir($dir): $!\n";
+ PublicInbox::Spawn::set_nodatacow(fileno($dh));
+}
+
sub idx_acquire {
my ($self) = @_;
my $flag;
@@ -128,8 +134,7 @@ sub idx_acquire {
if (!-d $dir && (!$is_shard ||
($is_shard && need_xapian($self)))) {
File::Path::mkpath($dir);
- opendir my $dh, $dir or die "opendir($dir): $!\n";
- PublicInbox::Spawn::set_nodatacow(fileno($dh));
+ nodatacow_dir($dir);
}
}
return unless defined $flag;
diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm
index 3b7a581b..f1c80831 100644
--- a/lib/PublicInbox/Xapcmd.pm
+++ b/lib/PublicInbox/Xapcmd.pm
@@ -5,7 +5,7 @@ use strict;
use warnings;
use PublicInbox::Spawn qw(which popen_rd);
use PublicInbox::Over;
-use PublicInbox::SearchIdx;
+use PublicInbox::SearchIdx qw(nodatacow_dir);
use File::Temp 0.19 (); # ->newdir
use File::Path qw(remove_tree);
use File::Basename qw(dirname);
@@ -187,6 +187,7 @@ sub prepare_run {
my $v = PublicInbox::Search::SCHEMA_VERSION();
my $wip = File::Temp->newdir("xapian$v-XXXXXXXX", DIR => $dir);
$tmp->{$old} = $wip;
+ nodatacow_dir($wip->dirname);
push @queue, [ $old, $wip ];
} else {
opendir my $dh, $old or die "Failed to opendir $old: $!\n";
@@ -217,6 +218,7 @@ sub prepare_run {
same_fs_or_die($old, $wip->dirname);
my $cur = "$old/$dn";
push @queue, [ $src // $cur , $wip ];
+ nodatacow_dir($wip->dirname);
$tmp->{$cur} = $wip;
}
# mark old shards to be unlinked
@@ -406,6 +408,7 @@ sub cpdb ($$) {
$ft = File::Temp->newdir("$new.compact-XXXXXX", DIR => $dir);
setup_signals();
$tmp = $ft->dirname;
+ nodatacow_dir($tmp);
} else {
$tmp = $new;
}
prev parent reply other threads:[~2020-07-29 11:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-28 22:21 [PATCH] searchidx: disable CoW for SQLite and Xapian under btrfs Eric Wong
2020-07-29 11:20 ` Eric Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200729112000.GA25039@dcvr \
--to=e@yhbt.net \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).