Skip to contentSkip to conversation

luks: Allow share-rw=on

PATCH Applied Fam Zheng 3 participants 3 messages Aug 14, 2018 Block layer

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 luks: Allow share-rw=on

Format drivers such as qcow2 don't allow sharing the same image between two QEMU instances in order to prevent image corruptions, because of metadata cache. LUKS driver don't modify metadata except for when creating image, so it is safe to relax the permission. This makes share-rw=on property work on virtual devices.

---
 block/crypto.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
block/crypto.c +3 -1
index 146d81c90a..33ee01bebd 100644
@@ -627,7 +627,9 @@ BlockDriver bdrv_crypto_luks = {
     .bdrv_probe         = block_crypto_probe_luks,
     .bdrv_open          = block_crypto_open_luks,
     .bdrv_close         = block_crypto_close,
-    .bdrv_child_perm    = bdrv_format_default_perms,
+    /* This driver doesn't modify LUKS metadata except when creating image.
+     * Allow share-rw=on as a special case. */
+    .bdrv_child_perm    = bdrv_filter_default_perms,
     .bdrv_co_create     = block_crypto_co_create_luks,
     .bdrv_co_create_opts = block_crypto_co_create_opts_luks,
     .bdrv_co_truncate   = block_crypto_co_truncate,
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Fam Zheng

Format drivers such as qcow2 don't allow sharing the same image between two QEMU instances in order to prevent image corruptions, because of metadata cache. LUKS driver don't modify metadata except for when creating image, so it is safe to relax the permission. This makes share-rw=on property work on virtual devices.

---
 block/crypto.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
block/crypto.c +0 -0
index 146d81c90a..33ee01bebd 100644

block/crypto.c BlockDriver bdrv_crypto_luks = { · line 635

Quoted 10 lines
block/crypto.c +3 -1
@@ -627,7 +627,9 @@ BlockDriver bdrv_crypto_luks = {
     .bdrv_probe         = block_crypto_probe_luks,
     .bdrv_open          = block_crypto_open_luks,
     .bdrv_close         = block_crypto_close,
-    .bdrv_child_perm    = bdrv_format_default_perms,
+    /* This driver doesn't modify LUKS metadata except when creating image.
+     * Allow share-rw=on as a special case. */
+    .bdrv_child_perm    = bdrv_filter_default_perms,
     .bdrv_co_create     = block_crypto_co_create_luks,
     .bdrv_co_create_opts = block_crypto_co_create_opts_luks,
     .bdrv_co_truncate   = block_crypto_co_truncate,

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Applied
#2 lore raw

Am 14.08.2018 um 09:27 hat Daniel P. Berrangé geschrieben:

Quoted 22 lines · Fam Zheng
Quoted 21 lines

Format drivers such as qcow2 don't allow sharing the same image between two QEMU instances in order to prevent image corruptions, because of metadata cache. LUKS driver don't modify metadata except for when creating image, so it is safe to relax the permission. This makes share-rw=on property work on virtual devices.

---
 block/crypto.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
block/crypto.c +0 -1
index 146d81c90a..33ee01bebd 100644
@@ -627,7 +627,9 @@ BlockDriver bdrv_crypto_luks = {
     .bdrv_probe         = block_crypto_probe_luks,
     .bdrv_open          = block_crypto_open_luks,
     .bdrv_close         = block_crypto_close,
-    .bdrv_child_perm    = bdrv_format_default_perms,
Quoted 8 lines

block/crypto.c BlockDriver bdrv_crypto_luks = { · line 635

Quoted 6 lines
block/crypto.c +3 -0
+    /* This driver doesn't modify LUKS metadata except when creating image.
+     * Allow share-rw=on as a special case. */
+    .bdrv_child_perm    = bdrv_filter_default_perms,
     .bdrv_co_create     = block_crypto_co_create_luks,
     .bdrv_co_create_opts = block_crypto_co_create_opts_luks,
     .bdrv_co_truncate   = block_crypto_co_truncate,

Thanks, applied to the block branch.

Kevin