Skip to contentSkip to conversation

open.2: Update note about the alignment of the user buffer and the file offset for O_DIRECT flag

PATCH In review Peter Schiffer 2 participants 2 messages Apr 22, 2014 1 message not in the archive Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 open.2: Update note about the alignment of the user buffer and the file offset for O_DIRECT flag

Hello Michael,

the sentence in open(2) man page in notes for O_DIRECT flag:
"Under Linux 2.6, alignment to 512-byte boundaries suffices."

is not universally correct. The alignment is a property of the storage, for example, 4k-sector drives with no 512 byte sector emulation will be unable to perform 512-byte direct I/O.

The patch clarifies this sentence.

Thanks,

peter

man2/open.2 +10 -1
index 389945f..c80686d 100644
@@ -1322,7 +1322,16 @@ operation in
 Under Linux 2.4, transfer sizes, and the alignment of the user buffer
 and the file offset must all be multiples of the logical block size
 of the filesystem.
-Under Linux 2.6, alignment to 512-byte boundaries suffices.
+Under Linux 2.6 and newer, alignment to the logical block size of the
+underlying storage (typically 512 bytes) suffices.
+Logical block size can be determined with
+.BR ioctl (2)
+.B BLKSSZGET
+system call or
+.BR blockdev (8)
+command with
+.B --getss
+parameter.
 .LP
 .B O_DIRECT
 I/Os should never be run concurrently with the

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 10 lines · Peter Schiffer

Hello Michael,

the sentence in open(2) man page in notes for O_DIRECT flag:
"Under Linux 2.6, alignment to 512-byte boundaries suffices."

is not universally correct. The alignment is a property of the storage, for example, 4k-sector drives with no 512 byte sector emulation will be unable to perform 512-byte direct I/O.

The patch clarifies this sentence.

Thanks very much for that patch, Peter. It clears
up my (mis)understanding! Applied.

Cheers,

Michael

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html