Skip to content
Snippets Groups Projects
Commit ad8890a7 authored by Dor Laor's avatar Dor Laor
Browse files

Handles aspects of RO disk - fail writes on all paths

and call biodone when appropriate
parent 3755f465
No related branches found
No related tags found
No related merge requests found
......@@ -63,6 +63,7 @@ virtio_blk_write(struct device *dev, struct uio *uio, int ioflags)
struct virtio_blk_priv *prv =
reinterpret_cast<struct virtio_blk_priv*>(dev->private_data);
if (prv->drv->is_readonly()) return EROFS;
if (uio->uio_offset + uio->uio_resid > prv->drv->size())
return EIO;
......@@ -191,10 +192,7 @@ struct driver virtio_blk_driver = {
virtio_d(fmt("\t value = %d len=%d") % (int)(*buf) % ii->_len);
}
if (req->bio != nullptr) {
biodone(req->bio);
req->bio = nullptr;
}
biodone(req->bio);
delete req;
}
......@@ -208,7 +206,6 @@ struct driver virtio_blk_driver = {
if (req_header) delete reinterpret_cast<virtio_blk_outhdr*>(req_header);
if (payload) delete payload;
if (status) delete status;
if (bio) delete bio;
}
int virtio_blk::size() {
......@@ -239,6 +236,8 @@ struct driver virtio_blk_driver = {
case BIO_WRITE:
if (is_readonly()) {
virtio_e("Error: block device is read only");
bio->bio_flags |= BIO_ERROR | BIO_DONE;
biodone(bio);
return EROFS;
}
type = VIRTIO_BLK_T_OUT;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment