summaryrefslogtreecommitdiffstats
path: root/sys/dev/xen/blkfront/block.h
diff options
context:
space:
mode:
authorgibbs <gibbs@FreeBSD.org>2013-06-26 20:39:07 +0000
committergibbs <gibbs@FreeBSD.org>2013-06-26 20:39:07 +0000
commite7f9e472fe57a341b8332bd98447ab01e94e65a3 (patch)
tree016ccaed3fa2945d44f8e207e7d9663a103a5b1a /sys/dev/xen/blkfront/block.h
parentef282086af7ae18f6589ca446e36e606ca79a751 (diff)
downloadFreeBSD-src-e7f9e472fe57a341b8332bd98447ab01e94e65a3.zip
FreeBSD-src-e7f9e472fe57a341b8332bd98447ab01e94e65a3.tar.gz
In the Xen block front driver, take advantage of backends that
support cache flush and write barrier commands. sys/dev/xen/blkfront/block.h: Add per-command flag that specifies that the I/O queue must be frozen after this command is dispatched. This is used to implement "single-stepping". Remove the unused per-command flag that indicates a polled command. Add block device instance flags to record backend features. Add a block device instance flag to indicate the I/O queue is frozen until all outstanding I/O completes. Enhance the queue API to allow the number of elements in a queue to be interrogated. Prefer "inline" to "__inline". sys/dev/xen/blkfront/blkfront.c: Formalize queue freeze semantics by adding methods for both global and command-associated queue freezing. Provide mechanism to freeze the I/O queue until all outstanding I/O completes. Use this to implement barrier semantics (BIO_ORDERED) when the backend does not support BLKIF_OP_WRITE_BARRIER commands. Implement BIO_FLUSH as either a BLKIF_OP_FLUSH_DISKCACHE command or a 0 byte write barrier. Currently, all publicly available backends perform a diskcache flush when processing barrier commands, and this frontend behavior matches what is done in Linux. Simplify code by using new queue length API. Report backend features during device attach and via sysctl. Submitted by: Roger Pau Monné Submitted by: gibbs (Merge with new driver queue API, sysctl support)
Diffstat (limited to 'sys/dev/xen/blkfront/block.h')
-rw-r--r--sys/dev/xen/blkfront/block.h30
1 files changed, 22 insertions, 8 deletions
diff --git a/sys/dev/xen/blkfront/block.h b/sys/dev/xen/blkfront/block.h
index 7cfe241..0f7d6cb 100644
--- a/sys/dev/xen/blkfront/block.h
+++ b/sys/dev/xen/blkfront/block.h
@@ -94,8 +94,11 @@
typedef enum {
XBDCF_Q_MASK = 0xFF,
+ /* This command has contributed to xbd_qfrozen_cnt. */
XBDCF_FROZEN = 1<<8,
- XBDCF_POLLED = 1<<9,
+ /* Freeze the command queue on dispatch (i.e. single step command). */
+ XBDCF_Q_FREEZE = 1<<9,
+ /* Bus DMA returned EINPROGRESS for this command. */
XBDCF_ASYNC_MAPPING = 1<<10,
XBDCF_INITIALIZER = XBDCF_Q_MASK
} xbdc_flag_t;
@@ -147,9 +150,14 @@ typedef enum {
XBDF_NONE = 0,
XBDF_OPEN = 1 << 0, /* drive is open (can't shut down) */
XBDF_BARRIER = 1 << 1, /* backend supports barriers */
- XBDF_READY = 1 << 2, /* Is ready */
- XBDF_CM_SHORTAGE = 1 << 3, /* Free cm resource shortage active. */
- XBDF_GNT_SHORTAGE = 1 << 4 /* Grant ref resource shortage active */
+ XBDF_FLUSH = 1 << 2, /* backend supports flush */
+ XBDF_READY = 1 << 3, /* Is ready */
+ XBDF_CM_SHORTAGE = 1 << 4, /* Free cm resource shortage active. */
+ XBDF_GNT_SHORTAGE = 1 << 5, /* Grant ref resource shortage active */
+ XBDF_WAIT_IDLE = 1 << 6 /*
+ * No new work until oustanding work
+ * completes.
+ */
} xbd_flag_t;
/*
@@ -206,6 +214,12 @@ xbd_removed_qentry(struct xbd_softc *sc, xbd_q_index_t index)
sc->xbd_cm_q[index].q_length--;
}
+static inline uint32_t
+xbd_queue_length(struct xbd_softc *sc, xbd_q_index_t index)
+{
+ return (sc->xbd_cm_q[index].q_length);
+}
+
static inline void
xbd_initq_cm(struct xbd_softc *sc, xbd_q_index_t index)
{
@@ -289,27 +303,27 @@ xbd_remove_cm(struct xbd_command *cm, xbd_q_index_t expected_index)
xbd_removed_qentry(cm->cm_sc, index);
}
-static __inline void
+static inline void
xbd_initq_bio(struct xbd_softc *sc)
{
bioq_init(&sc->xbd_bioq);
}
-static __inline void
+static inline void
xbd_enqueue_bio(struct xbd_softc *sc, struct bio *bp)
{
bioq_insert_tail(&sc->xbd_bioq, bp);
xbd_added_qentry(sc, XBD_Q_BIO);
}
-static __inline void
+static inline void
xbd_requeue_bio(struct xbd_softc *sc, struct bio *bp)
{
bioq_insert_head(&sc->xbd_bioq, bp);
xbd_added_qentry(sc, XBD_Q_BIO);
}
-static __inline struct bio *
+static inline struct bio *
xbd_dequeue_bio(struct xbd_softc *sc)
{
struct bio *bp;
OpenPOWER on IntegriCloud