svn commit: r361579 - head/sys/dev/xen/blkfront

Roger Pau Monné royger at FreeBSD.org
Thu May 28 08:19:14 UTC 2020


Author: royger
Date: Thu May 28 08:19:13 2020
New Revision: 361579
URL: https://svnweb.freebsd.org/changeset/base/361579

Log:
  xen/blkfront: use the correct type for disk sectors
  
  The correct type to use to represent disk sectors is blkif_sector_t
  (which is an uint64_t underneath). This avoid truncation of the disk
  size calculation when resizing on i386, as otherwise the calculation
  of d_mediasize in xbd_connect is truncated to the size of unsigned
  long, which is 32bits on i386.
  
  Note this issue didn't affect amd64, because the size of unsigned long
  is 64bits there.
  
  Sponsored by:	Citrix Systems R&D
  MFC after:	1 week

Modified:
  head/sys/dev/xen/blkfront/blkfront.c

Modified: head/sys/dev/xen/blkfront/blkfront.c
==============================================================================
--- head/sys/dev/xen/blkfront/blkfront.c	Thu May 28 08:18:34 2020	(r361578)
+++ head/sys/dev/xen/blkfront/blkfront.c	Thu May 28 08:19:13 2020	(r361579)
@@ -1225,7 +1225,8 @@ static void 
 xbd_connect(struct xbd_softc *sc)
 {
 	device_t dev = sc->xbd_dev;
-	unsigned long sectors, sector_size, phys_sector_size;
+	blkif_sector_t sectors;
+	unsigned long sector_size, phys_sector_size;
 	unsigned int binfo;
 	int err, feature_barrier, feature_flush;
 	int i, j;
@@ -1244,7 +1245,7 @@ xbd_connect(struct xbd_softc *sc)
 			return;
 		}
 		err = xs_gather(XST_NIL, xenbus_get_otherend_path(dev),
-		    "sectors", "%lu", &sectors, NULL);
+		    "sectors", "%"PRIu64, &sectors, NULL);
 		if (err != 0) {
 			xenbus_dev_error(dev, err,
 			    "reading sectors at %s",
@@ -1266,7 +1267,7 @@ xbd_connect(struct xbd_softc *sc)
 	}
 
 	err = xs_gather(XST_NIL, xenbus_get_otherend_path(dev),
-	    "sectors", "%lu", &sectors,
+	    "sectors", "%"PRIu64, &sectors,
 	    "info", "%u", &binfo,
 	    "sector-size", "%lu", &sector_size,
 	    NULL);
@@ -1279,7 +1280,7 @@ xbd_connect(struct xbd_softc *sc)
 	if ((sectors == 0) || (sector_size == 0)) {
 		xenbus_dev_fatal(dev, 0,
 		    "invalid parameters from %s:"
-		    " sectors = %lu, sector_size = %lu",
+		    " sectors = %"PRIu64", sector_size = %lu",
 		    xenbus_get_otherend_path(dev),
 		    sectors, sector_size);
 		return;


More information about the svn-src-all mailing list