Author: mav
Date: Tue May  3 07:52:06 2016
New Revision: 298960
URL: https://svnweb.freebsd.org/changeset/base/298960

Log:
  MFC r297522: Pass through some new block device features.

Modified:
  stable/10/sys/dev/xen/blkfront/blkfront.c
  stable/10/sys/dev/xen/blkfront/block.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/xen/blkfront/blkfront.c
==============================================================================
--- stable/10/sys/dev/xen/blkfront/blkfront.c   Tue May  3 07:50:58 2016        
(r298959)
+++ stable/10/sys/dev/xen/blkfront/blkfront.c   Tue May  3 07:52:06 2016        
(r298960)
@@ -849,6 +849,20 @@ xbd_feature_string(struct xbd_softc *sc,
                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, in
 
 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
        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); 

Modified: stable/10/sys/dev/xen/blkfront/block.h
==============================================================================
--- stable/10/sys/dev/xen/blkfront/block.h      Tue May  3 07:50:58 2016        
(r298959)
+++ stable/10/sys/dev/xen/blkfront/block.h      Tue May  3 07:52:06 2016        
(r298960)
@@ -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)
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to