svn commit: r345726 - head/sys/dev/xen/blkfront
Pawel Jakub Dawidek
pjd at FreeBSD.org
Sat Mar 30 07:20:29 UTC 2019
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,
More information about the svn-src-all
mailing list