Description of problem: Setting the inherit_directio flag on a gfs file results in the following error: cp: writing âfilenameâ: Invalid argument The file will be created but will be of zero size. Note that this behavior is exhibited locally on a single node â there is no need to export it and mount on another system to see the behavior. Version-Release number of selected component (if applicable): GFS-kernel-smp-2.6.9-42.1.x86_64.rpm How reproducible: Everytime Steps to Reproduce: 1. Set inherit_directio flag on root GFS file system 2. Write to a GFS file 3. Actual results: writing âfilenameâ: Invalid argument Expected results: no errors Additional info:
interesting. seems it's a problem whenever buffered->dio or dio -> buffered echo hi > test # produces 0 file
Although this is still a bug, we have learned that we should be using jdata instead of directio for what we want, so this is not effecting us currently.
With O_DIRECT, the buffer (memory) being read from or written to must be 512-byte aligned. It is more of a programming interface and I don't think commands such as "cp" is prepared to handle issues like this.
I'm checking into how "cp" is implemented.
From coreutils-5.2.1, "cp" does the regular file read/write as: buf = alloca (buf_size + sizeof (int)); n_read = read (source_desc, buf, buf_size); full_write (dest_desc, buf, n) ... The "buf" is not necessarily 512-byte aligned. As the result, the kernel __blockdev_direct_IO() call will return -EINVAL if alignment checking fails.
I *don't* consider this is a bug but a restriction (or more specifically, a mis-understanding) of the inherit_directio flag. On the other hand, we can certainly put some words into documentation about this if requested. Again, Direct IO is a programming interface - mixing its usage with other Linux commands and utilities are not recommended.