Hi Vicente,
> ... related to logical disk sector size, no matter if ...
Not entirely true - on Linux you can create a loopback device on top of the 4k device, the loop device will have 512 byte block and the direct I/O will "work". Performance will be awful, of course.
I am not sure if different (smaller) block size can be forced for the "md" device and/or the file system when the physical storage has 4k logical block, and even if yes - what would be the performance impact. (with the loopback - impact is considerable)
> ... Is this related to some hardcoded value inside Informix ...
It's a bit more complex than that. On (x86/AMD) Linux - the Informix base page size is 2k, so, in theory, the minimum I/O could be 2k aligned, however - I think that your suspicion is correct and any logical block size over 1k (1024 bytes) will result in Informix turning direct I/O off. Where 1k is the hardcoded value.
On (x86/AMD) Linux it would be somewhat difficult to enable direct I/O on 4k devices for the rootdbs and logs because the base page size (minimum I/O) will be less that that. However, in my opinion, it should be possible to enable direct I/O for chinks with custom page sizes which are equal or multiples of the device page size.
Until recently it was not a (big) problem - since most "advanced format devices" (and SSDs) provided 512 byte block emulation, for some SSDs you can actually control the (reported) logical block size with vendor tools.
I think having support case about this issue may prompt development to take another look at the direct I/O on Linux.
------------------------------
Vladimir Kolobrodov
------------------------------
Original Message:
Sent: Thu March 23, 2023 10:17 AM
From: Vicente Salvador Cubedo
Subject: DIRECT I/O (KAIO) Disabled in RHEL 9
Hi Vladimir,
I've made al kind of testing and I identified the DIRECT I/O disabled by Informix in related to logical disk sector size, no matter if this disks are joined in a RAID or accessed directly or the filesystem used: ext2, ext3 or xfs
If the hard disk has a logical sector size of 4096 bytes Informix disables Direct I/O and if the hard disk has a logical sector size of 512 bytes, Direct I/O works.
So next question is, Is this related to some hardcoded value inside Informix only working with 512 bytes blocs. Modern Linux allows to use Direct I/O with other sector sizes. Software should align to the size of the disk sector, but it is possible.
https://access.redhat.com/articles/3911611
In resume:
O_DIRECT requires that I/O occur in multiples of 512 bytes and from memory aligned on a 512-byte boundary because O_DIRECT performs direct memory access (DMA) straight to the backing store, bypassing any intermediate buffers. Performing unaligned transfers would require "fixing up" the I/O by explicitly aligning the user-space buffer and zeroing out the slack (the space between the end of the buffer and the next 512 byte multiple), obviating the benefits of O_DIRECT.
Here's another way to look at it: The "beauty" of O_DIRECT (such as it is) is that it cuts out the VM from the I/O process. No copying from user to kernel-space, no page cache, no pages period. But this means all the little things that the kernel handles for you-alignment being the biggest-you, the user, now need to handle. The underlying backing store expects everything in sectors, so you need to talk in sectors, too.
That is why the magic number isn't always 512 bytes. It is the sector size of the underlying block device. This number is almost always 512 bytes for a standard hard drive, but it can vary. For example, ISO 9660, the standard format of CD-ROMs, sports 2048 byte sectors. You can use the BLKSSZGET ioctl to obtain a backing store's sector size. Portable code should use the value returned from this ioctl and not hard-code 512 bytes.
So, I think there is maybe an issue in Informix just using a hardcoded 512 value and disabling Direct I/O if sector size is not 512 instead of reading the logical sector size and using it.
Regards,
------------------------------
Vicente Salvador Cubedo
------------------------------
Original Message:
Sent: Wed March 22, 2023 04:41 PM
From: Vladimir Kolobrodov
Subject: DIRECT I/O (KAIO) Disabled in RHEL 9
The direct I/O on Linux requires alignment on the block boundary, so for the devices where block size exceeds 512 (or, maybe, 1024) bytes (for example advanced format devices with no 512 byte emulation) Informix will disable direct I/O.
Since it's an "md" device - I wonder if it's possible to recreate it with 1k or 512 byte block ?
You can check block size for devices by something like:
lsblk -o NAME,PHY-SEC,LOG-SEC
and/or
blockdev --getss /dev/xxx
blockdev --getpbsz /dev/xxx
blockdev --getbsz /dev/xxx
I think the "important" one is the logical block (sector) size (getss), but I may be mistaken.
------------------------------
Vladimir Kolobrodov
Original Message:
Sent: Wed March 22, 2023 01:50 PM
From: Vicente Salvador Cubedo
Subject: DIRECT I/O (KAIO) Disabled in RHEL 9
Trying to create root dbx chunk directly on a device, shows a better understanding message:
18:41:19 IBM Informix Dynamic Server Version 14.10.FC10AEE
18:41:19 Performance Advisory: Currently IBM Informix Dynamic Server cannot
support KAIO on the device containing
'/dev/md0'
Its block size (4096) is larger than 1024.
18:41:19 Results: Direct and concurrent I/O are disabled for this chunk.
18:41:19 Action: Standard AIO (possibly buffered) will be used for I/O
to this chunk.
So, it seams than informis only allows to use DIRECT/IO y block size is lower than 1024 bytes. My disks have sector size of 4096 bytes. Is there a workaround?
------------------------------
Vicente Salvador Cubedo