Skip to content

Commit

Permalink
qed: mark more functions as coroutine_fns and GRAPH_RDLOCK
Browse files Browse the repository at this point in the history
Mark functions as coroutine_fn when they are only called by other coroutine_fns
and they can suspend.  Change calls to co_wrappers to use the non-wrapped
functions, which in turn requires adding GRAPH_RDLOCK annotations.

Signed-off-by: Paolo Bonzini <[email protected]>
Message-ID: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
  • Loading branch information
bonzini authored and kevmw committed Jun 28, 2023
1 parent 36c6c87 commit bba667d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions block/qed-check.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ static void qed_check_for_leaks(QEDCheck *check)
/**
* Mark an image clean once it passes check or has been repaired
*/
static void qed_check_mark_clean(BDRVQEDState *s, BdrvCheckResult *result)
static void coroutine_fn GRAPH_RDLOCK
qed_check_mark_clean(BDRVQEDState *s, BdrvCheckResult *result)
{
/* Skip if there were unfixable corruptions or I/O errors */
if (result->corruptions > 0 || result->check_errors > 0) {
Expand All @@ -213,7 +214,7 @@ static void qed_check_mark_clean(BDRVQEDState *s, BdrvCheckResult *result)
}

/* Ensure fixes reach storage before clearing check bit */
bdrv_flush(s->bs);
bdrv_co_flush(s->bs);

s->header.features &= ~QED_F_NEED_CHECK;
qed_write_header_sync(s);
Expand Down
7 changes: 4 additions & 3 deletions block/qed.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,15 @@ static bool qed_is_image_size_valid(uint64_t image_size, uint32_t cluster_size,
*
* The string is NUL-terminated.
*/
static int qed_read_string(BdrvChild *file, uint64_t offset, size_t n,
char *buf, size_t buflen)
static int coroutine_fn GRAPH_RDLOCK
qed_read_string(BdrvChild *file, uint64_t offset,
size_t n, char *buf, size_t buflen)
{
int ret;
if (n >= buflen) {
return -EINVAL;
}
ret = bdrv_pread(file, offset, n, buf, 0);
ret = bdrv_co_pread(file, offset, n, buf, 0);
if (ret < 0) {
return ret;
}
Expand Down

0 comments on commit bba667d

Please sign in to comment.