public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@suse.de>
To: Badari Pulavarty <pbadari@gmail.com>
Cc: li nux <lnxluv@yahoo.com>, Grzegorz Kulewski <kangur@polcom.net>,
	Erik Mouw <erik@harddisk-recovery.com>,
	colin <colin@realtek.com.tw>, lkml <linux-kernel@vger.kernel.org>
Subject: Re: A problem about DIRECT IO on ext3
Date: Mon, 17 Oct 2005 19:53:27 +0200	[thread overview]
Message-ID: <20051017175326.GX2811@suse.de> (raw)
In-Reply-To: <1129566970.23632.8.camel@localhost.localdomain>

On Mon, Oct 17 2005, Badari Pulavarty wrote:
> On Mon, 2005-10-17 at 11:51 +0200, Jens Axboe wrote:
> > On Mon, Oct 17 2005, li nux wrote:
> > > 
> > > 
> > > --- Jens Axboe <axboe@suse.de> wrote:
> > > 
> > > > On Mon, Oct 17 2005, Grzegorz Kulewski wrote:
> > > > > On Mon, 17 Oct 2005, Jens Axboe wrote:
> > > > > >>how to correct this problem ?
> > > > > >
> > > > > >See your buffer address, it's not aligned. You
> > > > need to align that as
> > > > > >well. This is needed because the hardware will
> > > > dma directly to the user
> > > > > >buffer, and to be on the safe side we require the
> > > > same alignment as the
> > > > > >block layer will normally generate for file
> > > > system io.
> > > > > >
> > > > > >So in short, just align your read buffer to the
> > > > same as your block size
> > > > > >and you will be fine. Example:
> > > > > >
> > > > > >#define BS      (4096)
> > > > > >#define MASK    (BS - 1)
> > > > > >#define ALIGN(buf)      (((unsigned long) (buf) +
> > > > MASK) & ~(MASK))
> > > > > >
> > > > > >char *ptr = malloc(BS + MASK);
> > > > > >char *buf = (char *) ALIGN(ptr);
> > > > > >
> > > > > >read(fd, buf, BS);
> > > > > 
> > > > > Shouldn't one use posix_memalign(3) for that?
> > > > 
> > > > Dunno if one 'should', one 'can' if one wants to. I
> > > > prefer to do it
> > > > manually so I don't have to jump through #define
> > > > hoops to get at it
> > > > (which, btw, still doesn't expose it on this
> > > > machine).
> > > > 
> > > > -- 
> > > > Jens Axboe
> > > 
> > > Thanx a lot Jens :-)
> > > Its working now.
> > > I did not have to make these adjustments on 2.6
> > > Is looks to be having more relaxation.
> > 
> > 2.6 does have the option of checking the hardware dma requirement
> > seperately, but for this path you should run into the same restrictions.
> > Perhaps you just got lucky when testing 2.6?
> 
> 2.6 also has the same restriction. But, if the "filesystem 
> blocksize alignment" (soft block size) fails, we try to see 
> if its aligned with hard sector size (512). If so, we can do the IO.
>  
> 2.4 fails if the offset or buffer is NOT filesystem blocksize
> aligned. Period.

I'm aware of that, however this particular case was about the buffer
alignment (which was 32-bytes in the strace). And that should not work
for 2.6 either.

The block-size alignment is really a separate property of correctness.

> BTW, posix_memalign() or valloc() should be safe.

Certainly.

-- 
Jens Axboe


  reply	other threads:[~2005-10-17 17:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-29 12:15 A problem about DIRECT IO on ext3 colin
2005-08-29 13:29 ` Erik Mouw
2005-08-31  8:07   ` Jens Axboe
2005-08-31 11:12     ` Erik Mouw
2005-08-31 11:15       ` Jens Axboe
2005-10-17  8:52     ` li nux
2005-10-17  8:58       ` li nux
2005-10-17  9:03       ` Jens Axboe
2005-10-17  9:15         ` Grzegorz Kulewski
2005-10-17  9:17           ` Jens Axboe
2005-10-17  9:41             ` li nux
2005-10-17  9:51               ` Jens Axboe
2005-10-17 16:36                 ` Badari Pulavarty
2005-10-17 17:53                   ` Jens Axboe [this message]
  -- strict thread matches above, loose matches on Subject: below --
2005-08-29 13:21 colin

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=20051017175326.GX2811@suse.de \
    --to=axboe@suse.de \
    --cc=colin@realtek.com.tw \
    --cc=erik@harddisk-recovery.com \
    --cc=kangur@polcom.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lnxluv@yahoo.com \
    --cc=pbadari@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox