linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Mason <chris.mason@oracle.com>
To: Suparna Bhattacharya <suparna@in.ibm.com>
Cc: linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org
Subject: Re: [PATCH 4 of 8] Add flags to control direct IO helpers
Date: Thu, 8 Feb 2007 07:58:03 -0500	[thread overview]
Message-ID: <20070208125803.GG11967@think.oraclecorp.com> (raw)
In-Reply-To: <20070208040305.GA32642@in.ibm.com>

On Thu, Feb 08, 2007 at 09:33:05AM +0530, Suparna Bhattacharya wrote:
> On Wed, Feb 07, 2007 at 01:05:44PM -0500, Chris Mason wrote:
> > On Wed, Feb 07, 2007 at 10:38:45PM +0530, Suparna Bhattacharya wrote:
> > > > + * The flags parameter is a bitmask of:
> > > > + *
> > > > + * DIO_PLACEHOLDERS (use placeholder pages for locking)
> > > > + * DIO_CREATE (pass create=1 to get_block for filling holes or extending)
> > > 
> > > A little more explanation about why these options are needed, and examples
> > > of when one would specify each of these options would be good.
> > 
> > I'll extend the comments in the patch, but for discussion here:
> > 
> > DIO_PLACEHOLDERS:  placeholders are inserted into the page cache to
> > synchronize the DIO with buffered writes.  From a locking point of view,
> > this is similar to inserting and locking pages in the address space
> > corresponding to the DIO.
> > 
> > placeholders guard against concurrent allocations and truncates during the DIO.
> > You don't need placeholders if truncates and allocations are are
> > impossible (for example, on a block device).
> 
> Likewise placeholders may not be needed if the underlying filesystem
> already takes care of locking to synchronizes DIO vs buffered.

True, although I don't think any FS covers 100% of the cases right now.

> 
> > 
> > DIO_CREATE: placeholders make it possible for filesystems to safely fill
> > holes and extend the file via get_block during the DIO.  If DIO_CREATE
> > is turned on, get_block will be called with create=1, allowing the FS to
> > allocate blocks during the DIO.
> 
> When would one NOT specify DIO_CREATE, and what are the implications ?
> The purpose of having an option of NOT allowing the FS to allocate blocks
> during DIO is one is not very intuitive from the standpoint of the caller.
> (the block device case could be an example, but then create=1 could not do
> any harm or add extra overhead, so why bother ?)

DIO has fallen back to buffered IO for so long that I wanted filesystems
to explicitly choose the create=1 for now.  A good example is my patch
for ext3, where the ext3 get_block routine needed to be changed to start
a transaction instead of finding the current trans in
current->journal_info.  The reiserfs DIO get_block needed to be told not
to expect i_mutex to be held, etc etc.

> 
> Is there still a valid case where we fallback to buffered IO to fill holes
> - to me that seems to be the only situation where create=0 must be enforced.

Right, when create=0 we fall back, otherwise we don't.

> 
> > 
> > DIO_DROP_I_MUTEX: If the write is inside of i_size, i_mutex is dropped
> > during the DIO and taken again before returning.
> 
> Again an example of when one would not specify this (block device and
> XFS ?) would be useful.

If the FS can't fill a hole or extend the file without i_mutex, or if
the caller has already dropped I_MUTEX themselves.  I think this is
only XFS right now, the long term goal is to make placeholders fast
enough for XFS to use.

-chris


  reply	other threads:[~2007-02-08 12:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-07  0:32 [RFC PATCH 0 of 8] O_DIRECT locking rework Chris Mason
2007-02-07  0:32 ` [PATCH 1 of 8] Introduce a place holder page for the pagecache Chris Mason
2007-02-07 17:36   ` Zach Brown
2007-02-07  0:32 ` [PATCH 2 of 8] Change O_DIRECT to use placeholders instead of i_mutex/i_alloc_sem locking Chris Mason
2007-02-07 20:11   ` Zach Brown
2007-02-07 20:22     ` Chris Mason
2007-02-07 20:34       ` Zach Brown
2007-02-07  0:32 ` [PATCH 3 of 8] DIO: don't fall back to buffered writes Chris Mason
2007-02-07  0:32 ` [PATCH 4 of 8] Add flags to control direct IO helpers Chris Mason
2007-02-07 17:08   ` Suparna Bhattacharya
2007-02-07 18:05     ` Chris Mason
2007-02-08  4:03       ` Suparna Bhattacharya
2007-02-08 12:58         ` Chris Mason [this message]
2007-02-07  0:32 ` [PATCH 5 of 8] Make ext3 safe for the new DIO locking rules Chris Mason
2007-02-07  0:32 ` [PATCH 6 of 8] Make reiserfs safe for " Chris Mason
2007-02-07  0:32 ` [PATCH 7 of 8] Adapt XFS to the new blockdev_direct_IO calls Chris Mason
2007-02-07  0:32 ` [PATCH 8 of 8] Avoid too many boundary buffers in DIO Chris Mason
  -- strict thread matches above, loose matches on Subject: below --
2006-12-22  1:45 [PATCH 0 of 8] O_DIRECT locking rework v5 Chris Mason
2006-12-22  1:59 ` [PATCH 4 of 8] Add flags to control direct IO helpers Chris Mason

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=20070208125803.GG11967@think.oraclecorp.com \
    --to=chris.mason@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=suparna@in.ibm.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;
as well as URLs for NNTP newsgroup(s).