From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202410 header.b=j3B1ME7o; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 45C9F5A004C for ; Wed, 06 Nov 2024 22:16:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1730927782; bh=2nfhcOP5r1wcIqwcwVCOuy5gNequFmOg4yrN4UWfpX0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=j3B1ME7otJ/FWuCo37J/y2OXID3ZnbiN8D8MFAB9zBA40d1XV569ORrQcJfficmGR SQnwxf+VXmMH+bi2n8aoWB58D2OZqo4jDnBf2jVNYPB+Yjv6jvC+nOoNBZMZ3a+LhP e4jIaX48ASBW542Azv7XlyI1QZPWSsegnxW68gyFVSfSLyJzpkIRosvrLtYnZqT6/w PK45F9N9eq5fBa/UYJcQCb47jBvTmPQmmOn/VgO4cX3BNFEiuzpgkAryuaDatC4Ry4 dOBUM3dhYN8Eu7RLbB2gaBps3A3/yAiqO3dnKleM6hWABnwmAr3sTuAdJd4TKARBs3 LF3C7O9gF71Iw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4XkJ0k6qysz4wyh; Thu, 7 Nov 2024 08:16:22 +1100 (AEDT) Date: Thu, 7 Nov 2024 07:54:43 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 2/8] log: Only check for FALLOC_FL_COLLAPSE_RANGE availability at runtime Message-ID: References: <20241106065421.2568179-1-david@gibson.dropbear.id.au> <20241106065421.2568179-3-david@gibson.dropbear.id.au> <20241106201041.1e385fc0@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rViXTO7E2WxxI3Se" Content-Disposition: inline In-Reply-To: <20241106201041.1e385fc0@elisabeth> Message-ID-Hash: X22KCP5D3GR57LDNTX7YBU2RM4UMSAMO X-Message-ID-Hash: X22KCP5D3GR57LDNTX7YBU2RM4UMSAMO X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --rViXTO7E2WxxI3Se Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 06, 2024 at 08:10:41PM +0100, Stefano Brivio wrote: > On Wed, 6 Nov 2024 17:54:15 +1100 > David Gibson wrote: >=20 > > log.c has several #ifdefs on FALLOC_FL_COLLAPSE_RANGE that won't attempt > > to use it if not defined. But even if the value is defined at compile > > time, it might not be available in the runtime kernel, so we need to ch= eck > > for errors from a fallocate() call and fall back to other methods. > >=20 > > Simplify this to only need the runtime check by using linux_dep.h to de= fine > > FALLOC_FL_COLLAPSE_RANGE if it's not in the kernel headers. > >=20 > > Signed-off-by: David Gibson > > --- > > Makefile | 5 ----- > > linux_dep.h | 6 ++++++ > > log.c | 9 +-------- > > 3 files changed, 7 insertions(+), 13 deletions(-) > >=20 > > diff --git a/Makefile b/Makefile > > index 56bf2e8..cb91535 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -59,11 +59,6 @@ ifeq ($(shell :|$(CC) -fstack-protector-strong -S -x= c - -o - >/dev/null 2>&1; ec > > FLAGS +=3D -fstack-protector-strong > > endif > > =20 > > -C :=3D \#define _GNU_SOURCE\n\#include \nint x =3D FALLOC_FL_= COLLAPSE_RANGE; > > -ifeq ($(shell printf "$(C)" | $(CC) -S -xc - -o - >/dev/null 2>&1; ech= o $$?),0) > > - EXTRA_SYSCALLS +=3D fallocate > > -endif > > - > > prefix ?=3D /usr/local > > exec_prefix ?=3D $(prefix) > > bindir ?=3D $(exec_prefix)/bin > > diff --git a/linux_dep.h b/linux_dep.h > > index 8921623..eae9c3c 100644 > > --- a/linux_dep.h > > +++ b/linux_dep.h > > @@ -119,4 +119,10 @@ struct tcp_info_linux { > > */ > > }; > > =20 > > +#include > > + > > +#ifndef FALLOC_FL_COLLAPSE_RANGE > > +#define FALLOC_FL_COLLAPSE_RANGE 0x08 > > +#endif > > + > > #endif /* LINUX_DEP_H */ > > diff --git a/log.c b/log.c > > index 19f1d98..3c1b39c 100644 > > --- a/log.c > > +++ b/log.c > > @@ -92,7 +92,6 @@ const char *logfile_prefix[] =3D { > > " ", /* LOG_DEBUG */ > > }; > > =20 > > -#ifdef FALLOC_FL_COLLAPSE_RANGE >=20 > This breaks the build on Alpine (and I suppose on Void Linux too, that > is, whenever we build against musl): >=20 > log.c: In function 'logfile_rotate': > log.c:207:28: error: 'FALLOC_FL_COLLAPSE_RANGE' undeclared (first use in = this function) > 207 | if (!fallocate(fd, FALLOC_FL_COLLAPSE_RANGE, 0, log_cut_s= ize)) > | ^~~~~~~~~~~~~~~~~~~~~~~~ > log.c:207:28: note: each undeclared identifier is reported only once for = each function it appears in >=20 > and it's fixed by including linux_dep.h from log.c. Oops, that was careless. Fixed for the next spin. --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --rViXTO7E2WxxI3Se Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmcr15IACgkQzQJF27ox 2GdH9g/8DekQuN2I2X61bsQfa9j8pxPYv6mS4f8kaUCet/IcgOXcAetNbTsP6UEj BfqhS9vPacgl1JbkcjzvLvDWBNsNc11Y/BB7gosKS7YpivJgMprHrquJePzHrgar sSw8nUZsAtKzkfmXsYJj6ihjBLFJBdsbkFrkc1p80rJMHhQ2w1FnqOUEfElmzyuB 2ClOdGYdjSMCbRZRF2hxOqGDnrtgPEkx+hAqhIQY2SOgxFGyM+NTlqRKxYfVRkD3 JpBqUXvMbFolBNISAGycf7DPnz7qqSx8twGcU3JhSv2EsIqP1fJsB5eKELyOUo6E dcWyNwVRukPqoDC0Lp7HGuJP4JC0eC+KSXO7zb7YoOLkMfXRp7KF/QTjIZqE6v+l Tp7o4SMxHe+nKGRG4fM2lX/SjYBgF2Q6PXJD/kwoPrQmuK0e1ucUQ8C3prpxzsga GJfdjDr21kzcwZ47/n1dF69vwT9Eypg9AaPVZwT2QTx9eeFuTsxWpTWzCUHZlBRu apEAMfEgqnaIsGMtr6N+fpTmFyyuwb6eyxQqOVlCNNV4ehyjRD1bcybSW6T1xVzN AI8JLh4qAITiWUkfh8kyHAOauNYom3iX4pJeodGI/oU9pMLtmiLqRT+pF919rMc2 oALUmHJf6uZUtSp1HHaYfUGNiO6BCOEZx/rnKF42MOviPUzGzew= =uZp+ -----END PGP SIGNATURE----- --rViXTO7E2WxxI3Se--