user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 2/1] xapcmd: -xcpdb and -compact disable CoW, too
  @ 2020-07-29 11:20  7% ` Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2020-07-29 11:20 UTC (permalink / raw)
  To: meta

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;
 	}

^ permalink raw reply related	[relevance 7%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-07-28 22:21     [PATCH] searchidx: disable CoW for SQLite and Xapian under btrfs Eric Wong
2020-07-29 11:20  7% ` [PATCH 2/1] xapcmd: -xcpdb and -compact disable CoW, too Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).