IBM Support

IBM Spectrum Scale: Using O_DIRECT and fork(2) in the same process in Linux

Troubleshooting


Problem

IBM Spectrum Scale: Using O_DIRECT and fork(2) in the same process in Linux

Symptom

System call read() may fail to record data into the user buffer when direct I/O is used, that is, when specifying the O_DIRECT flag when opening the file.

Cause

Because of a limitation in Linux, I/O operations with O_DIRECT should not be issued concurrently with a fork(2) system call that is invoked by the same process. Any calls to fork() in the program should be issued only after O_DIRECT I/O operations are completed. That is, fork() should not be invoked while O_DIRECT I/O operations are still pending completion. For more information, see the open(2) system call in the Linux documentation.

According to the open(2) man page:

http://man7.org/linux/man-pages/man2/open.2.html

"O_DIRECT I/Os should never be run concurrently with the fork(2) system call, if the memory buffer is a private mapping [...]"

Environment

Linux operating system with Spectrum Scale (any release).

Diagnosing The Problem

When issuing the read() system call, the data is not read into the user-specified memory buffer.

Resolving The Problem

Either do not use direct I/O (O_DIRECT flag in open(2)) in a program where fork(2) is also issued, including indirect invocations via the system(3) routine, or ensure that no I/O operations on the a file opened with O_DIRECT remain pending at the time fork() is invoked.

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"STXKQY","label":"IBM Spectrum Scale"},"Component":"--","Platform":[{"code":"PF016","label":"Linux"}],"Version":"4.1.1;4.2.0;4.2.1;4.2.2;4.2.3","Edition":"","Line of Business":{"code":"LOB26","label":"Storage"}}]

Document Information

Modified date:
01 August 2018

UID

ssg1S1010878