[Top][All Lists]

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

Re: dd PATCH: add conv=direct

From: Andrew Morton
Subject: Re: dd PATCH: add conv=direct
Date: Wed, 7 Apr 2004 09:42:22 -0700

Bruce Allen <address@hidden> wrote:
> > > On modern Linux, apparently the correct way to bypass the buffer cache
> > > when writing to a block device is to open the block device with
> > > O_DIRECT.  This enables, for example, the user to more easily force a
> > > reallocation of a single sector of an IDE disk with a media error
> > > (without overwriting anything but the 1k "sector pair" containing the
> > > error).  dd(1) is convenient for this purpose, but is lacking a method
> > > to force O_DIRECT.  The enclosed patch adds a "conv=direct" flag to
> > > enable this usage.
> > 
> > This would be rather nice to have.  You'll need to ensure that the data
> > is page-aligned in memory.
> > 
> > While you're there, please add an fsync-before-closing option.
> Andrew, am I right that this is NOT needed for the proposed O_DIRECT
> option, since open(2) says: 
>   "The I/O is synchronous, i.e., at the completion of the read(2) or
>    write(2) system call, data is guaranteed to have been transferred."
> so the write will block until data is physically on the disk.

A conv=fsync option is an irrelevant wishlist item.  If you were to provide
conv=fsync then dd should still fsync the file after performing the
direct-io read or write.

You're correct that an fsync after a direct-io read or write should not
need to perform any file data I/O.  But it will often need to perform file
metadata I/O - file allocation tables, inode, etc.  direct-io only syncs
the file data, not the file metadata.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]