Date: Tue, 03 Sep 2019 14:06:03 -0000 From: Pawel Jakub Dawidek <pjd@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345726 - head/sys/dev/xen/blkfront Message-ID: <201903300720.x2U7KSmN086902@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pjd Date: Sat Mar 30 07:20:28 2019 New Revision: 345726 URL: https://svnweb.freebsd.org/changeset/base/345726 Log: Implement support for online disk capacity changes. Obtained from: Fudo Security Tested in: AWS Modified: head/sys/dev/xen/blkfront/blkfront.c Modified: head/sys/dev/xen/blkfront/blkfront.c ============================================================================== --- head/sys/dev/xen/blkfront/blkfront.c Sat Mar 30 01:56:53 2019 (r345725) +++ head/sys/dev/xen/blkfront/blkfront.c Sat Mar 30 07:20:28 2019 (r345726) @@ -1227,11 +1227,40 @@ xbd_connect(struct xbd_softc *sc) int err, feature_barrier, feature_flush; int i, j; - if (sc->xbd_state == XBD_STATE_CONNECTED || - sc->xbd_state == XBD_STATE_SUSPENDED) + DPRINTK("blkfront.c:connect:%s.\n", xenbus_get_otherend_path(dev)); + + if (sc->xbd_state == XBD_STATE_SUSPENDED) { return; + } - DPRINTK("blkfront.c:connect:%s.\n", xenbus_get_otherend_path(dev)); + if (sc->xbd_state == XBD_STATE_CONNECTED) { + struct disk *disk; + + disk = sc->xbd_disk; + if (disk == NULL) { + return; + } + err = xs_gather(XST_NIL, xenbus_get_otherend_path(dev), + "sectors", "%lu", §ors, NULL); + if (err != 0) { + xenbus_dev_error(dev, err, + "reading sectors at %s", + xenbus_get_otherend_path(dev)); + return; + } + disk->d_mediasize = disk->d_sectorsize * sectors; + err = disk_resize(disk, M_NOWAIT); + if (err) { + xenbus_dev_error(dev, err, + "unable to resize disk %s%u", + disk->d_name, disk->d_unit); + return; + } + device_printf(sc->xbd_dev, + "changed capacity to %jd\n", + (intmax_t)disk->d_mediasize); + return; + } err = xs_gather(XST_NIL, xenbus_get_otherend_path(dev), "sectors", "%lu", §ors,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903300720.x2U7KSmN086902>