Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

O_DIRECT with EINVAL error #57047

Open
hillar opened this issue Feb 14, 2025 · 6 comments
Open

O_DIRECT with EINVAL error #57047

hillar opened this issue Feb 14, 2025 · 6 comments

Comments

@hillar
Copy link

hillar commented Feb 14, 2025

Version

v23.8.0, v22.14.0, v20.18.2

Platform

Linux be0d621d6699 6.11.10-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Nov 23 00:53:13 UTC 2024 x86_64 GNU/Linux

Subsystem

fs

What steps will reproduce the bug?

Using file reading or writing with the constants.O_DIRECT flag in results in an EINVAL: invalid argument, read error when attempting to read a file.
Tested on xfs and overlayfs filesystems on Linux.
The same code works on tmpfs and on macos, obviously ;)

Interestingly, a similar implementation in Go using syscall.Open(..., syscall.O_DIRECT | syscall.O_SYNC, ...) and syscall.Read does work without errors on the same xfs and overlayfs filesystems.

How often does it reproduce? Is there a required condition?

createReadStream, createWriteStream, read after open

What is the expected behavior? Why is that the expected behavior?

file I/O to bypass the Linux kernel's caches

What do you see instead?

Uncaught Error: EINVAL: invalid argument, read

Additional information

No response

@santigimeno
Copy link
Member

Can you post a simple code that reproduces the issue and run the program with strace -f -o output.txt node program.js and post the file somewhere? Thanks

@hillar
Copy link
Author

hillar commented Feb 14, 2025

const fs = require('fs');
const readStream = fs.createReadStream('example.txt', { encoding: 'utf8', flags:fs.constants.O_DIRECT });
readStream.on('data', (chunk) => {
  console.log(chunk);
});
readStream.on('error', (err) => {
  console.error('Error reading file:', err);
});
readStream.on('end', () => {
  console.log('Finished reading file.');
});
952127 futex(0x6ba5890, FUTEX_WAKE_PRIVATE, 2147483647 <unfinished ...>
952137 futex(0x6ba5888, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
952127 <... futex resumed>)             = 0
952127 futex(0x6ba5888, FUTEX_WAKE_PRIVATE, 1) = 1
952134 <... futex resumed>)             = 0
952134 futex(0x6ba5820, FUTEX_WAKE_PRIVATE, 1) = 0
952134 openat(AT_FDCWD, "example.txt", O_RDONLY|O_DIRECT|O_CLOEXEC) = 20
952134 write(19, "\1\0\0\0\0\0\0\0", 8) = 8
952134 futex(0x6ba588c, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
952127 io_uring_enter(16, 2, 2, IORING_ENTER_GETEVENTS, NULL, 0) = 2
952127 epoll_pwait(15, [{events=EPOLLIN, data=0x13}], 1024, 0, NULL, 8) = 1
952127 read(19, "\1\0\0\0\0\0\0\0", 1024) = 8
952127 futex(0x6ba5888, FUTEX_WAKE_PRIVATE, 1) = 1
952135 <... futex resumed>)             = 0
952135 futex(0x6ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952127 epoll_pwait(15,  <unfinished ...>
952135 <... futex resumed>)             = 0
952127 <... epoll_pwait resumed>[], 1024, 0, NULL, 8) = 0
952135 read(20,  <unfinished ...>
952127 epoll_pwait(15,  <unfinished ...>
952135 <... read resumed>0x25c718f0, 65536) = -1 EINVAL (Invalid argument)
952135 write(19, "\1\0\0\0\0\0\0\0", 8 <unfinished ...>
952127 <... epoll_pwait resumed>[{events=EPOLLIN, data=0x13}], 1024, -1, NULL, 8) = 1
952135 <... write resumed>)             = 8
952127 read(19,  <unfinished ...>
952135 futex(0x6ba588c, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
952127 <... read resumed>"\1\0\0\0\0\0\0\0", 1024) = 8
952127 futex(0x6ba5888, FUTEX_WAKE_PRIVATE, 1) = 1
952136 <... futex resumed>)             = 0
952127 epoll_pwait(15,  <unfinished ...>
952136 futex(0x6ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952127 <... epoll_pwait resumed>[], 1024, 0, NULL, 8) = 0
952136 <... futex resumed>)             = 0
952127 epoll_pwait(15,  <unfinished ...>
952136 close(20)                        = 0
952136 write(19, "\1\0\0\0\0\0\0\0", 8 <unfinished ...>
952127 <... epoll_pwait resumed>[{events=EPOLLIN, data=0x13}], 1024, -1, NULL, 8) = 1
952136 <... write resumed>)             = 8
952127 read(19,  <unfinished ...>
952136 futex(0x6ba588c, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
952127 <... read resumed>"\1\0\0\0\0\0\0\0", 1024) = 8
952127 ioctl(2, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952127 ioctl(2, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952127 fcntl(2, F_GETFL)                = 0x402 (flags O_RDWR|O_APPEND)
952127 ioctl(2, TIOCGPTN, 0x7ffc9bebc380) = -1 ENOTTY (Inappropriate ioctl for device)
952127 ioctl(2, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952127 fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}) = 0
952127 readlink("/proc/self/fd/2", "/dev/pts/1", 255) = 10
952127 newfstatat(AT_FDCWD, "/dev/pts/1", {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}, 0) = 0
952127 openat(AT_FDCWD, "/dev/pts/1", O_RDWR|O_NOCTTY|O_CLOEXEC) = 20
952127 dup3(20, 2, O_CLOEXEC)           = 2
952127 openat(AT_FDCWD, "/dev/null", O_RDONLY|O_CLOEXEC) = 21
952127 ioctl(20, FIONBIO, [1])          = 0
952127 ioctl(20, FIONBIO, [0])          = 0
952127 ioctl(20, TIOCGWINSZ, {ws_row=47, ws_col=212, ws_xpixel=1484, ws_ypixel=658}) = 0
952127 rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
952127 read(5, "*", 1)                  = 1
952127 rt_sigaction(SIGWINCH, {sa_handler=0x2087a00, sa_mask=~[RTMIN RT_1], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f9596a4efd0}, NULL, 8) = 0
952127 write(6, "*", 1)                 = 1
952127 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
952127 write(20, "Error reading file: [Error: EINV"..., 144) = 144
952127 epoll_ctl(15, EPOLL_CTL_DEL, 20, 0x7ffc9bec39e4) = -1 ENOENT (No such file or directory)
952127 close(20)                        = 0
952127 rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
952127 read(5, "*", 1)                  = 1
952127 rt_sigaction(SIGWINCH, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f9596a4efd0}, NULL, 8) = 0
952127 write(6, "*", 1)                 = 1
952127 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
952127 epoll_pwait(15, [], 1024, 0, NULL, 8) = 0
952127 epoll_pwait(15, [], 1024, 0, NULL, 8) = 0
952127 munmap(0x28390a6c0000, 262144)   = 0
952127 munmap(0x3bbb2ec0000, 262144)    = 0
952127 munmap(0x60b080c0000, 262144)    = 0
952127 munmap(0x287e1bb00000, 258048)   = 0
952127 munmap(0x204702840000, 262144)   = 0
952127 munmap(0x382cc3c80000, 262144)   = 0
952127 munmap(0x2f2326440000, 262144)   = 0
952127 munmap(0x14ea7ba00000, 262144)   = 0
952127 munmap(0x1efd58d40000, 262144)   = 0
952127 munmap(0x1cbafcc00000, 262144)   = 0
952127 munmap(0x33620d40000, 262144)    = 0
952127 madvise(0x7f9570000000, 262144, MADV_DONTNEED) = 0
952127 munmap(0x9a90f140000, 262144)    = 0
952127 munmap(0x9c3c0d00000, 262144)    = 0
952127 munmap(0x89a471c0000, 258048)    = 0
952127 munmap(0x38e8b4a80000, 262144)   = 0
952127 munmap(0x16ed5b8c0000, 266240)   = 0
952127 munmap(0x17047adc0000, 262144)   = 0
952127 munmap(0x3b696dc0000, 262144)    = 0
952127 munmap(0x263f2c480000, 262144)   = 0
952127 munmap(0x1f49d2ac0000, 262144)   = 0
952127 munmap(0x7f9594168000, 135168)   = 0
952127 munmap(0xf8e78300000, 118784)    = 0
952127 munmap(0x7f9570000000, 536870912) = 0
952127 fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}) = 0
952127 fcntl(0, F_GETFL)                = 0x402 (flags O_RDWR|O_APPEND)
952127 rt_sigprocmask(SIG_BLOCK, [TTOU], NULL, 8) = 0
952127 ioctl(0, TCSETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952127 ioctl(0, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952127 rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
952127 fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}) = 0
952127 fcntl(1, F_GETFL)                = 0x402 (flags O_RDWR|O_APPEND)
952127 rt_sigprocmask(SIG_BLOCK, [TTOU], NULL, 8) = 0
952127 ioctl(1, TCSETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952127 ioctl(1, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952127 rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
952127 fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}) = 0
952127 fcntl(2, F_GETFL)                = 0x8002 (flags O_RDWR|O_LARGEFILE)
952127 rt_sigprocmask(SIG_BLOCK, [TTOU], NULL, 8) = 0
952127 ioctl(2, TCSETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952127 ioctl(2, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952127 rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
952127 rt_sigaction(SIGHUP, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGINT, NULL, {sa_handler=0xfe0310, sa_mask=~[KILL STOP RTMIN RT_1], sa_flags=SA_RESTORER|SA_RESETHAND, sa_restorer=0x7f9596a4efd0}, 8) = 0
952127 rt_sigaction(SIGQUIT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGILL, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGTRAP, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGABRT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGBUS, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGFPE, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGUSR1, NULL, {sa_handler=0x11f0e30, sa_mask=~[KILL STOP RTMIN RT_1], sa_flags=SA_RESTORER, sa_restorer=0x7f9596a4efd0}, 8) = 0
952127 rt_sigaction(SIGSEGV, NULL, {sa_handler=0xfe0480, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f9596a4efd0}, 8) = 0
952127 rt_sigaction(SIGUSR2, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f9596a4efd0}, NULL, 8) = 0
952127 rt_sigaction(SIGALRM, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGTERM, NULL, {sa_handler=0xfe0310, sa_mask=~[KILL STOP RTMIN RT_1], sa_flags=SA_RESTORER|SA_RESETHAND, sa_restorer=0x7f9596a4efd0}, 8) = 0
952127 rt_sigaction(SIGSTKFLT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGCHLD, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGCONT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGTSTP, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGTTIN, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGTTOU, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGURG, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGXCPU, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGXFSZ, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f9596a4efd0}, NULL, 8) = 0
952127 rt_sigaction(SIGVTALRM, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGPROF, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGWINCH, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f9596a4efd0}, 8) = 0
952127 rt_sigaction(SIGIO, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGPWR, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 rt_sigaction(SIGSYS, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952127 futex(0x25ba5870, FUTEX_WAKE_PRIVATE, 2147483647) = 4
952130 <... futex resumed>)             = 0
952131 <... futex resumed>)             = 0
952127 write(14, "\1\0\0\0\0\0\0\0", 8 <unfinished ...>
952132 <... futex resumed>)             = 0
952131 futex(0x25ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952129 <... futex resumed>)             = 0
952127 <... write resumed>)             = 8
952132 futex(0x25ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952131 <... futex resumed>)             = 0
952129 futex(0x25ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952128 <... epoll_pwait resumed>[{events=EPOLLIN, data=0xe}], 1024, -1, NULL, 8) = 1
952127 futex(0x7f9596a0d990, FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, 952128, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
952132 <... futex resumed>)             = 0
952131 mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 <unfinished ...>
952129 <... futex resumed>)             = 0
952132 mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 <unfinished ...>
952128 read(14,  <unfinished ...>
952131 <... mmap resumed>)              = 0x7f9588000000
952129 mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 <unfinished ...>
952132 <... mmap resumed>)              = 0x7f9580000000
952131 munmap(0x7f958c000000, 67108864 <unfinished ...>
952128 <... read resumed>"\1\0\0\0\0\0\0\0", 1024) = 8
952132 munmap(0x7f9584000000, 67108864 <unfinished ...>
952129 <... mmap resumed>)              = 0x7f9578000000
952131 <... munmap resumed>)            = 0
952128 close(12 <unfinished ...>
952132 <... munmap resumed>)            = 0
952131 mprotect(0x7f9588000000, 135168, PROT_READ|PROT_WRITE <unfinished ...>
952129 munmap(0x7f957c000000, 67108864 <unfinished ...>
952132 mprotect(0x7f9580000000, 135168, PROT_READ|PROT_WRITE <unfinished ...>
952128 <... close resumed>)             = 0
952131 <... mprotect resumed>)          = 0
952132 <... mprotect resumed>)          = 0
952129 <... munmap resumed>)            = 0
952128 close(13 <unfinished ...>
952131 rt_sigprocmask(SIG_BLOCK, ~[RT_1],  <unfinished ...>
952129 mprotect(0x7f9578000000, 135168, PROT_READ|PROT_WRITE <unfinished ...>
952132 rt_sigprocmask(SIG_BLOCK, ~[RT_1],  <unfinished ...>
952131 <... rt_sigprocmask resumed>NULL, 8) = 0
952128 <... close resumed>)             = 0
952132 <... rt_sigprocmask resumed>NULL, 8) = 0
952131 madvise(0x7f9594a0a000, 8368128, MADV_DONTNEED <unfinished ...>
952129 <... mprotect resumed>)          = 0
952132 madvise(0x7f9594209000, 8368128, MADV_DONTNEED <unfinished ...>
952128 munmap(0x7f9596f9b000, 8256 <unfinished ...>
952131 <... madvise resumed>)           = 0
952129 rt_sigprocmask(SIG_BLOCK, ~[RT_1],  <unfinished ...>
952132 <... madvise resumed>)           = 0
952131 exit(0 <unfinished ...>
952128 <... munmap resumed>)            = 0
952132 exit(0 <unfinished ...>
952131 <... exit resumed>)              = ?
952129 <... rt_sigprocmask resumed>NULL, 8) = 0
952132 <... exit resumed>)              = ?
952128 munmap(0x7f9596e6e000, 16384 <unfinished ...>
952131 +++ exited with 0 +++
952129 madvise(0x7f9595a0c000, 8368128, MADV_DONTNEED <unfinished ...>
952132 +++ exited with 0 +++
952128 <... munmap resumed>)            = 0
952130 futex(0x25ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952129 <... madvise resumed>)           = 0
952128 close(11 <unfinished ...>
952130 <... futex resumed>)             = 0
952129 exit(0 <unfinished ...>
952130 rt_sigprocmask(SIG_BLOCK, ~[RT_1],  <unfinished ...>
952129 <... exit resumed>)              = ?
952128 <... close resumed>)             = 0
952130 <... rt_sigprocmask resumed>NULL, 8) = 0
952129 +++ exited with 0 +++
952128 close(14 <unfinished ...>
952130 madvise(0x7f959520b000, 8368128, MADV_DONTNEED <unfinished ...>
952128 <... close resumed>)             = 0
952130 <... madvise resumed>)           = 0
952128 close(10 <unfinished ...>
952130 exit(0)                          = ?
952128 <... close resumed>)             = 0
952130 +++ exited with 0 +++
952128 rt_sigprocmask(SIG_BLOCK, ~[RT_1], NULL, 8) = 0
952128 madvise(0x7f959620d000, 8368128, MADV_DONTNEED) = 0
952128 exit(0)                          = ?
952127 <... futex resumed>)             = 0
952128 +++ exited with 0 +++
952127 munmap(0x7f959620d000, 8392704)  = 0
952127 io_uring_enter(4, 2, 2, IORING_ENTER_GETEVENTS, NULL, 0) = 2
952127 epoll_pwait(3, [], 1024, 0, NULL, 8) = 0
952127 close(7)                         = 0
952127 close(8)                         = 0
952127 munmap(0x7f9596f9e000, 8256)     = 0
952127 munmap(0x7f9596e72000, 16384)    = 0
952127 close(4)                         = 0
952127 close(9)                         = 0
952127 close(3)                         = 0
952127 futex(0x6ba5de8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
952127 fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}) = 0
952127 fcntl(0, F_GETFL)                = 0x402 (flags O_RDWR|O_APPEND)
952127 rt_sigprocmask(SIG_BLOCK, [TTOU], NULL, 8) = 0
952127 ioctl(0, TCSETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952127 ioctl(0, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952127 rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
952127 fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}) = 0
952127 fcntl(1, F_GETFL)                = 0x402 (flags O_RDWR|O_APPEND)
952127 rt_sigprocmask(SIG_BLOCK, [TTOU], NULL, 8) = 0
952127 ioctl(1, TCSETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952127 ioctl(1, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952127 rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
952127 fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}) = 0
952127 fcntl(2, F_GETFL)                = 0x8002 (flags O_RDWR|O_LARGEFILE)
952127 rt_sigprocmask(SIG_BLOCK, [TTOU], NULL, 8) = 0
952127 ioctl(2, TCSETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952127 ioctl(2, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952127 rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
952127 close(5)                         = 0
952127 close(6)                         = 0
952127 futex(0x6ba5888, FUTEX_WAKE_PRIVATE, 1) = 1
952137 <... futex resumed>)             = 0
952127 futex(0x7f956ffff990, FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, 952134, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
952137 futex(0x6ba588c, FUTEX_WAKE_PRIVATE, 1) = 1
952134 <... futex resumed>)             = 0
952137 futex(0x6ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952134 futex(0x6ba588c, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952137 <... futex resumed>)             = 0
952134 <... futex resumed>)             = 1
952137 rt_sigprocmask(SIG_BLOCK, ~[RT_1],  <unfinished ...>
952135 <... futex resumed>)             = 0
952137 <... rt_sigprocmask resumed>NULL, 8) = 0
952134 futex(0x6ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952135 futex(0x6ba588c, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952137 madvise(0x7f956dffc000, 8368128, MADV_DONTNEED <unfinished ...>
952134 <... futex resumed>)             = 0
952135 <... futex resumed>)             = 1
952137 <... madvise resumed>)           = 0
952136 <... futex resumed>)             = 0
952134 rt_sigprocmask(SIG_BLOCK, ~[RT_1],  <unfinished ...>
952137 exit(0 <unfinished ...>
952136 futex(0x6ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952135 futex(0x6ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952137 <... exit resumed>)              = ?
952136 <... futex resumed>)             = 0
952134 <... rt_sigprocmask resumed>NULL, 8) = 0
952137 +++ exited with 0 +++
952136 rt_sigprocmask(SIG_BLOCK, ~[RT_1],  <unfinished ...>
952135 <... futex resumed>)             = 0
952134 madvise(0x7f956f7ff000, 8368128, MADV_DONTNEED <unfinished ...>
952136 <... rt_sigprocmask resumed>NULL, 8) = 0
952135 rt_sigprocmask(SIG_BLOCK, ~[RT_1],  <unfinished ...>
952136 madvise(0x7f956e7fd000, 8368128, MADV_DONTNEED <unfinished ...>
952134 <... madvise resumed>)           = 0
952135 <... rt_sigprocmask resumed>NULL, 8) = 0
952136 <... madvise resumed>)           = 0
952134 exit(0 <unfinished ...>
952135 madvise(0x7f956effe000, 8368128, MADV_DONTNEED <unfinished ...>
952136 exit(0 <unfinished ...>
952134 <... exit resumed>)              = ?
952136 <... exit resumed>)              = ?
952135 <... madvise resumed>)           = 0
952127 <... futex resumed>)             = 0
952136 +++ exited with 0 +++
952134 +++ exited with 0 +++
952135 exit(0 <unfinished ...>
952127 munmap(0x7f9595a0c000, 8392704 <unfinished ...>
952135 <... exit resumed>)              = ?
952127 <... munmap resumed>)            = 0
952135 +++ exited with 0 +++
952127 munmap(0x7f959520b000, 8392704)  = 0
952127 munmap(0x7f9594a0a000, 8392704)  = 0
952127 munmap(0x7f9594209000, 8392704)  = 0
952127 exit_group(0)                    = ?
952133 <... futex resumed>)             = ?
952133 +++ exited with 0 +++

@hillar
Copy link
Author

hillar commented Feb 14, 2025

const fs = require('fs');
const CHUNK_SIZE = 512; 
const buffer = Buffer.alloc(CHUNK_SIZE);
fs.open('example.txt', fs.constants.O_DIRECT, (err, fd) => {
  if (err) {
    console.error('Error opening file:', err);
    return;
  }
  function readNext() {
    fs.read(fd, buffer, 0, CHUNK_SIZE, null, (err, bytesRead) => {
      if (err) {
        console.error('Error reading file:', err);
        fs.close(fd, (err) => {
          if (err) console.error('Error closing file:', err);
        });
        return;
      }
      if (bytesRead > 0) {
        console.log(buffer.toString('utf8', 0, bytesRead));
        readNext();
      } else {
        fs.close(fd, (err) => {
          if (err) console.error('Error closing file:', err);
          else console.log('Finished reading file.');
        });
      }
    });
  }
 readNext();
});

952233 <... futex resumed>)             = 0
952233 futex(0x6ba5888, FUTEX_WAKE_PRIVATE, 1) = 1
952240 <... futex resumed>)             = 0
952240 futex(0x6ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952233 io_uring_enter(16, 2, 2, IORING_ENTER_GETEVENTS, NULL, 0 <unfinished ...>
952240 <... futex resumed>)             = 0
952233 <... io_uring_enter resumed>)    = 2
952240 openat(AT_FDCWD, "example.txt", O_RDONLY|O_DIRECT|O_CLOEXEC <unfinished ...>
952233 epoll_pwait(15, [], 1024, 0, NULL, 8) = 0
952240 <... openat resumed>)            = 20
952233 epoll_pwait(15,  <unfinished ...>
952240 write(19, "\1\0\0\0\0\0\0\0", 8 <unfinished ...>
952233 <... epoll_pwait resumed>[{events=EPOLLIN, data=0x13}], 1024, -1, NULL, 8) = 1
952240 <... write resumed>)             = 8
952233 read(19,  <unfinished ...>
952240 futex(0x6ba588c, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
952233 <... read resumed>"\1\0\0\0\0\0\0\0", 1024) = 8
952233 futex(0x6ba5888, FUTEX_WAKE_PRIVATE, 1) = 1
952241 <... futex resumed>)             = 0
952233 futex(0x6ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952241 futex(0x6ba5820, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...>
952233 <... futex resumed>)             = 0
952241 <... futex resumed>)             = -1 EAGAIN (Resource temporarily unavailable)
952233 epoll_pwait(15,  <unfinished ...>
952241 futex(0x6ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952233 <... epoll_pwait resumed>[], 1024, 0, NULL, 8) = 0
952241 <... futex resumed>)             = 0
952233 epoll_pwait(15,  <unfinished ...>
952241 read(20, 0x1e0fa730, 512)        = -1 EINVAL (Invalid argument)
952241 write(19, "\1\0\0\0\0\0\0\0", 8) = 8
952233 <... epoll_pwait resumed>[{events=EPOLLIN, data=0x13}], 1024, -1, NULL, 8) = 1
952241 futex(0x6ba588c, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
952233 read(19, "\1\0\0\0\0\0\0\0", 1024) = 8
952233 ioctl(2, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952233 mmap(0x443a2140000, 520192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x443a2140000
952233 madvise(0x443a2140000, 520192, MADV_DONTFORK) = 0
952233 munmap(0x443a2180000, 258048)    = 0
952233 ioctl(2, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952233 fcntl(2, F_GETFL)                = 0x402 (flags O_RDWR|O_APPEND)
952233 ioctl(2, TIOCGPTN, 0x7ffc7ee66110) = -1 ENOTTY (Inappropriate ioctl for device)
952233 ioctl(2, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952233 fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}) = 0
952233 readlink("/proc/self/fd/2", "/dev/pts/1", 255) = 10
952233 newfstatat(AT_FDCWD, "/dev/pts/1", {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}, 0) = 0
952233 openat(AT_FDCWD, "/dev/pts/1", O_RDWR|O_NOCTTY|O_CLOEXEC) = 21
952233 dup3(21, 2, O_CLOEXEC)           = 2
952233 openat(AT_FDCWD, "/dev/null", O_RDONLY|O_CLOEXEC) = 22
952233 ioctl(21, FIONBIO, [1])          = 0
952233 ioctl(21, FIONBIO, [0])          = 0
952233 ioctl(21, TIOCGWINSZ, {ws_row=47, ws_col=212, ws_xpixel=1484, ws_ypixel=658}) = 0
952233 rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
952233 read(5, "*", 1)                  = 1
952233 rt_sigaction(SIGWINCH, {sa_handler=0x2087a00, sa_mask=~[RTMIN RT_1], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f036e04efd0}, NULL, 8) = 0
952233 write(6, "*", 1)                 = 1
952233 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
952233 write(21, "Error reading file: [Error: EINV"..., 144) = 144
952233 futex(0x6ba5888, FUTEX_WAKE_PRIVATE, 1) = 1
952233 epoll_pwait(15, [], 1024, 0, NULL, 8) = 0
952233 epoll_pwait(15,  <unfinished ...>
952242 <... futex resumed>)             = 0
952242 futex(0x6ba5820, FUTEX_WAKE_PRIVATE, 1) = 0
952242 close(20)                        = 0
952242 write(19, "\1\0\0\0\0\0\0\0", 8 <unfinished ...>
952233 <... epoll_pwait resumed>[{events=EPOLLIN, data=0x13}], 1024, -1, NULL, 8) = 1
952242 <... write resumed>)             = 8
952233 read(19, "\1\0\0\0\0\0\0\0", 1024) = 8
952242 futex(0x6ba588c, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
952233 epoll_ctl(15, EPOLL_CTL_DEL, 21, 0x7ffc7ee6d544) = -1 ENOENT (No such file or directory)
952233 close(21)                        = 0
952233 rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
952233 read(5, "*", 1)                  = 1
952233 rt_sigaction(SIGWINCH, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f036e04efd0}, NULL, 8) = 0
952233 write(6, "*", 1)                 = 1
952233 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
952233 epoll_pwait(15, [], 1024, 0, NULL, 8) = 0
952233 epoll_pwait(15, [], 1024, 0, NULL, 8) = 0
952233 munmap(0x2b9d29100000, 262144)   = 0
952233 munmap(0x17640dd80000, 262144)   = 0
952233 munmap(0x3047b9780000, 262144)   = 0
952233 munmap(0x398d30880000, 258048)   = 0
952233 munmap(0x21a5ca280000, 262144)   = 0
952233 munmap(0x33787c0000, 262144)     = 0
952233 munmap(0x2f8141680000, 262144)   = 0
952233 munmap(0x203c39900000, 262144)   = 0
952233 munmap(0x3a1dac0000, 262144)     = 0
952233 munmap(0x37c5769c0000, 262144)   = 0
952233 munmap(0x443a2140000, 262144)    = 0
952233 madvise(0x7f0347740000, 262144, MADV_DONTNEED) = 0
952233 munmap(0x1febc4d80000, 262144)   = 0
952233 munmap(0x2ba6a8440000, 262144)   = 0
952233 munmap(0x38dd53f80000, 258048)   = 0
952233 munmap(0x3f79bd00000, 262144)    = 0
952233 munmap(0x26ac91840000, 266240)   = 0
952233 munmap(0x18ae49600000, 262144)   = 0
952233 munmap(0x37a35440000, 262144)    = 0
952233 munmap(0x3bd913440000, 262144)   = 0
952233 munmap(0x2e8395040000, 262144)   = 0
952233 munmap(0x7f036775a000, 135168)   = 0
952233 munmap(0x2d0422fc0000, 118784)   = 0
952233 munmap(0x7f0347740000, 536870912) = 0
952233 fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}) = 0
952233 fcntl(0, F_GETFL)                = 0x402 (flags O_RDWR|O_APPEND)
952233 rt_sigprocmask(SIG_BLOCK, [TTOU], NULL, 8) = 0
952233 ioctl(0, TCSETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952233 ioctl(0, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952233 rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
952233 fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}) = 0
952233 fcntl(1, F_GETFL)                = 0x402 (flags O_RDWR|O_APPEND)
952233 rt_sigprocmask(SIG_BLOCK, [TTOU], NULL, 8) = 0
952233 ioctl(1, TCSETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952233 ioctl(1, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952233 rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
952233 fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}) = 0
952233 fcntl(2, F_GETFL)                = 0x8002 (flags O_RDWR|O_LARGEFILE)
952233 rt_sigprocmask(SIG_BLOCK, [TTOU], NULL, 8) = 0
952233 ioctl(2, TCSETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952233 ioctl(2, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952233 rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
952233 rt_sigaction(SIGHUP, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGINT, NULL, {sa_handler=0xfe0310, sa_mask=~[KILL STOP RTMIN RT_1], sa_flags=SA_RESTORER|SA_RESETHAND, sa_restorer=0x7f036e04efd0}, 8) = 0
952233 rt_sigaction(SIGQUIT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGILL, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGTRAP, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGABRT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGBUS, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGFPE, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGUSR1, NULL, {sa_handler=0x11f0e30, sa_mask=~[KILL STOP RTMIN RT_1], sa_flags=SA_RESTORER, sa_restorer=0x7f036e04efd0}, 8) = 0
952233 rt_sigaction(SIGSEGV, NULL, {sa_handler=0xfe0480, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f036e04efd0}, 8) = 0
952233 rt_sigaction(SIGUSR2, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f036e04efd0}, NULL, 8) = 0
952233 rt_sigaction(SIGALRM, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGTERM, NULL, {sa_handler=0xfe0310, sa_mask=~[KILL STOP RTMIN RT_1], sa_flags=SA_RESTORER|SA_RESETHAND, sa_restorer=0x7f036e04efd0}, 8) = 0
952233 rt_sigaction(SIGSTKFLT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGCHLD, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGCONT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGTSTP, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGTTIN, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGTTOU, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGURG, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGXCPU, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGXFSZ, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f036e04efd0}, NULL, 8) = 0
952233 rt_sigaction(SIGVTALRM, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGPROF, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGWINCH, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f036e04efd0}, 8) = 0
952233 rt_sigaction(SIGIO, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGPWR, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 rt_sigaction(SIGSYS, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
952233 futex(0x1e015870, FUTEX_WAKE_PRIVATE, 2147483647) = 4
952238 <... futex resumed>)             = 0
952235 <... futex resumed>)             = 0
952233 write(14, "\1\0\0\0\0\0\0\0", 8 <unfinished ...>
952238 futex(0x1e015820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952233 <... write resumed>)             = 8
952236 <... futex resumed>)             = 0
952235 futex(0x1e015820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952233 futex(0x7f036e00d990, FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, 952234, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
952238 <... futex resumed>)             = 0
952237 <... futex resumed>)             = 0
952234 <... epoll_pwait resumed>[{events=EPOLLIN, data=0xe}], 1024, -1, NULL, 8) = 1
952238 mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 <unfinished ...>
952237 futex(0x1e015820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952236 futex(0x1e015820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952235 <... futex resumed>)             = 0
952238 <... mmap resumed>)              = 0x7f035f600000
952236 <... futex resumed>)             = 0
952237 <... futex resumed>)             = 0
952234 read(14,  <unfinished ...>
952238 munmap(0x7f035f600000, 10485760 <unfinished ...>
952236 mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 <unfinished ...>
952235 mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 <unfinished ...>
952237 mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 <unfinished ...>
952234 <... read resumed>"\1\0\0\0\0\0\0\0", 1024) = 8
952238 <... munmap resumed>)            = 0
952236 <... mmap resumed>)              = 0x7f0358000000
952235 <... mmap resumed>)              = 0x7f0350000000
952237 <... mmap resumed>)              = 0x7f0348000000
952236 munmap(0x7f035c000000, 67108864 <unfinished ...>
952234 close(12 <unfinished ...>
952238 munmap(0x7f0364000000, 56623104 <unfinished ...>
952237 munmap(0x7f034c000000, 67108864 <unfinished ...>
952235 munmap(0x7f0354000000, 67108864 <unfinished ...>
952238 <... munmap resumed>)            = 0
952236 <... munmap resumed>)            = 0
952234 <... close resumed>)             = 0
952238 mprotect(0x7f0360000000, 135168, PROT_READ|PROT_WRITE <unfinished ...>
952236 mprotect(0x7f0358000000, 135168, PROT_READ|PROT_WRITE <unfinished ...>
952235 <... munmap resumed>)            = 0
952238 <... mprotect resumed>)          = 0
952237 <... munmap resumed>)            = 0
952234 close(13 <unfinished ...>
952236 <... mprotect resumed>)          = 0
952235 mprotect(0x7f0350000000, 135168, PROT_READ|PROT_WRITE <unfinished ...>
952238 rt_sigprocmask(SIG_BLOCK, ~[RT_1],  <unfinished ...>
952237 mprotect(0x7f0348000000, 135168, PROT_READ|PROT_WRITE <unfinished ...>
952234 <... close resumed>)             = 0
952238 <... rt_sigprocmask resumed>NULL, 8) = 0
952236 rt_sigprocmask(SIG_BLOCK, ~[RT_1],  <unfinished ...>
952235 <... mprotect resumed>)          = 0
952238 madvise(0x7f03677ff000, 8368128, MADV_DONTNEED <unfinished ...>
952237 <... mprotect resumed>)          = 0
952236 <... rt_sigprocmask resumed>NULL, 8) = 0
952234 munmap(0x7f036e58d000, 8256 <unfinished ...>
952238 <... madvise resumed>)           = 0
952236 madvise(0x7f036c807000, 8368128, MADV_DONTNEED <unfinished ...>
952235 rt_sigprocmask(SIG_BLOCK, ~[RT_1],  <unfinished ...>
952238 exit(0 <unfinished ...>
952237 rt_sigprocmask(SIG_BLOCK, ~[RT_1],  <unfinished ...>
952236 <... madvise resumed>)           = 0
952234 <... munmap resumed>)            = 0
952238 <... exit resumed>)              = ?
952237 <... rt_sigprocmask resumed>NULL, 8) = 0
952236 exit(0 <unfinished ...>
952235 <... rt_sigprocmask resumed>NULL, 8) = 0
952238 +++ exited with 0 +++
952237 madvise(0x7f036c006000, 8368128, MADV_DONTNEED <unfinished ...>
952236 <... exit resumed>)              = ?
952234 munmap(0x7f036d809000, 16384 <unfinished ...>
952235 madvise(0x7f036d008000, 8368128, MADV_DONTNEED <unfinished ...>
952237 <... madvise resumed>)           = 0
952236 +++ exited with 0 +++
952234 <... munmap resumed>)            = 0
952235 <... madvise resumed>)           = 0
952237 exit(0 <unfinished ...>
952234 close(11 <unfinished ...>
952235 exit(0 <unfinished ...>
952237 <... exit resumed>)              = ?
952235 <... exit resumed>)              = ?
952234 <... close resumed>)             = 0
952237 +++ exited with 0 +++
952235 +++ exited with 0 +++
952234 close(14)                        = 0
952234 close(10)                        = 0
952234 rt_sigprocmask(SIG_BLOCK, ~[RT_1], NULL, 8) = 0
952234 madvise(0x7f036d80d000, 8368128, MADV_DONTNEED) = 0
952234 exit(0)                          = ?
952233 <... futex resumed>)             = 0
952234 +++ exited with 0 +++
952233 munmap(0x7f036d80d000, 8392704)  = 0
952233 io_uring_enter(4, 2, 2, IORING_ENTER_GETEVENTS, NULL, 0) = 2
952233 epoll_pwait(3, [], 1024, 0, NULL, 8) = 0
952233 close(7)                         = 0
952233 close(8)                         = 0
952233 munmap(0x7f036e590000, 8256)     = 0
952233 munmap(0x7f036e464000, 16384)    = 0
952233 close(4)                         = 0
952233 close(9)                         = 0
952233 close(3)                         = 0
952233 futex(0x6ba5de8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
952233 fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}) = 0
952233 fcntl(0, F_GETFL)                = 0x402 (flags O_RDWR|O_APPEND)
952233 rt_sigprocmask(SIG_BLOCK, [TTOU], NULL, 8) = 0
952233 ioctl(0, TCSETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952233 ioctl(0, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952233 rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
952233 fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}) = 0
952233 fcntl(1, F_GETFL)                = 0x402 (flags O_RDWR|O_APPEND)
952233 rt_sigprocmask(SIG_BLOCK, [TTOU], NULL, 8) = 0
952233 ioctl(1, TCSETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952233 ioctl(1, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952233 rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
952233 fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x1), ...}) = 0
952233 fcntl(2, F_GETFL)                = 0x8002 (flags O_RDWR|O_LARGEFILE)
952233 rt_sigprocmask(SIG_BLOCK, [TTOU], NULL, 8) = 0
952233 ioctl(2, TCSETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952233 ioctl(2, TCGETS, {c_iflag=ICRNL|IXON|IXANY|IMAXBEL, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
952233 rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
952233 close(5)                         = 0
952233 close(6)                         = 0
952233 futex(0x6ba5888, FUTEX_WAKE_PRIVATE, 1) = 1
952243 <... futex resumed>)             = 0
952233 futex(0x7f034773f990, FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, 952240, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
952243 futex(0x6ba588c, FUTEX_WAKE_PRIVATE, 1) = 1
952240 <... futex resumed>)             = 0
952243 futex(0x6ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952240 futex(0x6ba588c, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952243 <... futex resumed>)             = 0
952240 <... futex resumed>)             = 1
952241 <... futex resumed>)             = 0
952243 rt_sigprocmask(SIG_BLOCK, ~[RT_1],  <unfinished ...>
952240 futex(0x6ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952241 futex(0x6ba588c, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952243 <... rt_sigprocmask resumed>NULL, 8) = 0
952240 <... futex resumed>)             = 0
952242 <... futex resumed>)             = 0
952243 madvise(0x7f034573c000, 8368128, MADV_DONTNEED <unfinished ...>
952241 <... futex resumed>)             = 1
952242 futex(0x6ba5820, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...>
952240 rt_sigprocmask(SIG_BLOCK, ~[RT_1],  <unfinished ...>
952243 <... madvise resumed>)           = 0
952242 <... futex resumed>)             = -1 EAGAIN (Resource temporarily unavailable)
952241 futex(0x6ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952243 exit(0 <unfinished ...>
952242 futex(0x6ba5820, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
952240 <... rt_sigprocmask resumed>NULL, 8) = 0
952243 <... exit resumed>)              = ?
952242 <... futex resumed>)             = 0
952241 <... futex resumed>)             = 0
952243 +++ exited with 0 +++
952242 rt_sigprocmask(SIG_BLOCK, ~[RT_1],  <unfinished ...>
952240 madvise(0x7f0346f3f000, 8368128, MADV_DONTNEED <unfinished ...>
952242 <... rt_sigprocmask resumed>NULL, 8) = 0
952241 rt_sigprocmask(SIG_BLOCK, ~[RT_1],  <unfinished ...>
952242 madvise(0x7f0345f3d000, 8368128, MADV_DONTNEED <unfinished ...>
952240 <... madvise resumed>)           = 0
952241 <... rt_sigprocmask resumed>NULL, 8) = 0
952242 <... madvise resumed>)           = 0
952240 exit(0 <unfinished ...>
952241 madvise(0x7f034673e000, 8368128, MADV_DONTNEED <unfinished ...>
952242 exit(0 <unfinished ...>
952240 <... exit resumed>)              = ?
952242 <... exit resumed>)              = ?
952242 +++ exited with 0 +++
952240 +++ exited with 0 +++
952233 <... futex resumed>)             = 0
952241 <... madvise resumed>)           = 0
952233 munmap(0x7f036d008000, 8392704 <unfinished ...>
952241 exit(0)                          = ?
952233 <... munmap resumed>)            = 0
952233 munmap(0x7f036c807000, 8392704 <unfinished ...>
952241 +++ exited with 0 +++
952233 <... munmap resumed>)            = 0
952233 munmap(0x7f036c006000, 8392704)  = 0
952233 munmap(0x7f03677ff000, 8392704)  = 0
952233 exit_group(0)                    = ?
952239 <... futex resumed>)             = ?
952239 +++ exited with 0 +++

@bnoordhuis
Copy link
Member

O_DIRECT requires that the buffer is a multiple of 512 but also that it's aligned on a 512 byte boundary. Not all file systems enforce that but some do.

In node, it's not very practical to get a buffer with a particular alignment so you're probably out of luck.

@hillar
Copy link
Author

hillar commented Feb 15, 2025

In node, it's not very practical to get a buffer with a particular alignment so you're probably out of luck.

sorry, english is not my first language, should i read it: in nodejs there is no way to tell to the linux kernel to bypass page cache

@bnoordhuis
Copy link
Member

Yes, that's what I mean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants