Skip to content

Commit

Permalink
xen/blkfront: Implement FUA with BLKIF_OP_WRITE_BARRIER
Browse files Browse the repository at this point in the history
The BLKIF_OP_WRITE_BARRIER is a full ordered barrier, so we can use it
to implement FUA as well as a plain FLUSH.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Acked-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Jeremy Fitzhardinge committed Nov 2, 2010
1 parent a945b98 commit be2f837
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions drivers/block/xen-blkfront.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,18 @@ static int blkif_queue_request(struct request *req)

ring_req->operation = rq_data_dir(req) ?
BLKIF_OP_WRITE : BLKIF_OP_READ;
if (req->cmd_flags & REQ_FLUSH)

if (req->cmd_flags & (REQ_FLUSH | REQ_FUA)) {
/*
* Ideally we could just do an unordered
* flush-to-disk, but all we have is a full write
* barrier at the moment. However, a barrier write is
* a superset of FUA, so we can implement it the same
* way. (It's also a FLUSH+FUA, since it is
* guaranteed ordered WRT previous writes.)
*/
ring_req->operation = BLKIF_OP_WRITE_BARRIER;
}

ring_req->nr_segments = blk_rq_map_sg(req->q, req, info->sg);
BUG_ON(ring_req->nr_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST);
Expand Down Expand Up @@ -1065,7 +1075,7 @@ static void blkfront_connect(struct blkfront_info *info)
info->feature_flush = 0;

if (!err && barrier)
info->feature_flush = REQ_FLUSH;
info->feature_flush = REQ_FLUSH | REQ_FUA;

err = xlvbd_alloc_gendisk(sectors, info, binfo, sector_size);
if (err) {
Expand Down

0 comments on commit be2f837

Please sign in to comment.