[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v3 1/8] file-posix: Update open_flags in raw_set_per
From: |
Max Reitz |
Subject: |
[Qemu-block] [PATCH v3 1/8] file-posix: Update open_flags in raw_set_perm() |
Date: |
Wed, 22 May 2019 19:03:45 +0200 |
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 <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
---
block/file-posix.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/block/file-posix.c b/block/file-posix.c
index d018429672..5a54968183 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -145,6 +145,7 @@ typedef struct BDRVRawState {
uint64_t locked_shared_perm;
int perm_change_fd;
+ int perm_change_flags;
BDRVReopenState *reopen_state;
#ifdef CONFIG_XFS
@@ -2783,6 +2784,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,
@@ -2791,6 +2793,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;
}
}
@@ -2829,6 +2832,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.21.0
- [Qemu-block] [PATCH v3 0/8] block: Ignore loosening perm restrictions failures, Max Reitz, 2019/05/22
- [Qemu-block] [PATCH v3 1/8] file-posix: Update open_flags in raw_set_perm(),
Max Reitz <=
- [Qemu-block] [PATCH v3 4/8] block/commit: Drop bdrv_child_try_set_perm(), Max Reitz, 2019/05/22
- [Qemu-block] [PATCH v3 2/8] block: Add bdrv_child_refresh_perms(), Max Reitz, 2019/05/22
- [Qemu-block] [PATCH v3 7/8] block: Ignore loosening perm restrictions failures, Max Reitz, 2019/05/22
- [Qemu-block] [PATCH v3 3/8] block/mirror: Fix child permissions, Max Reitz, 2019/05/22
- [Qemu-block] [PATCH v3 5/8] block: Fix order in bdrv_replace_child(), Max Reitz, 2019/05/22
- [Qemu-block] [PATCH v3 6/8] block: Add *tighten_restrictions to *check*_perm(), Max Reitz, 2019/05/22
- [Qemu-block] [PATCH v3 8/8] iotests: Test failure to loosen restrictions, Max Reitz, 2019/05/22
- Re: [Qemu-block] [Qemu-devel] [PATCH v3 0/8] block: Ignore loosening perm restrictions failures, Eric Blake, 2019/05/22