Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63afd766 authored by Ross Lagerwall's avatar Ross Lagerwall Committed by Greg Kroah-Hartman
Browse files

xen/blkfront: Only check REQ_FUA for writes



[ Upstream commit b6ebaa8100090092aa602530d7e8316816d0c98d ]

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: default avatarRoss Lagerwall <ross.lagerwall@citrix.com>
Acked-by: default avatarJuergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20230426164005.2213139-1-ross.lagerwall@citrix.com


Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 27447dad
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -779,7 +779,8 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
		ring_req->u.rw.handle = info->handle;
		ring_req->operation = rq_data_dir(req) ?
			BLKIF_OP_WRITE : BLKIF_OP_READ;
		if (req_op(req) == REQ_OP_FLUSH || req->cmd_flags & REQ_FUA) {
		if (req_op(req) == REQ_OP_FLUSH ||
		    (req_op(req) == REQ_OP_WRITE && (req->cmd_flags & REQ_FUA))) {
			/*
			 * Ideally we can do an unordered flush-to-disk.
			 * In case the backend onlysupports barriers, use that.