From: Waldemar Kozaczuk <[email protected]>
Committer: Waldemar Kozaczuk <[email protected]>
Branch: master
Fix virtio-blk disk size reporting
This patch tweaks virtio blk disk size calculation
by using 512 as the size of the sector instead of
_config.blk_size which might not be even negotiated.
Per virtio 1.0 spec, 5.2.5, step 2:
"if the VIRTIO_BLK_F_BLK_SIZE feature is negotiated, blk_size can be read
to determine the optimal sector size for the driver to use. This does not
affect the units used in the protocol (always 512 bytes), but awareness of
the correct value can affect performance."
This makes disk reporting work correctly on firecracker.
Signed-off-by: Waldemar Kozaczuk <[email protected]>
---
diff --git a/drivers/virtio-blk.cc b/drivers/virtio-blk.cc
--- a/drivers/virtio-blk.cc
+++ b/drivers/virtio-blk.cc
@@ -255,13 +255,13 @@ void blk::req_done()
}
}
+static const int sector_size = 512;
+
int64_t blk::size()
{
- return _config.capacity * _config.blk_size;
+ return _config.capacity * sector_size;
}
-static const int sector_size = 512;
-
int blk::make_request(struct bio* bio)
{
// The lock is here for parallel requests protection
--
You received this message because you are subscribed to the Google Groups "OSv
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.