]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: don't affect atime of journal files when vacuuming
authorLennart Poettering <lennart@poettering.net>
Fri, 2 Oct 2015 20:39:24 +0000 (22:39 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 2 Oct 2015 20:39:24 +0000 (22:39 +0200)
Let's try to use O_NOATIME if we can when vacuuming old journal files,
if we have the permissions for it, so that vacuuming doesn't count as
proper journal read access.

src/journal/journal-vacuum.c

index 8c642d16e4ef9d44846833180bc1b6cf0277c5d9..394f7be46b771c3539f89e518cc192b376547d78 100644 (file)
@@ -112,9 +112,13 @@ static int journal_file_empty(int dir_fd, const char *name) {
         le64_t n_entries;
         ssize_t n;
 
-        fd = openat(dir_fd, name, O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK);
-        if (fd < 0)
-                return -errno;
+        fd = openat(dir_fd, name, O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK|O_NOATIME);
+        if (fd < 0) {
+                /* Maybe failed due to O_NOATIME and lack of privileges? */
+                fd = openat(dir_fd, name, O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK);
+                if (fd < 0)
+                        return -errno;
+        }
 
         if (fstat(fd, &st) < 0)
                 return -errno;