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 <[EMAIL PROTECTED]> Received, acked && forwarded to Jens. Thanks. -- tejun - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/