Patch for 512-byte alignment support for direct I/O

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Sage,

My direct I/O test still failed (and even crashed the whole system)
when reading a file on ceph. Attached is my simple test program.
I tried to fix it with the following patch:
https://github.com/tcloud/ceph-client-standalone/commit/3e9c611b43a9e03e0a80582b2a3d81e5c8d5ff79
Would you help to review it? :)

Thanks,
Henry
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>

int main(int argc, char *argv[]) {
	int i;
	int n = 0;
	void *buf = 0;
	int fd = open(argv[1], O_RDONLY | O_DIRECT);
	if (fd < 0) {
		printf("file open error %d\n", errno);
		return -1;
	}

	n = lseek(fd, 0, SEEK_END);
	printf("seek %d\n", n);
	n = lseek(fd, 0, SEEK_CUR);
	printf("seek %d\n", n);
	n = lseek(fd, 6656, SEEK_SET);
	printf("seek %d\n", n);

	n = posix_memalign(&buf, 512, 8192);
	printf("posix_memalign ret %d buf %p\n", n, buf);
	memset(buf, 0, n);

	n = read(fd, buf, 8192);
	printf("read %d bytes (err %d)\n", n, errno);
	char* buf1 = (char*)buf;
	for (i = 0; i < n; ++i)
		printf("%c", buf1[i]);
	printf("\n");
	free(buf);
	close(fd);
	return 0;
}

[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux