public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: Neil Brown <neilb@suse.de>
Cc: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>,
	Linux Kernel Development <linux-kernel@vger.kernel.org>,
	Jens Axboe <jens.axboe@oracle.com>
Subject: Re: Block devices and barriers
Date: Tue, 29 May 2007 14:34:25 +0200	[thread overview]
Message-ID: <465C1DD1.8060201@gmail.com> (raw)
In-Reply-To: <18011.43887.825594.407340@notabene.brown>

Hello,

Neil Brown wrote:
>> but I can't find a way to actually trigger the calling of ps3disk_issue_flush()
>> and ps3disk_prepare_flush().
>>
>>  1. My prepare_flush_fn() routine should be called from queue_flush(), which is
>>     in turn called by start_ordered().
>>     start_ordered() is called by blk_do_ordered(), but only if there's no
>>     barrier (REQ_HARDBARRIER is not set).
>>     Apart from drivers/block/pktcdvd.c and init_request_from_bio()
>>     (BIO_RW_BARRIER is set by drivers/md/md.c only?), the only other way
>>     REQ_HARDBARRIER can be set is in queue_flush(), which is not possible.
> 
> BIO_RW_BARRIER is set by various filesystems when mounted with
>   -o barrier 
> or
>   -o barrier=1 (ext3)
> 
> See calls to set_buffer_ordered in fs/jbd/commit.c

You driver first needs to call blk_queue_ordered() to set ordered mode
(probably QUEUE_ORDERED_DRAIN_FLUSH) and the filesystem needs to be
mounted with barrier enabled as Neil explained.  Then, the FS will issue
barriers and the block layer will interpret them as draining + cache flush.

>>   2. My issue_flush_fn() should be called from blkdev_issue_flush() (ignoring
>>      drivers/md). But blkdev_issue_flush() is called by ReiserFS and XFS only.
> 
> Yeh, it isn't widely used at the moment.

I thought about re-implementing it in terms of barrier callbacks but
wasn't sure whether it would be better than completely removing
blkdev_issue_flush() && a bit lazy. :-)

I'll look into it.

>> I read the Block Device chapter in Linux Device Drivers 3rd edition, which says
>> to check blk_barrier_rq(), but the barrier part seems to be obsolete, as we now
>> have the prepare_flush_fn parameter of blk_queue_ordered().
>>
>> Am I missing something? Should I care about barriers?
> 
> Yes, you should care about barriers, though it is true that there is
> some confusion around them and it might be difficult.

Yeap, basically a block driver needs two callbacks - issue_flush and
prepare_flush plus a call to blk_queue_ordered().

>> BTW, Documentation/block/barrier.txt seems to be out-of-date. Patch to update
>> it is below.
> 
> You might like to post this directly to
>   Tejun Heo <htejun@gmail.com>

Received, acked && forwarded to Jens.

Thanks.

-- 
tejun

      reply	other threads:[~2007-05-29 12:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-21 13:16 Block devices and barriers Geert Uytterhoeven
2007-05-29  4:26 ` Neil Brown
2007-05-29 12:34   ` Tejun Heo [this message]

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=465C1DD1.8060201@gmail.com \
    --to=htejun@gmail.com \
    --cc=Geert.Uytterhoeven@sonycom.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@suse.de \
    /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