virtio_blk: allow read-only disks
Subsystems (4)
PATCH 1/1 virtio_blk: allow read-only disks
Hello Rusty,
sometimes it is useful to share a disk (e.g. usr). To avoid file system corruption, the disk should be mounted read-only in that case. This patch adds a new feature flag, that allows the host to specify, if the disk should be considered read-only.
--- drivers/block/virtio_blk.c | 6 +++++- include/linux/virtio_blk.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/block/virtio_blk.c +5 -1
@@ -260,6 +260,10 @@ static int virtblk_probe(struct virtio_dif (virtio_has_feature (vdev,VIRTIO_BLK_F_BARRIER ))blk_queue_ordered (vblk->disk->queue,QUEUE_ORDERED_TAG ,NULL ); +/* If disk is read-only in the host, the guest should obey */ +if (virtio_has_feature (vdev,VIRTIO_BLK_F_RO )) +set_disk_ro (vblk->disk,1 ); +/* Host must always specify the capacity. */ vdev->config->get (vdev, offsetof(struct virtio_blk_config , capacity), &cap,sizeof (cap));
@@ -325,7 +329,7 @@ static struct virtio_device_id id_table[static unsigned int features[] = {VIRTIO_BLK_F_BARRIER ,VIRTIO_BLK_F_SEG_MAX ,VIRTIO_BLK_F_SIZE_MAX , -VIRTIO_BLK_F_GEOMETRY , +VIRTIO_BLK_F_GEOMETRY ,VIRTIO_BLK_F_RO , };static struct virtio_driver virtio_blk = {
include/linux/virtio_blk.h +1 -0
@@ -10,6 +10,7 @@#define VIRTIO_BLK_F_SIZE_MAX 1/* Indicates maximum segment size */ #define VIRTIO_BLK_F_SEG_MAX 2/* Indicates maximum # of segments */ #define VIRTIO_BLK_F_GEOMETRY 4/* Legacy geometry available */ +#define VIRTIO_BLK_F_RO 5/* Disk is read-only */ struct virtio_blk_config {
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Quoted 4 lines · Christian Borntraeger
Hello Rusty,
sometimes it is useful to share a disk (e.g. usr). To avoid file system corruption, the disk should be mounted read-only in that case.
Although it is done at a different level here, I wanted to note that mounting a filesystem read-only does not necessarily mean the system will not try to write to it. This is the case for ext3, for example - when mounted ro, system will still reply the journal and do some writes etc.
The patch, however, should take care of that, too, as it is completely different place it is made ro.
Signature · 7 lines
Tomasz Chmielewski http://wpkg.org ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Quoted 6 lines · On Friday 16 May 2008 19:28:27 Tomasz Chmielewski wrote:
Quoted 4 lines · Christian Borntraeger
Hello Rusty,
sometimes it is useful to share a disk (e.g. usr). To avoid file system corruption, the disk should be mounted read-only in that case.
Quoted 7 lines
Although it is done at a different level here, I wanted to note that mounting a filesystem read-only does not necessarily mean the system will not try to write to it. This is the case for ext3, for example - when mounted ro, system will still reply the journal and do some writes etc.
The patch, however, should take care of that, too, as it is completely different place it is made ro.
Note I'm assuming that the host will deny writes. Telling the guest is merely politeness.
Cheers,
Rusty.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Quoted 6 lines · On Friday 16 May 2008 19:28:27 Tomasz Chmielewski wrote:
Quoted 4 lines · Christian Borntraeger
Hello Rusty,
sometimes it is useful to share a disk (e.g. usr). To avoid file system corruption, the disk should be mounted read-only in that case.
Quoted 7 lines
Although it is done at a different level here, I wanted to note that mounting a filesystem read-only does not necessarily mean the system will not try to write to it. This is the case for ext3, for example - when mounted ro, system will still reply the journal and do some writes etc.
The patch, however, should take care of that, too, as it is completely different place it is made ro.
Note I'm assuming that the host will deny writes. Telling the guest is merely politeness.
Cheers,
Rusty.
Quoted 4 lines · Christian Borntraeger
Hello Rusty,
sometimes it is useful to share a disk (e.g. usr). To avoid file system corruption, the disk should be mounted read-only in that case.
Although it is done at a different level here, I wanted to note that mounting a filesystem read-only does not necessarily mean the system will not try to write to it. This is the case for ext3, for example - when mounted ro, system will still reply the journal and do some writes etc.
The patch, however, should take care of that, too, as it is completely different place it is made ro.
Signature · 2 lines
Tomasz Chmielewski http://wpkg.org
Rusty Russell
AppliedQuoted 6 lines · On Friday 16 May 2008 19:17:03 Christian Borntraeger wrote:
Hello Rusty,
sometimes it is useful to share a disk (e.g. usr). To avoid file system corruption, the disk should be mounted read-only in that case. This patch adds a new feature flag, that allows the host to specify, if the disk should be considered read-only.
Applied, thanks.
Rusty.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Rusty Russell
AppliedQuoted 6 lines · On Friday 16 May 2008 19:17:03 Christian Borntraeger wrote:
Hello Rusty,
sometimes it is useful to share a disk (e.g. usr). To avoid file system corruption, the disk should be mounted read-only in that case. This patch adds a new feature flag, that allows the host to specify, if the disk should be considered read-only.
Applied, thanks.
Rusty.