Implement support for online disk capacity changes.
Obtained from: Fudo Security Tested in: AWS
This commit is contained in:
parent
b89cf12cc6
commit
e55624c605
@ -1227,12 +1227,41 @@ 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)
|
||||
return;
|
||||
|
||||
DPRINTK("blkfront.c:connect:%s.\n", xenbus_get_otherend_path(dev));
|
||||
|
||||
if (sc->xbd_state == XBD_STATE_SUSPENDED) {
|
||||
return;
|
||||
}
|
||||
|
||||
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,
|
||||
"info", "%u", &binfo,
|
||||
|
Loading…
Reference in New Issue
Block a user