[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/24] block: Move read-only check during truncation earlier
From: |
Kevin Wolf |
Subject: |
[PULL 02/24] block: Move read-only check during truncation earlier |
Date: |
Wed, 30 Jun 2021 18:01:44 +0200 |
From: Eric Blake <eblake@redhat.com>
No need to start a tracked request that will always fail. The choice
to check read-only after bdrv_inc_in_flight() predates 1bc5f09f2e
(block: Use tracked request for truncate), but waiting for serializing
requests can make the effect more noticeable.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20210609163034.997943-1-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/io.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/block/io.c b/block/io.c
index dd93364258..cf177a9d2d 100644
--- a/block/io.c
+++ b/block/io.c
@@ -3392,6 +3392,11 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child,
int64_t offset, bool exact,
return old_size;
}
+ if (bdrv_is_read_only(bs)) {
+ error_setg(errp, "Image is read-only");
+ return -EACCES;
+ }
+
if (offset > old_size) {
new_bytes = offset - old_size;
} else {
@@ -3408,11 +3413,6 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child,
int64_t offset, bool exact,
if (new_bytes) {
bdrv_make_request_serialising(&req, 1);
}
- if (bdrv_is_read_only(bs)) {
- error_setg(errp, "Image is read-only");
- ret = -EACCES;
- goto out;
- }
ret = bdrv_co_write_req_prepare(child, offset - new_bytes, new_bytes, &req,
0);
if (ret < 0) {
--
2.31.1
- [PULL 00/24] Block layer patches, Kevin Wolf, 2021/06/30
- [PULL 02/24] block: Move read-only check during truncation earlier,
Kevin Wolf <=
- [PULL 01/24] Prevent compiler warning on block.c, Kevin Wolf, 2021/06/30
- [PULL 03/24] block: BDRV_O_NO_IO for backing file on creation, Kevin Wolf, 2021/06/30
- [PULL 07/24] block: introduce bdrv_set_file_or_backing_noperm(), Kevin Wolf, 2021/06/30
- [PULL 06/24] block: introduce bdrv_remove_file_or_backing_child(), Kevin Wolf, 2021/06/30
- [PULL 08/24] block: bdrv_reopen_parse_backing(): don't check aio context, Kevin Wolf, 2021/06/30
- [PULL 10/24] block: bdrv_reopen_parse_backing(): simplify handling implicit filters, Kevin Wolf, 2021/06/30
- [PULL 09/24] block: bdrv_reopen_parse_backing(): don't check frozen child, Kevin Wolf, 2021/06/30
- [PULL 12/24] block: BDRVReopenState: drop replace_backing_bs field, Kevin Wolf, 2021/06/30
- [PULL 04/24] block: rename bdrv_replace_child to bdrv_replace_child_tran, Kevin Wolf, 2021/06/30
- [PULL 13/24] block: Allow changing bs->file on reopen, Kevin Wolf, 2021/06/30