From: Eric Wong <e@80x24.org>
To: Dominique Martinet <asmadeus@codewreck.org>
Cc: Julien Moutinho <julm+public-inbox@sourcephile.fr>,
meta@public-inbox.org
Subject: Re: [PATCH] nodatacow: quiet chattr errors [was: Test failures with 1.7.0]
Date: Tue, 1 Feb 2022 01:27:50 +0000 [thread overview]
Message-ID: <20220201012750.M302709@dcvr> (raw)
In-Reply-To: <YfdYqLhDVQRQ9NGT@codewreck.org>
Dominique Martinet <asmadeus@codewreck.org> wrote:
> Eric Wong wrote on Mon, Jan 31, 2022 at 02:03:11AM +0000:
> > Ah, intentionally setting BTRFS_TESTDIR to something that isn't
> > btrfs will break, yes.
>
> Ok, so this is specific to the test.
> Checking now nodatacow_fh skips files with non-btrfs magic, so it looks
> good to me!
>
> I've taken a look at the code now, just one more question: I don't
> understand why you've made the ioctl value depend on endianness ?
Actually, it's not endianess, it's architecture specific :x
The nasty patch below fixes it. I really wish there are better
options for scripting languages to use C headers :<
> That aside the code looks good to me, if you do Reviewed-by tags feel
> free to add mine (Dominique Martinet <asmadeus@codewreck.org>) once that
> question is answered.
> If you don't care, I don't care either :)
Thanks, just added the Noticed-by: as an attribution to the
below patch.
> this isn't really a problem, I've only tried because I'm a monkey :)
Yeah. Setting BTRFS_TESTDIR to a non-btrfs dir isn't going to
be supported :>
> Thanks again for the support, don't hesitate to ask if you need further
> info or tests for the zfs problems.
You're welcome, and will do.
-----8<-----
Subject: [PATCH] syscall: FS_IOC_*FLAGS: define on per-architecture basis
It turns out these Linux ioctls are unfortunately
architecture-dependent, and not endian-dependent.
Fixup some warning messages while we're at it, too.
Fixes: 14fa0abdcc7b6513 ("rewrite Linux nodatacow use in pure Perl w/o system")
Link: https://public-inbox.org/meta/YfdYqLhDVQRQ9NGT@codewreck.org/
Noticed-by: Dominique Martinet <asmadeus@codewreck.org>
---
lib/PublicInbox/Syscall.pm | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/lib/PublicInbox/Syscall.pm b/lib/PublicInbox/Syscall.pm
index bcfae2cb..31c67a14 100644
--- a/lib/PublicInbox/Syscall.pm
+++ b/lib/PublicInbox/Syscall.pm
@@ -69,6 +69,7 @@ our (
);
my $SYS_fstatfs; # don't need fstatfs64, just statfs.f_type
+my ($FS_IOC_GETFLAGS, $FS_IOC_SETFLAGS);
my $SFD_CLOEXEC = 02000000; # Perl does not expose O_CLOEXEC
our $no_deprecated = 0;
@@ -98,6 +99,8 @@ if ($^O eq "linux") {
$SYS_signalfd4 = 327;
$SYS_renameat2 //= 353;
$SYS_fstatfs = 100;
+ $FS_IOC_GETFLAGS = 0x80046601;
+ $FS_IOC_SETFLAGS = 0x40046602;
} elsif ($machine eq "x86_64") {
$SYS_epoll_create = 213;
$SYS_epoll_ctl = 233;
@@ -105,6 +108,8 @@ if ($^O eq "linux") {
$SYS_signalfd4 = 289;
$SYS_renameat2 //= 316;
$SYS_fstatfs = 138;
+ $FS_IOC_GETFLAGS = 0x80086601;
+ $FS_IOC_SETFLAGS = 0x40086602;
} elsif ($machine eq 'x32') {
$SYS_epoll_create = 1073742037;
$SYS_epoll_ctl = 1073742057;
@@ -112,6 +117,8 @@ if ($^O eq "linux") {
$SYS_signalfd4 = 1073742113;
$SYS_renameat2 //= 0x40000000 + 316;
$SYS_fstatfs = 138;
+ $FS_IOC_GETFLAGS = 0x80046601;
+ $FS_IOC_SETFLAGS = 0x40046602;
} elsif ($machine eq 'sparc64') {
$SYS_epoll_create = 193;
$SYS_epoll_ctl = 194;
@@ -121,6 +128,8 @@ if ($^O eq "linux") {
$SYS_renameat2 //= 345;
$SFD_CLOEXEC = 020000000;
$SYS_fstatfs = 158;
+ $FS_IOC_GETFLAGS = 0x40086601;
+ $FS_IOC_SETFLAGS = 0x80086602;
} elsif ($machine =~ m/^parisc/) {
$SYS_epoll_create = 224;
$SYS_epoll_ctl = 225;
@@ -135,6 +144,8 @@ if ($^O eq "linux") {
$SYS_signalfd4 = 313;
$SYS_renameat2 //= 357;
$SYS_fstatfs = 100;
+ $FS_IOC_GETFLAGS = 0x40086601;
+ $FS_IOC_SETFLAGS = 0x80086602;
} elsif ($machine eq "ppc") {
$SYS_epoll_create = 236;
$SYS_epoll_ctl = 237;
@@ -143,6 +154,8 @@ if ($^O eq "linux") {
$SYS_signalfd4 = 313;
$SYS_renameat2 //= 357;
$SYS_fstatfs = 100;
+ $FS_IOC_GETFLAGS = 0x40086601;
+ $FS_IOC_SETFLAGS = 0x80086602;
} elsif ($machine =~ m/^s390/) {
$SYS_epoll_create = 249;
$SYS_epoll_ctl = 250;
@@ -174,6 +187,8 @@ if ($^O eq "linux") {
$SYS_signalfd4 = 74;
$SYS_renameat2 //= 276;
$SYS_fstatfs = 44;
+ $FS_IOC_GETFLAGS = 0x80086601;
+ $FS_IOC_SETFLAGS = 0x40086602;
} elsif ($machine =~ m/arm(v\d+)?.*l/) {
# ARM OABI
$SYS_epoll_create = 250;
@@ -191,6 +206,8 @@ if ($^O eq "linux") {
$SYS_signalfd4 = 5283;
$SYS_renameat2 //= 5311;
$SYS_fstatfs = 5135;
+ $FS_IOC_GETFLAGS = 0x40046601;
+ $FS_IOC_SETFLAGS = 0x80046602;
} elsif ($machine =~ m/^mips/) {
$SYS_epoll_create = 4248;
$SYS_epoll_ctl = 4249;
@@ -199,6 +216,8 @@ if ($^O eq "linux") {
$SYS_signalfd4 = 4324;
$SYS_renameat2 //= 4351;
$SYS_fstatfs = 4100;
+ $FS_IOC_GETFLAGS = 0x40046601;
+ $FS_IOC_SETFLAGS = 0x80046602;
} else {
# as a last resort, try using the *.ph files which may not
# exist or may be wrong
@@ -345,22 +364,14 @@ sub nodatacow_fh {
my $f_type = unpack('l!', $buf); # statfs.f_type is a signed word
return if $f_type != 0x9123683E; # BTRFS_SUPER_MAGIC
- state ($FS_IOC_GETFLAGS, $FS_IOC_SETFLAGS);
- unless (defined $FS_IOC_GETFLAGS) {
- if (substr($Config{byteorder}, 0, 4) eq '1234') {
- $FS_IOC_GETFLAGS = 0x80086601;
- $FS_IOC_SETFLAGS = 0x40086602;
- } else { # Big endian
- $FS_IOC_GETFLAGS = 0x40086601;
- $FS_IOC_SETFLAGS = 0x80086602;
- }
- }
+ $FS_IOC_GETFLAGS //
+ return warn('FS_IOC_GETFLAGS undefined for platform');
ioctl($fh, $FS_IOC_GETFLAGS, $buf) //
- return warn("FS_IOC_GET_FLAGS: $!\n");
+ return warn("FS_IOC_GETFLAGS: $!\n");
my $attr = unpack('l!', $buf);
return if ($attr & 0x00800000); # FS_NOCOW_FL;
ioctl($fh, $FS_IOC_SETFLAGS, pack('l', $attr | 0x00800000)) //
- warn("FS_IOC_SET_FLAGS: $!\n");
+ warn("FS_IOC_SETFLAGS: $!\n");
}
sub nodatacow_dir {
next prev parent reply other threads:[~2022-02-01 1:27 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-08 1:07 Test failures with 1.7.0 Julien Moutinho
2021-12-08 4:08 ` Eric Wong
2021-12-08 10:56 ` Dominique Martinet
2021-12-08 18:22 ` [PATCH] nodatacow: quiet chattr errors [was: Test failures with 1.7.0] Eric Wong
2021-12-08 21:14 ` Dominique Martinet
2021-12-08 22:01 ` Dominique Martinet
2022-01-30 21:49 ` Eric Wong
2022-01-30 23:18 ` Dominique Martinet
2022-01-31 2:03 ` Eric Wong
2022-01-31 3:34 ` Dominique Martinet
2022-02-01 1:27 ` Eric Wong [this message]
2021-12-09 1:37 ` Test failures with 1.7.0 Julien Moutinho
2021-12-09 2:53 ` Dominique Martinet
2022-02-01 9:37 ` Eric Wong
2022-02-01 23:27 ` FD_CLOEXEC w/ nix-shell [was: Test failures with 1.7.0] Eric Wong
2022-02-02 0:23 ` Dominique Martinet
2022-02-02 2:11 ` Dominique Martinet
2022-02-01 23:34 ` [PATCH] test_lei: use consistent locale for error messages Eric Wong
2022-02-17 21:02 ` [PATCH] t/lei-sigpipe: attempt to improve diagnostics for stuck test Eric Wong
2022-02-20 1:38 ` Julien Moutinho
2022-02-22 6:44 ` Eric Wong
2022-02-27 4:15 ` Julien Moutinho
2022-02-27 6:41 ` Julien Moutinho
2022-02-27 7:23 ` Dominique Martinet
2022-02-27 8:04 ` Julien Moutinho
2022-02-27 11:17 ` [PATCH] t/lei-sigpipe: ensure SIGPIPE is unblocked for this test Eric Wong
2022-03-11 10:42 ` [PATCH] t/lei-sigpipe.t: ensure SIGPIPE is not ignored instead of not blocked Julien Moutinho
2022-03-14 22:14 ` Eric Wong
2022-03-15 2:56 ` Julien Moutinho
2022-03-01 2:30 ` Test failures with 1.7.0 Julien Moutinho
2022-03-01 4:05 ` Eric Wong
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=20220201012750.M302709@dcvr \
--to=e@80x24.org \
--cc=asmadeus@codewreck.org \
--cc=julm+public-inbox@sourcephile.fr \
--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).