All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-fsdevel@vger.kernel.org, Jan Kara <jack@suse.cz>,
	Jeff Moyer <jmoyer@redhat.com>,
	"Darrick J. Wong" <darrick.wong@oracle.com>
Subject: Re: [PATCH 1/2] [PATCH 1/2] direct-io: implement generic deferred AIO completions
Date: Thu, 6 Dec 2012 20:05:37 +0100	[thread overview]
Message-ID: <20121206190537.GD21029@quack.suse.cz> (raw)
In-Reply-To: <20121123075916.182694435@bombadil.infradead.org>

On Fri 23-11-12 02:55:03, Christoph Hellwig wrote:
> Add support to the core direct-io code to defer AIO completions to user
> context using a workqueue.  This replaces opencoded and less efficient
> code in XFS and ext4 and will be needed to properly support O_(D)SYNC
> for AIO.
> 
> The communication between the filesystem and the direct I/O code requires
> a new buffer head flag, which is a bit ugly but not avoidable until the
> direct I/O code stops abusing the buffer_head structure for communicating
> with the filesystems.
> 
> Currently this creates a per-superblock unbnound workqueue for these
> completions, which is taken from an earlier patch by Jan Kara.  I'm
> not really convince about this use and would prefer a "normal" global
> workqueue with a high concurrently limit, but this needs further discussion.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
  I like this, but this patch already breaks ext4, doesn't it?

> Index: linux-2.6/fs/ext4/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/ext4/inode.c	2012-11-06 13:33:43.483326794 +0100
> +++ linux-2.6/fs/ext4/inode.c	2012-11-21 21:19:35.227136042 +0100
> @@ -2876,15 +2876,13 @@ static int ext4_get_block_write_nolock(s
>  }
>  
>  static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset,
> -			    ssize_t size, void *private, int ret,
> -			    bool is_async)
> +			    ssize_t size, void *private)
>  {
> -	struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode;
>          ext4_io_end_t *io_end = iocb->private;
>  
>  	/* if not async direct IO or dio with 0 bytes write, just return */
>  	if (!io_end || !size)
> -		goto out;
> +		return;
>  
>  	ext_debug("ext4_end_io_dio(): io_end 0x%p "
>  		  "for inode %lu, iocb 0x%p, offset %llu, size %zd\n",
> @@ -2896,19 +2894,11 @@ static void ext4_end_io_dio(struct kiocb
>  	/* if not aio dio with unwritten extents, just free io and return */
>  	if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) {
>  		ext4_free_io_end(io_end);
> -out:
> -		if (is_async)
> -			aio_complete(iocb, ret, 0);
> -		inode_dio_done(inode);
>  		return;
>  	}
>  
>  	io_end->offset = offset;
>  	io_end->size = size;
> -	if (is_async) {
> -		io_end->iocb = iocb;
> -		io_end->result = ret;
> -	}
>  
>  	ext4_add_complete_io(io_end);
  ^^^ Here ext4 offloads IO completion to a worker thread. So you now
complete AIO / DIO before ext4_end_io() runs which is a bug (ext4_end_io()
is responsible for example for calling end_page_writeback()). I'll modify
these patches to work for ext4 tomorrow I hope...

								Honza

-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

  parent reply	other threads:[~2012-12-06 19:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-23  7:55 [PATCH 0/2] handle O_(D)SYNC for AIO Christoph Hellwig
2012-11-23  7:55 ` [PATCH 1/2] [PATCH 1/2] direct-io: implement generic deferred AIO completions Christoph Hellwig
2012-11-27 16:17   ` Jeff Moyer
2012-12-06 19:05   ` Jan Kara [this message]
2012-12-08 12:02     ` Christoph Hellwig
2012-12-20 11:15       ` Jan Kara
2012-11-23  7:55 ` [PATCH 2/2] [PATCH 2/2] direct-io: handle handle O_(D)SYNC AIO Christoph Hellwig
2012-11-27 16:19   ` Jeff Moyer
2012-11-28  0:26     ` Darrick J. Wong
2012-11-28  0:30       ` Christoph Hellwig
2012-11-28  8:02         ` [RFC PATCH] ext4: Convert unwritten extents during end_io processing Darrick J. Wong
2012-11-28 14:34           ` Christoph Hellwig
2012-11-29 19:47             ` Darrick J. Wong
2012-12-05 13:08     ` [PATCH 2/2] [PATCH 2/2] direct-io: handle handle O_(D)SYNC AIO Jan Kara

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=20121206190537.GD21029@quack.suse.cz \
    --to=jack@suse.cz \
    --cc=darrick.wong@oracle.com \
    --cc=hch@infradead.org \
    --cc=jmoyer@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.