Skip to content

tmpfiles: bogus error condition when STATX_ATIME is not set #41227

Closed

Description

@intelfx

systemd version the issue has been seen with

260

Used distribution

Arch

Linux kernel version used

6.18.x

CPU architectures issue was seen on

x86_64

Component

systemd-tmpfiles

Expected behaviour you didn't see

systemd-tmpfiles must not rely on STATX_ATIME being always set if the kernel "new enough", as this flag is masked off when the filesystem is mounted with noatime.

https://github.com/torvalds/linux/blob/05f7e89ab9731565d8a62e3b5d1ec206485eeb0b/fs/stat.c#L191-L195:

	/* allow the fs to override these if it really wants to */
	/* SB_NOATIME means filesystem supplies dummy atime value */
	if (inode->i_sb->s_flags & SB_NOATIME)
		stat->result_mask &= ~STATX_ATIME;

Unexpected behaviour you saw

systemd-tmpfiles uses STATX_ATIME as a "mandatory" flag, expecting it to be always set in a well-formed environment, and emitting an error if it is not set suggesting that the environment is broken when it in fact isn't:

r = xstatx_full(dirfd(d),
/* path= */ NULL,
AT_EMPTY_PATH,
/* xstatx_flags= */ 0,
STATX_MODE|STATX_INO|STATX_ATIME|STATX_MTIME,
/* optional_mask= */ 0,
STATX_ATTR_MOUNT_ROOT,
&sx);
if (r < 0)
return log_error_errno(r, "statx(%s) failed: %m", path);

leading to

if (!FLAGS_SET(sx.stx_mask, mandatory_mask)) {
if (DEBUG_LOGGING) {
_cleanup_free_ char *mask_str = statx_mask_to_string(mandatory_mask & ~sx.stx_mask);
log_debug("statx() does not support '%s' mask (running on an old kernel?)", strnull(mask_str));
}
return -EUNATCH;
}

Steps to reproduce the problem

  • set up a rootfs on a filesystem with noatime
  • boot using systemd
  • observe systemd-tmpfiles-clean.service failing

Additional program output to the terminal or log subsystem illustrating the issue

# SYSTEMD_LOG_LEVEL=debug systemd-tmpfiles --clean
<...>
Running clean action for entry X /var/tmp/systemd-private-94cc8a77688e497f96d5b9019e66ed6f-*/tmp
statx() does not support 'STATX_ATIME' mask (running on an old kernel?)
statx(/var/tmp/systemd-private-94cc8a77688e497f96d5b9019e66ed6f-prometheus-smartctl-exporter.service-GKguQK/tmp) failed: Protocol driver not attached
statx() does not support 'STATX_ATIME' mask (running on an old kernel?)
statx(/var/tmp/systemd-private-94cc8a77688e497f96d5b9019e66ed6f-systemd-logind.service-k8j52T/tmp) failed: Protocol driver not attached
statx() does not support 'STATX_ATIME' mask (running on an old kernel?)
statx(/var/tmp/systemd-private-94cc8a77688e497f96d5b9019e66ed6f-irqbalance.service-7RJkev/tmp) failed: Protocol driver not attached
statx() does not support 'STATX_ATIME' mask (running on an old kernel?)
statx(/var/tmp/systemd-private-94cc8a77688e497f96d5b9019e66ed6f-chronyd.service-8hkO5G/tmp) failed: Protocol driver not attached
statx() does not support 'STATX_ATIME' mask (running on an old kernel?)
statx(/var/tmp/systemd-private-94cc8a77688e497f96d5b9019e66ed6f-dbus-broker.service-6P6LVl/tmp) failed: Protocol driver not attached
statx() does not support 'STATX_ATIME' mask (running on an old kernel?)
statx(/var/tmp/systemd-private-94cc8a77688e497f96d5b9019e66ed6f-nginx.service-B5HX8B/tmp) failed: Protocol driver not attached
Running clean action for entry x /var/tmp/systemd-private-94cc8a77688e497f96d5b9019e66ed6f-*
Running clean action for entry q /var/tmp
statx() does not support 'STATX_ATIME' mask (running on an old kernel?)
statx(/var/tmp) failed: Protocol driver not attached
<...>

Activity

  1. added
    bug 🐛
    on Mar 20, 2026
  2. added a commit that references this issue on Mar 20, 2026
    6b1727d
  3. added this to the v261 milestone on Mar 23, 2026
  4. added a commit that references this issue on Apr 6, 2026
    122de8d
  5. added a commit that references this issue on Apr 8, 2026
    df45055
  6. added a commit that references this issue on Apr 13, 2026
    77b550c
  7. mbartosi commented on May 7, 2026

    @mbartosi

    I can confirm this also happens on stable Gentoo now:

    maj 07 07:59:08 lat9330 systemd[1]: Starting Cleanup of Temporary Directories...
    maj 07 07:59:09 lat9330 systemd-tmpfiles[11391]: statx(/var/cache/man) failed: Protocol driver not attached
    maj 07 07:59:09 lat9330 systemd-tmpfiles[11391]: statx(/var/lib/systemd/pstore) failed: Protocol driver not attached
    maj 07 07:59:09 lat9330 systemd-tmpfiles[11391]: statx(/var/lib/systemd/ephemeral-trees) failed: Protocol driver not attached
    maj 07 07:59:09 lat9330 systemd-tmpfiles[11391]: statx(/var/lib/systemd/coredump) failed: Protocol driver not attached
    maj 07 07:59:09 lat9330 systemd-tmpfiles[11391]: statx(/var/tmp/systemd-private-0181b75034d14179867cb16f3074538f-systemd-logind.service-thnuno/tmp) failed: Protocol driver not attached
    maj 07 07:59:09 lat9330 systemd-tmpfiles[11391]: statx(/var/tmp) failed: Protocol driver not attached
    maj 07 07:59:09 lat9330 systemd[1]: systemd-tmpfiles-clean.service: Main process exited, code=exited, status=73/CANTCREAT
    maj 07 07:59:09 lat9330 systemd[1]: systemd-tmpfiles-clean.service: Failed with result 'exit-code'.
    maj 07 07:59:09 lat9330 systemd[1]: Failed to start Cleanup of Temporary Directories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛tmpfiles

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions