openzfs / zfs

OpenZFS on Linux and FreeBSD
https://openzfs.github.io/openzfs-docs
Other
10.63k stars 1.75k forks source link

performance issues with hard linking O_TMPFILE #13446

Open KoykL opened 2 years ago

KoykL commented 2 years ago

System information

Type Version/Name
Distribution Name fedora
Distribution Version 36
Kernel Version 5.17.5
Architecture x86_64
OpenZFS Version 2.1.4-1

Describe the problem you're observing

Discussed in https://github.com/openzfs/zfs/discussions/13441

Based on: https://github.com/openzfs/zfs/blob/52bad4f23daaa5f827f802c8d05785a27b80275d/module/os/linux/zfs/zfs_vnops_os.c#L3427 It seems hard linking a o_tmpfile waits for txg completion even when SLOG exists. Therefore, this operation is slow on a non-ssd pool even when SLOG exists. This causes performance problems for many kde apps (e.g. konsole), since they will perform and wait for this operation several times during launch (for updating config/session file).

It seems in https://github.com/openzfs/zfs/pull/4276, design decisions are made such that ZIL is not used for hard linking O_TMPFILE. However, given the impact on real-world applications, should the decision be revised?

Describe how to reproduce the problem

Launch kde apps such as konsole on a non-ssd pool with SLOG, observe the delay in konsole window showing up.

Include any warning/errors/backtraces from the system logs

Example strace (similar operations happen multiple times on a single launch):

openat(AT_FDCWD, "(redacted)/.config", O_RDWR|O_CLOEXEC|O_TMPFILE, 0600) = 11 statx(AT_FDCWD, "(redacted)/.config/konsolerc", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=1753, ...}) = 0 access("(redacted)/.config/konsolerc", R_OK) = 0 access("(redacted)/.config/konsolerc", W_OK) = 0 access("(redacted)/.config/konsolerc", X_OK) = -1 EACCES (Permission denied) fchmod(11, 0600) = 0 statx(11, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=0, ...}) = 0 write(11, (redacted), 1760) = 1760 statx(11, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=1760, ...}) = 0 lseek(11, 0, SEEK_SET) = 0 fdatasync(11) = 0 linkat(AT_FDCWD, "/proc/self/fd/11", AT_FDCWD, "(redacted)/.config/konsolerc", AT_SYMLINK_FOLLOW) = -1 EEXIST (File exists) linkat(AT_FDCWD, "/proc/self/fd/11", AT_FDCWD, "(redacted)/.config/konsolerc.OpMaLI", AT_SYMLINK_FOLLOW) = 0 (pauses here for a while) close(11)

stale[bot] commented 1 year ago

This issue has been automatically marked as "stale" because it has not had any activity for a while. It will be closed in 90 days if no further activity occurs. Thank you for your contributions.