From: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
To: elfutils-devel@sourceware.org
Cc: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
Subject: [PATCH 3/3] debuginfod: When retrieving files from cache, update atime manually
Date: Fri, 24 Mar 2023 01:48:05 +0100 [thread overview]
Message-ID: <20230324004805.156080-3-heftig@archlinux.org> (raw)
In-Reply-To: <20230324004805.156080-1-heftig@archlinux.org>
The cache cleaning logic requires atime to be correct (strictatime) but
most users on Linux only have relatime or even noatime.
Attempt to update the atime manually so that the cache works properly.
Signed-off-by: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
---
debuginfod/debuginfod-client.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
index 1a2d7573..484dc7b3 100644
--- a/debuginfod/debuginfod-client.c
+++ b/debuginfod/debuginfod-client.c
@@ -618,6 +618,19 @@ path_escape (const char *src, char *dest)
dest[q] = '\0';
}
+/* Attempt to update the atime */
+static void
+update_atime (int fd)
+{
+ struct timespec tvs[2];
+
+ tvs[0].tv_sec = tvs[1].tv_sec = 0;
+ tvs[0].tv_nsec = UTIME_NOW;
+ tvs[1].tv_nsec = UTIME_OMIT;
+
+ (void) futimens (fd, tvs); /* best effort */
+}
+
/* Attempt to read an ELF/DWARF section with name SECTION from FD and write
it to a separate file in the debuginfod cache. If successful the absolute
path of the separate file containing SECTION will be stored in USR_PATH.
@@ -761,6 +774,7 @@ extract_section (int fd, const char *section, char *fd_path, char **usr_path)
*usr_path = sec_path;
else
free (sec_path);
+ update_atime(fd);
rc = sec_fd;
goto out2;
}
@@ -1098,6 +1112,7 @@ debuginfod_query_server (debuginfod_client *c,
}
}
/* Success!!!! */
+ update_atime(fd);
rc = fd;
goto out;
}
--
2.40.0
next prev parent reply other threads:[~2023-03-24 0:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-24 0:48 [PATCH 1/3] debuginfod: Replace futimes with futimens Jan Alexander Steffens (heftig)
2023-03-24 0:48 ` [PATCH 2/3] debuginfod: Don't touch access time of new files Jan Alexander Steffens (heftig)
2023-03-24 0:48 ` Jan Alexander Steffens (heftig) [this message]
2023-03-29 20:54 ` [PATCH 3/3] debuginfod: When retrieving files from cache, update atime manually Frank Ch. Eigler
2023-03-29 21:32 ` Jan Alexander Steffens (heftig)
2023-03-29 20:47 ` [PATCH 1/3] debuginfod: Replace futimes with futimens Frank Ch. Eigler
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230324004805.156080-3-heftig@archlinux.org \
--to=heftig@archlinux.org \
--cc=elfutils-devel@sourceware.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).