linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Chinner <dgc@sgi.com>
To: Chris Mason <chris.mason@oracle.com>
Cc: linux-fsdevel@vger.kernel.org, akpm@osdl.org,
	zach.brown@oracle.com, Suparna Bhattacharya <suparna@in.ibm.com>
Subject: Re: [PATCH 4 of 7] Turn the DIO lock_type parameter into a flags field
Date: Thu, 2 Nov 2006 09:58:58 +1100	[thread overview]
Message-ID: <20061101225858.GO8394166@melbourne.sgi.com> (raw)
In-Reply-To: <f84d3216430d2b1aa58d.1162397286@opti.oraclecorp.com>

On Wed, Nov 01, 2006 at 11:08:06AM -0400, Chris Mason wrote:
> This creates a number of flags so that filesystems can control
> blockdev_direct_IO.  It is based on code from Russell Cettelan.
> 
> The new flags are:
> DIO_CREATE -- always pass create=1 to get_block on writes.  This allows
> 	      DIO to fill holes in the file.
> DIO_PLACEHOLDERS -- use placeholder pages to provide locking against buffered
> 	            io and truncates.
> DIO_EXTEND -- use truncate to grow the file instead of falling back to
> 	      buffered io.
> DIO_DROP_I_MUTEX -- drop i_mutex before starting the IO on writes
> 
> Signed-off-by: Chris Mason <chris.mason@oracle.com>

....
> @@ -1193,28 +1190,17 @@ direct_io_worker(int rw, struct kiocb *i
>  
>  /*
>   * This is a library function for use by filesystem drivers.
> - * The locking rules are governed by the dio_lock_type parameter.
> - *
> - * DIO_NO_LOCKING (no locking, for raw block device access)
> - * For writes, i_mutex is not held on entry; it is never taken.
> - *
> - * DIO_LOCKING (simple locking for regular files)
> - * For writes we are called under i_mutex and return with i_mutex held, even
> - * though it is internally dropped.
> - *
> - * DIO_OWN_LOCKING (filesystem provides synchronisation and handling of
> - *	uninitialised data, allowing parallel direct readers and writers)
> - * For writes we are called without i_mutex, return without it, never touch it.
> - * For reads we are called under i_mutex and return with i_mutex held, even
> - * though it may be internally dropped.
> - *
> - * Additional i_alloc_sem locking requirements described inline below.
> + * 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)
> + * DIO_DROP_I_MUTEX (drop inode->i_mutex during writes)

DIO_EXTEND?

> @@ -1271,9 +1256,14 @@ __blockdev_direct_IO(int rw, struct kioc
>  	 * For regular files using DIO_OWN_LOCKING,
>  	 *	neither readers nor writers take any locks here
>  	 */
> -	dio->lock_type = dio_lock_type;
> -
> -	if (dio->lock_type == DIO_NO_LOCKING && end > offset) {
> +	dio->flags = flags;
> +
> +	/*
> +	 * the placeholder code does filemap_write_and_wait, so if we
> +	 * aren't using placeholders we have to do it here
> +	 */
> +	if (!(dio->flags & DIO_PLACEHOLDERS) && end > offset) {
> +		struct address_space *mapping = iocb->ki_filp->f_mapping;
>  		retval = filemap_write_and_wait_range(mapping, offset, end - 1);
>  		if (retval)
>  			goto out;

So that means XFS will now do three cache flushes on write (one in
xfs_write(), one in generic_file_direct_IO() and yet another here....

Given the unconditional flush in generic_file_direct_IO(), is this
flush here needed at all?


> @@ -1310,7 +1301,7 @@ __blockdev_direct_IO(int rw, struct kioc
>  			if (retval)
>  				goto out;
>  		}
> -		if (is_sync_kiocb(iocb)) {
> +		if ((dio->flags & DIO_DROP_I_MUTEX) && is_sync_kiocb(iocb)) {
>  			dio->reacquire_i_mutex = 1;
>  			mutex_unlock(&inode->i_mutex);
>  		}

Hmm - do we need dio->reacquire_i_mutex? We could use the DIO_DROP_I_MUTEX
to determine if we need to reacquire the mutex (i.e. we clear the
flag if we don't need to reacquire the mutex.).

Cheers,

Dave.
-- 
Dave Chinner
Principal Engineer
SGI Australian Software Group

  reply	other threads:[~2006-11-01 22:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-01 15:08 [PATCH 0 of 7] O_DIRECT locking rework Chris Mason
2006-11-01 15:08 ` [PATCH 1 of 7] Introduce a place holder page for the pagecache Chris Mason
2006-11-01 15:08 ` [PATCH 2 of 7] Change O_DIRECT to use placeholders instead of i_mutex/i_alloc_sem locking Chris Mason
2006-11-01 22:44   ` David Chinner
2006-11-01 15:08 ` [PATCH 3 of 7] DIO: don't fall back to buffered writes Chris Mason
2006-11-01 15:08 ` [PATCH 4 of 7] Turn the DIO lock_type parameter into a flags field Chris Mason
2006-11-01 22:58   ` David Chinner [this message]
2006-11-02  1:02     ` Chris Mason
2006-11-02  2:16       ` David Chinner
2006-11-08 18:48     ` Chris Mason
2006-11-01 15:08 ` [PATCH 5 of 7] Make ext3 safe for the new DIO locking rules Chris Mason
2006-11-01 15:08 ` [PATCH 6 of 7] Make reiserfs safe for " Chris Mason
2006-11-01 15:08 ` [PATCH 7 of 7] Adapt XFS to the new blockdev_direct_IO calls Chris Mason
2006-11-01 23:00   ` David Chinner

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=20061101225858.GO8394166@melbourne.sgi.com \
    --to=dgc@sgi.com \
    --cc=akpm@osdl.org \
    --cc=chris.mason@oracle.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=suparna@in.ibm.com \
    --cc=zach.brown@oracle.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).