public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ray Lee" <ray-lk@madrabbit.org>
To: "Timo Sirainen" <tss@iki.fi>
Cc: linux-kernel@vger.kernel.org
Subject: Re: SMP read() stopping at memory page boundaries
Date: Wed, 20 Jun 2007 09:22:20 -0700	[thread overview]
Message-ID: <2c0942db0706200922i15ce44b0xceaed95d002dba33@mail.gmail.com> (raw)
In-Reply-To: <1182354493.3768.80.camel@hurina>

On 6/20/07, Timo Sirainen <tss@iki.fi> wrote:
> On Wed, 2007-06-20 at 17:52 +0300, Timo Sirainen wrote:
> > Sometimes read() returns only 4096 bytes. I'm locking the file, so I
> > don't think this should ever happen, right?

man 2 read

read() is always allowed to return less than you asked for. You need
to go back and ask for the rest. That's why people wrap read() and
write() in loops, and use those wrapped versions instead.

> read() sometimes returns 4096 bytes but with the "1111" already included
> in the data.

Uhm, do you mean 'without the 1111'? 4096 with the 1111 sounds
perfectly fine. (Though 4096 without the 1111 is also perfectly fine.)

> Is there a way to avoid this without locking the file while
> reading? The "1111" tries to act as a kind of a lock.

I think you've misunderstood how read and write work. pread and pwrite
are no different in this respect -- they just allow an atomic
seek+read/write.

Ray

  reply	other threads:[~2007-06-20 16:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-20 14:52 SMP read() stopping at memory page boundaries Timo Sirainen
2007-06-20 15:48 ` Timo Sirainen
2007-06-20 16:22   ` Ray Lee [this message]
2007-06-20 16:57     ` Timo Sirainen
2007-06-20 17:05       ` Alan Cox
2007-06-20 17:48         ` Timo Sirainen
2007-06-20 23:22           ` Jiri Kosina

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=2c0942db0706200922i15ce44b0xceaed95d002dba33@mail.gmail.com \
    --to=ray-lk@madrabbit.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tss@iki.fi \
    /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