From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: eblake@redhat.com, Kevin Wolf <kwolf@redhat.com>,
Max Reitz <mreitz@redhat.com>,
qemu-block@nongnu.org
Subject: [Qemu-devel] [PATCH v13 02/20] block: Drop consistent read perm if opened unsafe
Date: Thu, 20 Apr 2017 15:52:19 +0800 [thread overview]
Message-ID: <20170420075237.18219-3-famz@redhat.com> (raw)
In-Reply-To: <20170420075237.18219-1-famz@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
---
block.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/block.c b/block.c
index 1fbbb8d..f5182d8 100644
--- a/block.c
+++ b/block.c
@@ -1722,9 +1722,15 @@ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
}
/* bs->file always needs to be consistent because of the metadata. We
- * can never allow other users to resize or write to it. */
- perm |= BLK_PERM_CONSISTENT_READ;
- shared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);
+ * cannot allow other users to resize or write to it unless the caller
+ * explicitly expects unsafe readings. */
+ if (!(bdrv_get_flags(bs) & BDRV_O_UNSAFE_READ)) {
+ perm |= BLK_PERM_CONSISTENT_READ;
+ shared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);
+ } else {
+ perm &= ~BLK_PERM_CONSISTENT_READ;
+ shared |= BLK_PERM_WRITE | BLK_PERM_RESIZE;
+ }
} else {
/* We want consistent read from backing files if the parent needs it.
* No other operations are performed on backing files. */
--
2.9.3
next prev parent reply other threads:[~2017-04-20 7:53 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-20 7:52 [Qemu-devel] [PATCH v13 00/20] block: Image locking series Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 01/20] block: Introduce BDRV_O_UNSAFE_READ Fam Zheng
2017-04-20 7:52 ` Fam Zheng [this message]
2017-04-20 10:58 ` [Qemu-devel] [PATCH v13 02/20] block: Drop consistent read perm if opened unsafe Kevin Wolf
2017-04-20 11:19 ` Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 03/20] block: Don't require BLK_PERM_CONSISTENT_READ when unsafe open Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 04/20] qemu-img: Add --unsafe-read option to subcommands Fam Zheng
2017-04-20 10:20 ` Kevin Wolf
2017-04-20 10:31 ` Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 05/20] qemu-img: Update documentation for --unsafe-read Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 06/20] qemu-io: Add --unsafe-read option Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 07/20] iotests: 030: Prepare for image locking Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 08/20] iotests: 046: " Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 09/20] iotests: 055: Don't attach the target image already for drive-backup Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 10/20] iotests: 085: Avoid image locking conflict Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 11/20] iotests: 087: Don't attach test image twice Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 12/20] iotests: 091: Quit QEMU before checking image Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 13/20] iotests: 172: Use separate images for multiple devices Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 14/20] tests: Use null-co:// instead of /dev/null as the dummy image Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 15/20] file-posix: Add 'locking' option Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 16/20] tests: Disable image lock in test-replication Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 17/20] block: Workaround drive-backup sync=none for image locking Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 18/20] osdep: Add qemu_lock_fd and qemu_unlock_fd Fam Zheng
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 19/20] file-posix: Add image locking in perm operations Fam Zheng
2017-04-20 9:42 ` Fam Zheng
2017-04-20 11:26 ` Kevin Wolf
2017-04-20 7:52 ` [Qemu-devel] [PATCH v13 20/20] tests: Add test-image-lock Fam Zheng
2017-04-20 8:11 ` [Qemu-devel] [PATCH v13 00/20] block: Image locking series no-reply
2017-04-20 8:32 ` Fam Zheng
2017-04-20 10:03 ` Kevin Wolf
2017-04-20 10:13 ` Fam Zheng
2017-04-20 8:39 ` no-reply
2017-04-20 9:37 ` Fam Zheng
2017-04-20 8:40 ` no-reply
2017-04-20 8:49 ` Fam Zheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170420075237.18219-3-famz@redhat.com \
--to=famz@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).