Skip to content

Commit

Permalink
CP-46757: advertise feature-flush-cache
Browse files Browse the repository at this point in the history
Windows guests do not request BLKIF_OP_WRITE_BARRIER and only support
BLKIF_OP_FLUSH_DISKCACHE, so advertise and support that to allow for
explicit cache and data integrity management.

Signed-off-by: Mark Syms <mark.syms@citrix.com>
  • Loading branch information
MarkSymsCtx committed Nov 23, 2023
1 parent 1179cd6 commit 73145e0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
10 changes: 6 additions & 4 deletions drivers/td-ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ __xenio_blkif_get_requests(struct td_xenblkif * const blkif,

xenio_blkif_get_request(blkif, dst, rc);

if (unlikely(dst->operation == BLKIF_OP_WRITE_BARRIER))
if (unlikely(dst->operation == BLKIF_OP_WRITE_BARRIER ||
dst->operation == BLKIF_OP_FLUSH_DISKCACHE))
barrier = true;
}

Expand Down Expand Up @@ -278,7 +279,8 @@ xenio_blkif_get_requests(struct td_xenblkif * const blkif,

n += __xenio_blkif_get_requests(blkif, reqs + n, count - n);

if (unlikely(n && reqs[(n - 1)]->operation == BLKIF_OP_WRITE_BARRIER))
if (unlikely(n && (reqs[(n - 1)]->operation == BLKIF_OP_WRITE_BARRIER ||
reqs[(n - 1)]->operation == BLKIF_OP_FLUSH_DISKCACHE)))
break;

} while (1);
Expand Down Expand Up @@ -327,8 +329,8 @@ tapdisk_xenio_ctx_process_ring(struct td_xenblkif *blkif,
limit -= n_reqs;
final = 1;

if (unlikely(reqs[(n_reqs - 1)]->operation ==
BLKIF_OP_WRITE_BARRIER)) {
if (unlikely(reqs[(n_reqs - 1)]->operation == BLKIF_OP_WRITE_BARRIER ||
reqs[(n_reqs - 1)]->operation == BLKIF_OP_FLUSH_DISKCACHE)) {
ASSERT(!blkif->barrier.msg);
blkif->barrier.msg = reqs[(n_reqs - 1)];
blkif->barrier.io_done = false;
Expand Down
10 changes: 7 additions & 3 deletions drivers/td-req.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,9 @@ tapdisk_xenblkif_complete_request(struct td_xenblkif * const blkif,

depth++;

processing_barrier_message =
tapreq->msg.operation == BLKIF_OP_WRITE_BARRIER;
processing_barrier_message = (
tapreq->msg.operation == BLKIF_OP_WRITE_BARRIER ||
tapreq->msg.operation == BLKIF_OP_FLUSH_DISKCACHE);

/*
* If a barrier request completes, check whether it's an I/O completion
Expand Down Expand Up @@ -770,6 +771,8 @@ tapdisk_xenblkif_make_vbd_request(struct td_xenblkif * const blkif,
tapreq->prot = PROT_READ;
vreq->op = TD_OP_WRITE;
break;
case BLKIF_OP_FLUSH_DISKCACHE:
break;
default:
RING_ERR(blkif, "req %lu: invalid request type %d\n",
tapreq->msg.id, tapreq->msg.operation);
Expand All @@ -783,7 +786,8 @@ tapdisk_xenblkif_make_vbd_request(struct td_xenblkif * const blkif,
* Check that the number of segments is sane.
*/
if (unlikely((tapreq->msg.nr_segments == 0 &&
tapreq->msg.operation != BLKIF_OP_WRITE_BARRIER) ||
(tapreq->msg.operation != BLKIF_OP_WRITE_BARRIER &&
tapreq->msg.operation != BLKIF_OP_FLUSH_DISKCACHE)) ||
tapreq->msg.nr_segments > BLKIF_MMAX_SEGMENTS_PER_REQUEST)) {
RING_ERR(blkif, "req %lu: bad number of segments in request (%d)\n",
tapreq->msg.id, tapreq->msg.nr_segments);
Expand Down
6 changes: 6 additions & 0 deletions tapback/frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ connect_frontend(vbd_t *device) {
break;
}

if ((err = tapback_device_printf(device, xst, "feature-flush-cache", true,
"%d", 1))) {
WARN(device, "failed to write feature-flush-cache: %s\n", strerror(-err));
break;
}

if ((err = tapback_device_printf(device, xst, "sector-size", true,
"%u", device->sector_size))) {
WARN(device, "failed to write sector-size: %s\n", strerror(-err));
Expand Down

0 comments on commit 73145e0

Please sign in to comment.