diff options
author | Eric Wong <e@80x24.org> | 2022-01-30 21:49:08 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-01-31 02:04:11 +0000 |
commit | 14fa0abdcc7b6513540e529375e53edd74ce13e8 (patch) | |
tree | 9f0de95629590def3c2dd72df28243faf129014e /t | |
parent | 6beeb75e5ccddf9f4e8eefc62cbe349972f59917 (diff) | |
download | public-inbox-14fa0abdcc7b6513540e529375e53edd74ce13e8.tar.gz |
btrfs is Linux-only at the moment (and likely to remain that way for practical purposes). So rely on Linux ABI stability and use the `syscall' and `ioctl' perlops rather than relying on Inline::C. Inline::C (and gcc||clang) are monstrous dependencies which we can't expect users to have. This makes supporting new architectures more difficult, but new architectures come along rarely and this reduces the burden for the majority of Linux users on popular architectures (while still avoiding the distribution of pre-built binaries). Link: https://public-inbox.org/meta/YbCPWGaJEkV6eWfo@codewreck.org/
Diffstat (limited to 't')
-rw-r--r-- | t/nodatacow.t | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/t/nodatacow.t b/t/nodatacow.t index 19247c10..0940d908 100644 --- a/t/nodatacow.t +++ b/t/nodatacow.t @@ -1,48 +1,42 @@ #!perl -w -# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org> +# Copyright (C) all contributors <meta@public-inbox.org> # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> use strict; use v5.10.1; use PublicInbox::TestCommon; use File::Temp 0.19; -use_ok 'PublicInbox::NDC_PP'; +use_ok 'PublicInbox::Syscall'; + +# btrfs on Linux is copy-on-write (COW) by default. As of Linux 5.7, +# this still leads to fragmentation for SQLite and Xapian files where +# random I/O happens, so we disable COW just for SQLite files and Xapian +# directories. Disabling COW disables checksumming, so we only do this +# for regeneratable files, and not canonical git storage (git doesn't +# checksum refs, only data under $GIT_DIR/objects). SKIP: { my $nr = 2; skip 'test is Linux-only', $nr if $^O ne 'linux'; my $dir = $ENV{BTRFS_TESTDIR}; skip 'BTRFS_TESTDIR not defined', $nr unless defined $dir; - require_cmd('chattr', 1) or skip 'chattr(1) not installed', $nr; + my $lsattr = require_cmd('lsattr', 1) or skip 'lsattr(1) not installed', $nr; + my $tmp = File::Temp->newdir('nodatacow-XXXX', DIR => $dir); my $dn = $tmp->dirname; my $name = "$dn/pp.f"; open my $fh, '>', $name or BAIL_OUT "open($name): $!"; - my $pp_sub = \&PublicInbox::NDC_PP::nodatacow_fd; - $pp_sub->(fileno($fh)); + PublicInbox::Syscall::nodatacow_fh($fh); my $res = xqx([$lsattr, $name]); + + BAIL_OUT "lsattr(1) fails in $dir" if $?; like($res, qr/C.*\Q$name\E/, "`C' attribute set on fd with pure Perl"); $name = "$dn/pp.d"; mkdir($name) or BAIL_OUT "mkdir($name) $!"; - PublicInbox::NDC_PP::nodatacow_dir($name); + PublicInbox::Syscall::nodatacow_dir($name); $res = xqx([$lsattr, '-d', $name]); like($res, qr/C.*\Q$name\E/, "`C' attribute set on dir with pure Perl"); - - $name = "$dn/ic.f"; - my $ic_sub = \&PublicInbox::Spawn::nodatacow_fd; - $pp_sub == $ic_sub and - skip 'Inline::C or Linux kernel headers missing', 2; - open $fh, '>', $name or BAIL_OUT "open($name): $!"; - $ic_sub->(fileno($fh)); - $res = xqx([$lsattr, $name]); - like($res, qr/C.*\Q$name\E/, "`C' attribute set on fd with Inline::C"); - - $name = "$dn/ic.d"; - mkdir($name) or BAIL_OUT "mkdir($name) $!"; - PublicInbox::Spawn::nodatacow_dir($name); - $res = xqx([$lsattr, '-d', $name]); - like($res, qr/C.*\Q$name\E/, "`C' attribute set on dir with Inline::C"); }; done_testing; |