qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 06/14] file-posix: Update open_flags in raw_set_perm()
Date: Tue, 18 Jun 2019 17:23:10 +0200	[thread overview]
Message-ID: <20190618152318.24953-7-kwolf@redhat.com> (raw)
In-Reply-To: <20190618152318.24953-1-kwolf@redhat.com>

From: Max Reitz <mreitz@redhat.com>

raw_check_perm() + raw_set_perm() can change the flags associated with
the current FD.  If so, we have to update BDRVRawState.open_flags
accordingly.  Otherwise, we may keep reopening the FD even though the
current one already has the correct flags.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/file-posix.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/block/file-posix.c b/block/file-posix.c
index 83ab1b78ef..ab05b51a66 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -146,6 +146,7 @@ typedef struct BDRVRawState {
     uint64_t locked_shared_perm;
 
     int perm_change_fd;
+    int perm_change_flags;
     BDRVReopenState *reopen_state;
 
 #ifdef CONFIG_XFS
@@ -2788,6 +2789,7 @@ static int raw_check_perm(BlockDriverState *bs, uint64_t perm, uint64_t shared,
         assert(s->reopen_state->shared_perm == shared);
         rs = s->reopen_state->opaque;
         s->perm_change_fd = rs->fd;
+        s->perm_change_flags = rs->open_flags;
     } else {
         /* We may need a new fd if auto-read-only switches the mode */
         ret = raw_reconfigure_getfd(bs, bs->open_flags, &open_flags, perm,
@@ -2796,6 +2798,7 @@ static int raw_check_perm(BlockDriverState *bs, uint64_t perm, uint64_t shared,
             return ret;
         } else if (ret != s->fd) {
             s->perm_change_fd = ret;
+            s->perm_change_flags = open_flags;
         }
     }
 
@@ -2834,6 +2837,7 @@ static void raw_set_perm(BlockDriverState *bs, uint64_t perm, uint64_t shared)
     if (s->perm_change_fd && s->fd != s->perm_change_fd) {
         qemu_close(s->fd);
         s->fd = s->perm_change_fd;
+        s->open_flags = s->perm_change_flags;
     }
     s->perm_change_fd = 0;
 
-- 
2.20.1



  parent reply	other threads:[~2019-06-18 16:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-18 15:23 [Qemu-devel] [PULL 00/14] Block layer patches Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 01/14] iotests: Hide timestamps for skipped tests Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 02/14] block/replication: drop usage of bs->job Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 03/14] block/block-backend: blk_iostatus_reset: " Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 04/14] blockdev: blockdev_mark_auto_del: " Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 05/14] block: drop bs->job Kevin Wolf
2019-06-18 15:23 ` Kevin Wolf [this message]
2019-06-18 15:23 ` [Qemu-devel] [PULL 07/14] block: Add bdrv_child_refresh_perms() Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 08/14] block/mirror: Fix child permissions Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 09/14] block/commit: Drop bdrv_child_try_set_perm() Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 10/14] block: Fix order in bdrv_replace_child() Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 11/14] block: Add *tighten_restrictions to *check*_perm() Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 12/14] block: Ignore loosening perm restrictions failures Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 13/14] iotests: Test failure to loosen restrictions Kevin Wolf
2019-06-18 15:23 ` [Qemu-devel] [PULL 14/14] block/null: Expose read-zeroes option in QAPI schema Kevin Wolf
2019-06-18 16:32 ` [Qemu-devel] [PULL 00/14] Block layer patches Peter Maydell

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=20190618152318.24953-7-kwolf@redhat.com \
    --to=kwolf@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).