aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/virtio
diff options
context:
space:
mode:
authorBryan Venteicher <bryanv@FreeBSD.org>2021-01-19 04:55:24 +0000
committerBryan Venteicher <bryanv@FreeBSD.org>2021-01-19 04:55:24 +0000
commit149ab110dd5c9b6058142408a44ef2aa18b30037 (patch)
treeba5c58fa4c18abe875bb6207bceecce69953057b /sys/dev/virtio
parent5e2208117787f3f0b9dc079e1060edf91eb2b5fc (diff)
downloadsrc-149ab110dd5c9b6058142408a44ef2aa18b30037.tar.gz
src-149ab110dd5c9b6058142408a44ef2aa18b30037.zip
Diffstat (limited to 'sys/dev/virtio')
-rw-r--r--sys/dev/virtio/block/virtio_blk.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/sys/dev/virtio/block/virtio_blk.c b/sys/dev/virtio/block/virtio_blk.c
index 091eb029530e..08df77d6de5b 100644
--- a/sys/dev/virtio/block/virtio_blk.c
+++ b/sys/dev/virtio/block/virtio_blk.c
@@ -76,11 +76,10 @@ struct vtblk_softc {
uint64_t vtblk_features;
uint32_t vtblk_flags;
#define VTBLK_FLAG_INDIRECT 0x0001
-#define VTBLK_FLAG_READONLY 0x0002
-#define VTBLK_FLAG_DETACH 0x0004
-#define VTBLK_FLAG_SUSPEND 0x0008
-#define VTBLK_FLAG_BARRIER 0x0010
-#define VTBLK_FLAG_WCE_CONFIG 0x0020
+#define VTBLK_FLAG_DETACH 0x0002
+#define VTBLK_FLAG_SUSPEND 0x0004
+#define VTBLK_FLAG_BARRIER 0x0008
+#define VTBLK_FLAG_WCE_CONFIG 0x0010
struct virtqueue *vtblk_vq;
struct sglist *vtblk_sglist;
@@ -553,17 +552,6 @@ vtblk_strategy(struct bio *bp)
return;
}
- /*
- * Fail any write if RO. Unfortunately, there does not seem to
- * be a better way to report our readonly'ness to GEOM above.
- */
- if (sc->vtblk_flags & VTBLK_FLAG_READONLY &&
- (bp->bio_cmd == BIO_WRITE || bp->bio_cmd == BIO_FLUSH ||
- bp->bio_cmd == BIO_DELETE)) {
- vtblk_bio_done(sc, bp, EROFS);
- return;
- }
-
if ((bp->bio_cmd != BIO_READ) && (bp->bio_cmd != BIO_WRITE) &&
(bp->bio_cmd != BIO_FLUSH) && (bp->bio_cmd != BIO_DELETE)) {
vtblk_bio_done(sc, bp, EOPNOTSUPP);
@@ -609,8 +597,6 @@ vtblk_setup_features(struct vtblk_softc *sc)
if (virtio_with_feature(dev, VIRTIO_RING_F_INDIRECT_DESC))
sc->vtblk_flags |= VTBLK_FLAG_INDIRECT;
- if (virtio_with_feature(dev, VIRTIO_BLK_F_RO))
- sc->vtblk_flags |= VTBLK_FLAG_READONLY;
if (virtio_with_feature(dev, VIRTIO_BLK_F_CONFIG_WCE))
sc->vtblk_flags |= VTBLK_FLAG_WCE_CONFIG;
@@ -701,11 +687,13 @@ vtblk_alloc_disk(struct vtblk_softc *sc, struct virtio_blk_config *blkcfg)
dp->d_hba_subvendor = virtio_get_subvendor(dev);
dp->d_hba_subdevice = virtio_get_subdevice(dev);
- if (virtio_with_feature(dev, VIRTIO_BLK_F_FLUSH))
- dp->d_flags |= DISKFLAG_CANFLUSHCACHE;
-
- if ((sc->vtblk_flags & VTBLK_FLAG_READONLY) == 0)
+ if (virtio_with_feature(dev, VIRTIO_BLK_F_RO))
+ dp->d_flags |= DISKFLAG_WRITE_PROTECT;
+ else {
+ if (virtio_with_feature(dev, VIRTIO_BLK_F_FLUSH))
+ dp->d_flags |= DISKFLAG_CANFLUSHCACHE;
dp->d_dump = vtblk_dump;
+ }
/* Capacity is always in 512-byte units. */
dp->d_mediasize = blkcfg->capacity * VTBLK_BSIZE;