Skip to content

Commit b6ebaa8

Browse files
rosslagerwalljgross1
authored andcommitted
xen/blkfront: Only check REQ_FUA for writes
The existing code silently converts read operations with the REQ_FUA bit set into write-barrier operations. This results in data loss as the backend scribbles zeroes over the data instead of returning it. While the REQ_FUA bit doesn't make sense on a read operation, at least one well-known out-of-tree kernel module does set it and since it results in data loss, let's be safe here and only look at REQ_FUA for writes. Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com> Acked-by: Juergen Gross <jgross@suse.com> Link: https://lore.kernel.org/r/20230426164005.2213139-1-ross.lagerwall@citrix.com Signed-off-by: Juergen Gross <jgross@suse.com>
1 parent cbfac77 commit b6ebaa8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/block/xen-blkfront.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,8 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
780780
ring_req->u.rw.handle = info->handle;
781781
ring_req->operation = rq_data_dir(req) ?
782782
BLKIF_OP_WRITE : BLKIF_OP_READ;
783-
if (req_op(req) == REQ_OP_FLUSH || req->cmd_flags & REQ_FUA) {
783+
if (req_op(req) == REQ_OP_FLUSH ||
784+
(req_op(req) == REQ_OP_WRITE && (req->cmd_flags & REQ_FUA))) {
784785
/*
785786
* Ideally we can do an unordered flush-to-disk.
786787
* In case the backend onlysupports barriers, use that.

0 commit comments

Comments
 (0)