Skip to content

Commit 9426b0a

Browse files
committed
CP-46757: advertise feature-flush-cache
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 <[email protected]>
1 parent 1179cd6 commit 9426b0a

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

drivers/td-ctx.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ __xenio_blkif_get_requests(struct td_xenblkif * const blkif,
230230

231231
xenio_blkif_get_request(blkif, dst, rc);
232232

233-
if (unlikely(dst->operation == BLKIF_OP_WRITE_BARRIER))
233+
if (unlikely(dst->operation == BLKIF_OP_WRITE_BARRIER ||
234+
dst->operation == BLKIF_OP_FLUSH_DISKCACHE))
234235
barrier = true;
235236
}
236237

@@ -278,7 +279,8 @@ xenio_blkif_get_requests(struct td_xenblkif * const blkif,
278279

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

281-
if (unlikely(n && reqs[(n - 1)]->operation == BLKIF_OP_WRITE_BARRIER))
282+
if (unlikely(n && (reqs[(n - 1)]->operation == BLKIF_OP_WRITE_BARRIER ||
283+
reqs[(n - 1)]->operation == BLKIF_OP_FLUSH_DISKCACHE)))
282284
break;
283285

284286
} while (1);
@@ -327,8 +329,8 @@ tapdisk_xenio_ctx_process_ring(struct td_xenblkif *blkif,
327329
limit -= n_reqs;
328330
final = 1;
329331

330-
if (unlikely(reqs[(n_reqs - 1)]->operation ==
331-
BLKIF_OP_WRITE_BARRIER)) {
332+
if (unlikely(reqs[(n_reqs - 1)]->operation == BLKIF_OP_WRITE_BARRIER ||
333+
reqs[(n_reqs - 1)]->operation == BLKIF_OP_FLUSH_DISKCACHE)) {
332334
ASSERT(!blkif->barrier.msg);
333335
blkif->barrier.msg = reqs[(n_reqs - 1)];
334336
blkif->barrier.io_done = false;

drivers/td-req.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,9 @@ tapdisk_xenblkif_complete_request(struct td_xenblkif * const blkif,
467467

468468
depth++;
469469

470-
processing_barrier_message =
471-
tapreq->msg.operation == BLKIF_OP_WRITE_BARRIER;
470+
processing_barrier_message = (
471+
tapreq->msg.operation == BLKIF_OP_WRITE_BARRIER ||
472+
tapreq->msg.operation == BLKIF_OP_FLUSH_DISKCACHE);
472473

473474
/*
474475
* If a barrier request completes, check whether it's an I/O completion
@@ -763,6 +764,7 @@ tapdisk_xenblkif_make_vbd_request(struct td_xenblkif * const blkif,
763764
break;
764765
case BLKIF_OP_WRITE:
765766
case BLKIF_OP_WRITE_BARRIER:
767+
case BLKIF_OP_FLUSH_DISKCACHE:
766768
if (likely(blkif->stats.xenvbd))
767769
blkif->stats.xenvbd->st_wr_req++;
768770
if (likely(blkif->vbd_stats.stats))
@@ -783,7 +785,8 @@ tapdisk_xenblkif_make_vbd_request(struct td_xenblkif * const blkif,
783785
* Check that the number of segments is sane.
784786
*/
785787
if (unlikely((tapreq->msg.nr_segments == 0 &&
786-
tapreq->msg.operation != BLKIF_OP_WRITE_BARRIER) ||
788+
(tapreq->msg.operation != BLKIF_OP_WRITE_BARRIER &&
789+
tapreq->msg.operation != BLKIF_OP_FLUSH_DISKCACHE)) ||
787790
tapreq->msg.nr_segments > BLKIF_MMAX_SEGMENTS_PER_REQUEST)) {
788791
RING_ERR(blkif, "req %lu: bad number of segments in request (%d)\n",
789792
tapreq->msg.id, tapreq->msg.nr_segments);

tapback/frontend.c

+6
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,12 @@ connect_frontend(vbd_t *device) {
300300
break;
301301
}
302302

303+
if ((err = tapback_device_printf(device, xst, "feature-flush-cache", true,
304+
"%d", 1))) {
305+
WARN(device, "failed to write feature-flush-cache: %s\n", strerror(-err));
306+
break;
307+
}
308+
303309
if ((err = tapback_device_printf(device, xst, "sector-size", true,
304310
"%u", device->sector_size))) {
305311
WARN(device, "failed to write sector-size: %s\n", strerror(-err));

0 commit comments

Comments
 (0)