MFC r297522: Pass through some new block device features.

This commit is contained in:
mav 2016-05-03 07:52:06 +00:00
parent 74a61ec0b0
commit 7f17c80898
2 changed files with 30 additions and 5 deletions

View File

@ -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;
@ -1222,6 +1239,11 @@ xbd_connect(struct xbd_softc *sc)
xenbus_get_otherend_path(dev));
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);
@ -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);

View File

@ -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)