Is O_DIRECT supported on Lustre for write()? I got an EINVAL error when I write to a file opened with mode O_DIRECT. The write amount is the same as the file system block size, which is 4MB on the machine I ran. According to Lustre manual, this should be fine as long as the I/O is aligned with 512B. Read is fine, though. Attached is the the code. I compiled it with gcc. Wei-keng -------------- next part -------------- #include <stdio.h> #include <stdlib.h> #define __USE_GNU #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> /* __USE_GNU to use O_DIRECT defined in bits/fcntl.h */ #include <unistd.h> #include <errno.h> extern int errno; /*---< main() >-------------------------------------------------------------*/ int main(int argc, char **argv) { int i, err, fd, block_size; mode_t io_mode; char *buf, *filename; long long offset = 0; struct stat statBuf; filename = "/cfs/projects/widescratch/users/wkliao/testfile.dat"; /* get system block size */ stat(filename, &statBuf); block_size = statBuf.st_blksize; printf("Writing to file: %s block_size=%d\n",filename,block_size); buf = (char*) malloc(block_size); for (i=0; i<block_size; i++) buf[i] = ''z''; io_mode = O_CREAT | O_WRONLY | O_DIRECT; fd = open(filename, io_mode, 0600); if (fd == -1) printf("Error when open file %s\n", filename); err = write(fd, buf, block_size); if (err == -1) printf("WRITE Error: offset=%lld len=%d - errno=%d(EINVAL=%d)\n",offset,block_size,errno,EINVAL); else printf("WRITE Success: offset=%lld len=%d err=%d\n",offset,block_size,err); else printf("WRITE Success: offset=%lld len=%d err=%d\n",offset,block_size,err); close(fd); free(buf); return 0; }