From 74d4ffbba09aab2f73538a37b05ee3abcc921374 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 7 Aug 2025 00:50:05 +0000 Subject: [PATCH] nodatacow: warn about CoW being disabled on btrfs While Xapian and SQLite performance is untenable with CoW on btrfs, disabling CoW is not without caveats on btrfs. So warn users about the possibility of data corruption. --- lib/PublicInbox/Syscall.pm | 14 ++++++++++++-- t/nodatacow.t | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/Syscall.pm b/lib/PublicInbox/Syscall.pm index a7fa37363..b1cb4e688 100644 --- a/lib/PublicInbox/Syscall.pm +++ b/lib/PublicInbox/Syscall.pm @@ -435,6 +435,7 @@ sub rename_noreplace ($$) { } } +# returns "0 but true" on success, undef or sub nodatacow_fh ($) { my ($fh) = @_; my $buf = "\0" x 120; @@ -453,8 +454,17 @@ sub nodatacow_fh ($) { warn("FS_IOC_SETFLAGS: $!\n"); } -sub nodatacow_dir { - if (open my $fh, '<', $_[0]) { nodatacow_fh($fh) } +sub nodatacow_dir ($) { + my ($f) = @_; + if (open my $fh, '<', $f) { + my $rc = nodatacow_fh($fh); # returns "0 but true" on success + $rc && $rc == 0 and warn <