From patchwork Fri Mar 24 00:48:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jan Alexander Steffens \\(heftig\\)" X-Patchwork-Id: 66828 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9DD0E3870889 for ; Fri, 24 Mar 2023 00:49:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9DD0E3870889 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679618954; bh=6BCEsDBHQM0C/0TAmO2SGFuT2lOSc35jhDqLdXI31L4=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=s0uRowuyH1anEn4MBBWlbdDsFItqVlNPqehshPJR3ZNJq6CHoz++RRI2hWlvwphmK LHoQGYcjnEPRoO0B4FOz+lv2HNkIsjPsFd8FMCmMy4ecIP23SgIyxeh6CSA/p5wnOf Sr2HNPx+dPx0PNfgVo7N2GivcXNGRLGW5CMiDGsU= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by sourceware.org (Postfix) with ESMTPS id 360BD3858C50 for ; Fri, 24 Mar 2023 00:48:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 360BD3858C50 Received: by mail-ed1-f49.google.com with SMTP id r11so1910447edd.5 for ; Thu, 23 Mar 2023 17:48:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679618930; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6BCEsDBHQM0C/0TAmO2SGFuT2lOSc35jhDqLdXI31L4=; b=vXMFcapKG+pcE9+8P1hKxOUqSBx+qYByVRtymrFXQ98+4DpHlYPK9LegBHOFPH7Y/J bYBvQxNGs+r1MikWbYaC4IiLDeIXAbErKrCIv/BdfMdIcKSjk0I/LXcA+QuRp5JvC/uY CBAUhlG+BBQvEf4IdPuCXsvCaKd5Wlqkk0uoJ4P/ePlYT8QnQ0RrsNgUGDkM+XyinJjd 5vCEwtNb9L9kVUKlqD7Ho7L44XEsSSKFo5PN0NY2VrcFaWMCqrlTZ5trK5tzhibAGJ51 hecSDaMwOiykgyjTPXDpQQMAapUiurEAUXgJ3yq+XuWbZJGbdUpRUCAfvfK2XhRzfmcV heiw== X-Gm-Message-State: AAQBX9eTX8a9RyEk+HZhlqs7P7qnSF1Ugw4XmcwD3f6W7goQVasoHaLi uvZP9vIR45oPSsOsIViJ1nQ6cU5aJ1M= X-Google-Smtp-Source: AKy350a8koOruYiPZ3t4OElsihMJkX4NQVqtnCXyxqKhx68h80Z2g9/uXcHtGtw/MCJ499zjZfeUOA== X-Received: by 2002:a05:6402:4c:b0:4c0:1120:a15d with SMTP id f12-20020a056402004c00b004c01120a15dmr1169212edu.5.1679618929888; Thu, 23 Mar 2023 17:48:49 -0700 (PDT) Received: from ocellus.fritz.box (p200300eae71e29008ef8c5fffef034ee.dip0.t-ipconnect.de. [2003:ea:e71e:2900:8ef8:c5ff:fef0:34ee]) by smtp.gmail.com with ESMTPSA id u25-20020a50c2d9000000b004faf34064c8sm9824029edf.62.2023.03.23.17.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Mar 2023 17:48:49 -0700 (PDT) To: elfutils-devel@sourceware.org Cc: "Jan Alexander Steffens (heftig)" Subject: [PATCH 2/3] debuginfod: Don't touch access time of new files Date: Fri, 24 Mar 2023 01:48:04 +0100 Message-Id: <20230324004805.156080-2-heftig@archlinux.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230324004805.156080-1-heftig@archlinux.org> References: <20230324004805.156080-1-heftig@archlinux.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Jan Alexander Steffens \(heftig\) via Elfutils-devel" From: "Jan Alexander Steffens \\(heftig\\)" Reply-To: "Jan Alexander Steffens \(heftig\)" Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Instead of copying the mtime, which might be far in the past, don't touch the access time. This will prevent cache cleaning from considering the file as old immediately. Signed-off-by: Jan Alexander Steffens (heftig) --- debuginfod/debuginfod-client.c | 16 +++++++++------- debuginfod/debuginfod.cxx | 10 +++++++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index 460afd5c..1a2d7573 100644 --- a/debuginfod/debuginfod-client.c +++ b/debuginfod/debuginfod-client.c @@ -1718,13 +1718,15 @@ debuginfod_query_server (debuginfod_client *c, #else CURLcode curl_res = curl_easy_getinfo(verified_handle, CURLINFO_FILETIME, (void*) &mtime); #endif - if (curl_res != CURLE_OK) - mtime = time(NULL); /* fall back to current time */ - - struct timespec tvs[2]; - tvs[0].tv_sec = tvs[1].tv_sec = mtime; - tvs[0].tv_nsec = tvs[1].tv_nsec = 0; - (void) futimens (fd, tvs); /* best effort */ + if (curl_res == CURLE_OK) + { + struct timespec tvs[2]; + tvs[0].tv_sec = 0; + tvs[0].tv_nsec = UTIME_OMIT; + tvs[1].tv_sec = mtime; + tvs[1].tv_nsec = 0; + (void) futimens (fd, tvs); /* best effort */ + } /* PR27571: make cache files casually unwriteable; dirs are already 0700 */ (void) fchmod(fd, 0400); diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx index b39c0591..5ef6cc32 100644 --- a/debuginfod/debuginfod.cxx +++ b/debuginfod/debuginfod.cxx @@ -1639,7 +1639,9 @@ extract_section (int elf_fd, int64_t parent_mtime, if (fstat (elf_fd, &fs) != 0) throw libc_exception (errno, "cannot fstat file"); - tvs[0] = tvs[1] = fs.st_mtim; + tvs[0].tv_sec = 0; + tvs[0].tv_nsec = UTIME_OMIT; + tvs[1] = fs.st_mtim; (void) futimens (fd, tvs); /* Add to fdcache. */ @@ -1951,8 +1953,10 @@ handle_buildid_r_match (bool internal_req_p, // Set the mtime so the fdcache file mtimes, even prefetched ones, // propagate to future webapi clients. struct timespec tvs[2]; - tvs[0].tv_sec = tvs[1].tv_sec = archive_entry_mtime(e); - tvs[0].tv_nsec = tvs[1].tv_nsec = archive_entry_mtime_nsec(e); + tvs[0].tv_sec = 0; + tvs[0].tv_nsec = UTIME_OMIT; + tvs[1].tv_sec = archive_entry_mtime(e); + tvs[1].tv_nsec = archive_entry_mtime_nsec(e); (void) futimens (fd, tvs); /* best effort */ if (r != 0) // stage 3