mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bruno Diniz de Paula <diniz@cs.rutgers.edu>
To: Chris Wedgwood <cw@f00f.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: O_DIRECT foolish question
Date: 12 Feb 2003 18:02:58 -0500	[thread overview]
Message-ID: <1045090977.21195.87.camel@urca.rutgers.edu> (raw)
In-Reply-To: <20030212224226.GA13129@f00f.org>

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

On Wed, 2003-02-12 at 17:42, Chris Wedgwood wrote:
> On Wed, Feb 12, 2003 at 05:29:52PM -0500, Bruno Diniz de Paula wrote:
> 
> > But I am using multiples of page size in both buffer alignment and
> > buffer size (2nd and 3rd parameters of read).  The issue is that
> > when I try to read files with sizes that are NOT multiples of block
> > size (and therefore also not multiples of page size), the read
> > syscall returns 0, with no errors.
> 
> What filesystem?

ext2.

> 
> Can you send an strace of this occurring?

execve("./testopen", ["./testopen"], [/* 30 vars */]) = 0
uname({sys="Linux", node="urca", ...})  = 0
brk(0)                                  = 0x80497fc
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=57677, ...}) = 0
old_mmap(NULL, 57677, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40012000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0]Z\1\000"...,
1024) = 1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=1102984, ...}) = 0
old_mmap(NULL, 1112740, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) =
0x40021000
mprotect(0x40129000, 31396, PROT_NONE)  = 0
old_mmap(0x40129000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
3, 0x107000) = 0x40129000
old_mmap(0x4012f000, 6820, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4012f000
close(3)                                = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x40131000
munmap(0x40012000, 57677)               = 0
open("/var/tmp/testopen.txt", O_RDONLY|O_DIRECT) = 3
brk(0)                                  = 0x80497fc
brk(0x804c7fc)                          = 0x804c7fc
brk(0)                                  = 0x804c7fc
brk(0x804d000)                          = 0x804d000
read(3, "", 4096)                       = 0
fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 4), ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x40012000
write(1, "0 bytes read from file.\n", 240 bytes read from file.
) = 24
close(3)                                = 0
write(1, "Message: ", 9Message: )                = 9
munmap(0x40012000, 4096)                = 0
exit_group(0)                           = ?

Thanks a lot,

Bruno.

> 
> > So the question remains, am I able to read just files whose size is
> > a multiple of block size?
> 
> No.
> 
> You ideally should be able to read any length file with O_DIRECT.
> Even a 1-byte file.
> 
> 
> 
>   --cw
-- 
Bruno Diniz de Paula <diniz@cs.rutgers.edu>
Rutgers University

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2003-02-12 22:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-12 21:19 Bruno Diniz de Paula
2003-02-12 22:03 ` Andrew Morton
2003-02-12 22:29   ` Bruno Diniz de Paula
2003-02-12 22:42     ` Chris Wedgwood
2003-02-12 23:02       ` Bruno Diniz de Paula [this message]
2003-02-12 23:22         ` Bruno Diniz de Paula
2003-02-13  1:46           ` Randy.Dunlap
2003-02-12 23:24         ` Chris Wedgwood
2003-02-12 23:33           ` Bruno Diniz de Paula
2003-02-12 23:38             ` Chris Wedgwood
2003-02-12 23:49               ` Bruno Diniz de Paula
2003-02-12 23:51                 ` Chris Wedgwood
     [not found]                   ` <1045094589.4767.106.camel@urca.rutgers.edu>
     [not found]                     ` <20030213001302.GA13833@f00f.org>
2003-02-13  0:36                       ` Bruno Diniz de Paula
2003-02-13  5:12                         ` Andrew Morton
2003-02-13 15:22                           ` Bruno Diniz de Paula
2003-02-13 17:31                             ` Andrew Morton
2003-02-13 22:45                               ` Bruno Diniz de Paula
2003-02-12 23:33           ` Chris Wedgwood
2003-02-12 22:07 ` Chris Wedgwood

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=1045090977.21195.87.camel@urca.rutgers.edu \
    --to=diniz@cs.rutgers.edu \
    --cc=cw@f00f.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®