summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2016-05-03 07:52:06 +0000
committermav <mav@FreeBSD.org>2016-05-03 07:52:06 +0000
commit7f17c80898a32dee37f7f8bf0cf03b8f61543e8a (patch)
treedf06145f348ea64dc2a3e626df437e03c10141e1
parent74a61ec0b04cf12075c419354a5696972159ce89 (diff)
downloadFreeBSD-src-7f17c80898a32dee37f7f8bf0cf03b8f61543e8a.zip
FreeBSD-src-7f17c80898a32dee37f7f8bf0cf03b8f61543e8a.tar.gz
MFC r297522: Pass through some new block device features.
-rw-r--r--sys/dev/xen/blkfront/blkfront.c28
-rw-r--r--sys/dev/xen/blkfront/block.h7
2 files changed, 30 insertions, 5 deletions
diff --git a/sys/dev/xen/blkfront/blkfront.c b/sys/dev/xen/blkfront/blkfront.c
index e9650f0..1ad2494 100644
--- a/sys/dev/xen/blkfront/blkfront.c
+++ b/sys/dev/xen/blkfront/blkfront.c
@@ -849,6 +849,20 @@ xbd_feature_string(struct xbd_softc *sc, char *features, size_t len)
feature_cnt++;
}
+ if ((sc->xbd_flags & XBDF_DISCARD) != 0) {
+ if (feature_cnt != 0)
+ sbuf_printf(&sb, ", ");
+ sbuf_printf(&sb, "discard");
+ feature_cnt++;
+ }
+
+ if ((sc->xbd_flags & XBDF_PERSISTENT) != 0) {
+ if (feature_cnt != 0)
+ sbuf_printf(&sb, ", ");
+ sbuf_printf(&sb, "persistent_grants");
+ feature_cnt++;
+ }
+
(void) sbuf_finish(&sb);
return (sbuf_len(&sb));
}
@@ -979,7 +993,8 @@ xbd_vdevice_to_unit(uint32_t vdevice, int *unit, const char **name)
int
xbd_instance_create(struct xbd_softc *sc, blkif_sector_t sectors,
- int vdevice, uint16_t vdisk_info, unsigned long sector_size)
+ int vdevice, uint16_t vdisk_info, unsigned long sector_size,
+ unsigned long phys_sector_size)
{
char features[80];
int unit, error = 0;
@@ -1007,6 +1022,8 @@ xbd_instance_create(struct xbd_softc *sc, blkif_sector_t sectors,
sc->xbd_disk->d_name = name;
sc->xbd_disk->d_drv1 = sc;
sc->xbd_disk->d_sectorsize = sector_size;
+ sc->xbd_disk->d_stripesize = phys_sector_size;
+ sc->xbd_disk->d_stripeoffset = 0;
sc->xbd_disk->d_mediasize = sectors * sector_size;
sc->xbd_disk->d_maxsize = sc->xbd_max_request_size;
@@ -1200,7 +1217,7 @@ static void
xbd_connect(struct xbd_softc *sc)
{
device_t dev = sc->xbd_dev;
- unsigned long sectors, sector_size;
+ unsigned long sectors, sector_size, phys_sector_size;
unsigned int binfo;
int err, feature_barrier, feature_flush;
int i, j;
@@ -1223,6 +1240,11 @@ xbd_connect(struct xbd_softc *sc)
return;
}
err = xs_gather(XST_NIL, xenbus_get_otherend_path(dev),
+ "physical-sector-size", "%lu", &phys_sector_size,
+ NULL);
+ if (err || phys_sector_size <= sector_size)
+ phys_sector_size = 0;
+ err = xs_gather(XST_NIL, xenbus_get_otherend_path(dev),
"feature-barrier", "%lu", &feature_barrier,
NULL);
if (err == 0 && feature_barrier != 0)
@@ -1324,7 +1346,7 @@ xbd_connect(struct xbd_softc *sc)
bus_print_child_footer(device_get_parent(dev), dev);
xbd_instance_create(sc, sectors, sc->xbd_vdevice, binfo,
- sector_size);
+ sector_size, phys_sector_size);
}
(void)xenbus_set_state(dev, XenbusStateConnected);
diff --git a/sys/dev/xen/blkfront/block.h b/sys/dev/xen/blkfront/block.h
index 28c6ff2..ddb4088 100644
--- a/sys/dev/xen/blkfront/block.h
+++ b/sys/dev/xen/blkfront/block.h
@@ -159,10 +159,12 @@ typedef enum {
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 /*
+ XBDF_WAIT_IDLE = 1 << 6, /*
* No new work until oustanding work
* completes.
*/
+ XBDF_DISCARD = 1 << 7, /* backend supports discard */
+ XBDF_PERSISTENT = 1 << 8 /* backend supports persistent grants */
} xbd_flag_t;
/*
@@ -200,7 +202,8 @@ struct xbd_softc {
};
int xbd_instance_create(struct xbd_softc *, blkif_sector_t sectors, int device,
- uint16_t vdisk_info, unsigned long sector_size);
+ uint16_t vdisk_info, unsigned long sector_size,
+ unsigned long phys_sector_size);
static inline void
xbd_added_qentry(struct xbd_softc *sc, xbd_q_index_t index)
OpenPOWER on IntegriCloud