public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: Chris Mason <chris.mason@oracle.com>
Cc: Hisashi Hifumi <hifumi.hisashi@oss.ntt.co.jp>,
	linux-btrfs@vger.kernel.org
Subject: Re: [RFC] [PATCH] Btrfs: improve fsync/osync write performance
Date: Wed, 1 Apr 2009 19:01:49 +0200	[thread overview]
Message-ID: <20090401170149.GL5178@kernel.dk> (raw)
In-Reply-To: <1238599038.18549.39.camel@think.oraclecorp.com>

On Wed, Apr 01 2009, Chris Mason wrote:
> On Tue, 2009-03-31 at 14:18 +0900, Hisashi Hifumi wrote:
> > Hi Chris.
> > 
> > I noticed performance of fsync() and write() with O_SYNC flag on Btrfs is
> > very slow as compared to ext3/4. I used blktrace to try to investigate the 
> > cause of this. One of cause is that unplug is done by kblockd even if the I/O is 
> > issued through fsync() or write() with O_SYNC flag. kblockd's unplug timeout
> > is 3msec, so unplug via blockd can decrease I/O response. To increase 
> > fsync/osync write performance, speeding up unplug should be done here.
> > 
> 
> I realized today that all of the async thread handling btrfs does for
> writes gives us plenty of time to queue up IO for the block device.  If
> that's true, we can just unplug the block device in async helper thread
> and get pretty good coverage for the problem you're describing.
> 
> Could you please try the patch below and see if it performs well?  I did
> some O_DIRECT testing on a 5 drive array, and tput jumped from 386MB/s
> to 450MB/s for large writes.
> 
> Thanks again for digging through this problem.
> 
> -chris
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index dd06e18..bf377ab 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -146,7 +146,7 @@ static noinline int run_scheduled_bios(struct btrfs_device *device)
>  	unsigned long num_run = 0;
>  	unsigned long limit;
>  
> -	bdi = device->bdev->bd_inode->i_mapping->backing_dev_info;
> +	bdi = blk_get_backing_dev_info(device->bdev);
>  	fs_info = device->dev_root->fs_info;
>  	limit = btrfs_async_submit_limit(fs_info);
>  	limit = limit * 2 / 3;
> @@ -231,6 +231,19 @@ loop_lock:
>  	if (device->pending_bios)
>  		goto loop_lock;
>  	spin_unlock(&device->io_lock);
> +
> +	/*
> +	 * IO has already been through a long path to get here.  Checksumming,
> +	 * async helper threads, perhaps compression.  We've done a pretty
> +	 * good job of collecting a batch of IO and should just unplug
> +	 * the device right away.
> +	 *
> +	 * This will help anyone who is waiting on the IO, they might have
> +	 * already unplugged, but managed to do so before the bio they
> +	 * cared about found its way down here.
> +	 */
> +	if (bdi->unplug_io_fn)
> +		bdi->unplug_io_fn(bdi, NULL);

blk_run_backing_dev(bdi, NULL);

:-)

-- 
Jens Axboe


  reply	other threads:[~2009-04-01 17:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-31  5:18 [RFC] [PATCH] Btrfs: improve fsync/osync write performance Hisashi Hifumi
2009-03-31 11:27 ` Chris Mason
2009-04-02  2:02   ` Hisashi Hifumi
2009-04-01 15:17 ` Chris Mason
2009-04-01 17:01   ` Jens Axboe [this message]
2009-04-02  6:25   ` Hisashi Hifumi
2009-04-02 11:25     ` 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=20090401170149.GL5178@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=chris.mason@oracle.com \
    --cc=hifumi.hisashi@oss.ntt.co.jp \
    --cc=linux-btrfs@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox