From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ehovz4ZR; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id E2E9D5A004C for ; Wed, 06 Nov 2024 20:10:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730920247; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZN0rCcHz+PD/38fPxpO0AuLWXE2OqjEEPCmwWaQ+NHQ=; b=ehovz4ZRa5T4KQGl1FBgdSkeHr4GbehYFTHqJHpjS7mjEfF7lJ+8hnSRwZDwclyYGnLkgA qtt4/fAZCeXsoAVaPCjHE6RpGOM4wcl0a/hJLuy3aJqTpE57G2NViwUAg3iYJ9RnZVQZlr Jb3M6Vej2o5ejOKsygKJNoZQMQ8oUMo= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-622-ROrbxe60O02T7FnVlR9SIQ-1; Wed, 06 Nov 2024 14:10:45 -0500 X-MC-Unique: ROrbxe60O02T7FnVlR9SIQ-1 X-Mimecast-MFC-AGG-ID: ROrbxe60O02T7FnVlR9SIQ Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-381d07c377cso60568f8f.1 for ; Wed, 06 Nov 2024 11:10:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730920244; x=1731525044; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ZN0rCcHz+PD/38fPxpO0AuLWXE2OqjEEPCmwWaQ+NHQ=; b=k3AMGu1kfXgVhBdHMYRz+NNUi1XGwo4mdBG/aQhdYzt8Yix7xbuI1u1Lm0wLETgeT9 PAg0/JbMJRcZTqFSj6xwuj6x0NHJCrZf1p1JrsVrUi/dHkyQ6pnbPGm9BYMY+A9x8Wpt +fmwJv0nmYPZI74VuDWqK7vjhSDW/f1o7zhEOqe3cOhyf20zvEijTqfjZKt8kgMqyXgW Zv+UuW/03xY96VCRDz+gUtjU4ZrLdAK/qDlZJOjEi2X5np84BVz9+0IsALqh+fWTUu0Y qY17jRL5LM2UHx7tlD12EFsX5uRyhPCuE2E83YYqB4mRRmVePl7RclECBKsy4adOOMMj C2Sw== X-Gm-Message-State: AOJu0YyTBFKHpZ5jY6Jmigan//BRFXvoeG+K629aFd/xcrfEPQ9OI1wZ aKT58B3KOU9YBrYnh0OlECQZnpQlenPtzpvFqKTYZB5flQtkzJKFW7IJQXjI+tumCRTGUTMsOsj yhvATNTQPn3fZiLr4Sud2Nh729SVj1FG8VSkte4OWEfGNl/sS0yEELKYqNw== X-Received: by 2002:a05:6000:a12:b0:37c:d2e3:1298 with SMTP id ffacd0b85a97d-381c7ae0b41mr21704821f8f.55.1730920244056; Wed, 06 Nov 2024 11:10:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJ0qf8YYk5U5dHsJGDYlnbcAcBXZg+iArnK1GwVl1oapneARR/q7MDjKwVlTohTxnAwx3vbg== X-Received: by 2002:a05:6000:a12:b0:37c:d2e3:1298 with SMTP id ffacd0b85a97d-381c7ae0b41mr21704798f8f.55.1730920243614; Wed, 06 Nov 2024 11:10:43 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c116ad6fsm19840327f8f.98.2024.11.06.11.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 11:10:42 -0800 (PST) Date: Wed, 6 Nov 2024 20:10:41 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 2/8] log: Only check for FALLOC_FL_COLLAPSE_RANGE availability at runtime Message-ID: <20241106201041.1e385fc0@elisabeth> In-Reply-To: <20241106065421.2568179-3-david@gibson.dropbear.id.au> References: <20241106065421.2568179-1-david@gibson.dropbear.id.au> <20241106065421.2568179-3-david@gibson.dropbear.id.au> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: csOfh1nP7pwaV50vEeYyYnA3IqcgeUk0l6tOqy-9xiM_1730920245 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: FKI6QXRYIBDOMPEFIWKU7IPNZRLABLBN X-Message-ID-Hash: FKI6QXRYIBDOMPEFIWKU7IPNZRLABLBN X-MailFrom: sbrivio@redhat.com 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: On Wed, 6 Nov 2024 17:54:15 +1100 David Gibson wrote: > 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 check > for errors from a fallocate() call and fall back to other methods. > > Simplify this to only need the runtime check by using linux_dep.h to define > FALLOC_FL_COLLAPSE_RANGE if it's not in the kernel headers. > > Signed-off-by: David Gibson > --- > Makefile | 5 ----- > linux_dep.h | 6 ++++++ > log.c | 9 +-------- > 3 files changed, 7 insertions(+), 13 deletions(-) > > 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 -xc - -o - >/dev/null 2>&1; ec > FLAGS += -fstack-protector-strong > endif > > -C := \#define _GNU_SOURCE\n\#include \nint x = FALLOC_FL_COLLAPSE_RANGE; > -ifeq ($(shell printf "$(C)" | $(CC) -S -xc - -o - >/dev/null 2>&1; echo $$?),0) > - EXTRA_SYSCALLS += fallocate > -endif > - > prefix ?= /usr/local > exec_prefix ?= $(prefix) > bindir ?= $(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 { > */ > }; > > +#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[] = { > " ", /* LOG_DEBUG */ > }; > > -#ifdef FALLOC_FL_COLLAPSE_RANGE This breaks the build on Alpine (and I suppose on Void Linux too, that is, whenever we build against musl): 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_size)) | ^~~~~~~~~~~~~~~~~~~~~~~~ log.c:207:28: note: each undeclared identifier is reported only once for each function it appears in and it's fixed by including linux_dep.h from log.c. -- Stefano