All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vladimir V. Saveliev" <vs@namesys.com>
To: Gorazd Golob <gorazdg@noviforum.si>
Cc: reiserfs-list@namesys.com
Subject: Re: reiser3 and O_DIRECT read
Date: Tue, 11 Oct 2005 11:30:35 +0400	[thread overview]
Message-ID: <434B6A1B.4030702@namesys.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0510110834110.3955@dacun.noviforum.si>

[-- Attachment #1: Type: text/plain, Size: 443 bytes --]

Hello

Gorazd Golob wrote:
> 
> ;(
> 
> works ok if file is bigger than about 4000 bytes. Otherwise read failed.
> 
Yes, using O_DIRECT you should care about alignment to boundary of 512 bytes for
address of buffer you read to, size of that buffer and offset in a file to read
from.

Please try this version of test program and let us know how to make it to behave
differently for file in reiserfs and ext2.
What is version of kernel you use?

[-- Attachment #2: test-direct-io.c --]
[-- Type: text/x-c, Size: 686 bytes --]

#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <unistd.h>
#include <malloc.h>
#include <stdlib.h>
#include <fcntl.h>

#define O_DIRECT   040000

int main(int argc, char **argv)
{
	int fd;
	ssize_t rd;
	char *buf;
	size_t size;

	if (argc != 3) {
		printf("%s filename nr\n", argv[0]);
		return 0;
	}
	fd = open(argv[1], O_RDONLY | O_DIRECT);
	if (fd == -1) {
		perror("open failed");
		return 0;
	}
	size = atoi(argv[2]);

	if (posix_memalign((void **)&buf, 512, size)) {
		perror("malloc failed");
                return 0;
	}
	rd = read(fd, buf, size);
	if (rd != size) {
                perror("read failed");
                return 0;
	}
	free(buf);
	close(fd);
	return 0;
}

  reply	other threads:[~2005-10-11  7:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-07 10:13 reiser3 and O_DIRECT read Gorazd Golob
2005-10-07 13:29 ` Vladimir V. Saveliev
2005-10-10 10:41   ` Gorazd Golob
2005-10-10 12:22     ` Vladimir V. Saveliev
2005-10-10 12:30       ` Gorazd Golob
2005-10-10 13:08         ` Vladimir V. Saveliev
2005-10-10 13:22           ` Gorazd Golob
2005-10-10 15:40           ` Gorazd Golob
2005-10-11  6:10             ` Vladimir V. Saveliev
2005-10-11  6:36               ` Gorazd Golob
2005-10-11  7:30                 ` Vladimir V. Saveliev [this message]
2005-10-11  7:56                   ` Gorazd Golob
2005-10-11 12:06                     ` Vladimir V. Saveliev
2005-10-11 16:07                       ` Hans Reiser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=434B6A1B.4030702@namesys.com \
    --to=vs@namesys.com \
    --cc=gorazdg@noviforum.si \
    --cc=reiserfs-list@namesys.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.