nbd: Mark nbd_co_do_establish_connection() and callers GRAPH_RDLOCK
This adds GRAPH_RDLOCK annotations to declare that callers of nbd_co_do_establish_connection() need to hold a reader lock for the graph. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20230504115750.54437-11-kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
5d934513f8
commit
69aa0d371f
@ -61,7 +61,7 @@ bdrv_co_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos);
|
|||||||
int coroutine_fn GRAPH_RDLOCK
|
int coroutine_fn GRAPH_RDLOCK
|
||||||
bdrv_co_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos);
|
bdrv_co_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos);
|
||||||
|
|
||||||
int coroutine_fn
|
int coroutine_fn GRAPH_RDLOCK
|
||||||
nbd_co_do_establish_connection(BlockDriverState *bs, bool blocking,
|
nbd_co_do_establish_connection(BlockDriverState *bs, bool blocking,
|
||||||
Error **errp);
|
Error **errp);
|
||||||
|
|
||||||
@ -85,7 +85,8 @@ bdrv_common_block_status_above(BlockDriverState *bs,
|
|||||||
int64_t *map,
|
int64_t *map,
|
||||||
BlockDriverState **file,
|
BlockDriverState **file,
|
||||||
int *depth);
|
int *depth);
|
||||||
int co_wrapper_mixed
|
|
||||||
|
int co_wrapper_mixed_bdrv_rdlock
|
||||||
nbd_do_establish_connection(BlockDriverState *bs, bool blocking, Error **errp);
|
nbd_do_establish_connection(BlockDriverState *bs, bool blocking, Error **errp);
|
||||||
|
|
||||||
#endif /* BLOCK_COROUTINES_H */
|
#endif /* BLOCK_COROUTINES_H */
|
||||||
|
39
block/nbd.c
39
block/nbd.c
@ -322,6 +322,7 @@ int coroutine_fn nbd_co_do_establish_connection(BlockDriverState *bs,
|
|||||||
int ret;
|
int ret;
|
||||||
IO_CODE();
|
IO_CODE();
|
||||||
|
|
||||||
|
assert_bdrv_graph_readable();
|
||||||
assert(!s->ioc);
|
assert(!s->ioc);
|
||||||
|
|
||||||
s->ioc = nbd_co_establish_connection(s->conn, &s->info, blocking, errp);
|
s->ioc = nbd_co_establish_connection(s->conn, &s->info, blocking, errp);
|
||||||
@ -369,7 +370,7 @@ static bool nbd_client_connecting(BDRVNBDState *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Called with s->requests_lock taken. */
|
/* Called with s->requests_lock taken. */
|
||||||
static coroutine_fn void nbd_reconnect_attempt(BDRVNBDState *s)
|
static void coroutine_fn GRAPH_RDLOCK nbd_reconnect_attempt(BDRVNBDState *s)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
bool blocking = s->state == NBD_CLIENT_CONNECTING_WAIT;
|
bool blocking = s->state == NBD_CLIENT_CONNECTING_WAIT;
|
||||||
@ -480,9 +481,9 @@ static coroutine_fn int nbd_receive_replies(BDRVNBDState *s, uint64_t handle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn nbd_co_send_request(BlockDriverState *bs,
|
static int coroutine_fn GRAPH_RDLOCK
|
||||||
NBDRequest *request,
|
nbd_co_send_request(BlockDriverState *bs, NBDRequest *request,
|
||||||
QEMUIOVector *qiov)
|
QEMUIOVector *qiov)
|
||||||
{
|
{
|
||||||
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
|
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
|
||||||
int rc, i = -1;
|
int rc, i = -1;
|
||||||
@ -1171,8 +1172,9 @@ static int coroutine_fn nbd_co_receive_blockstatus_reply(BDRVNBDState *s,
|
|||||||
return iter.ret;
|
return iter.ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn nbd_co_request(BlockDriverState *bs, NBDRequest *request,
|
static int coroutine_fn GRAPH_RDLOCK
|
||||||
QEMUIOVector *write_qiov)
|
nbd_co_request(BlockDriverState *bs, NBDRequest *request,
|
||||||
|
QEMUIOVector *write_qiov)
|
||||||
{
|
{
|
||||||
int ret, request_ret;
|
int ret, request_ret;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
@ -1208,9 +1210,9 @@ static int coroutine_fn nbd_co_request(BlockDriverState *bs, NBDRequest *request
|
|||||||
return ret ? ret : request_ret;
|
return ret ? ret : request_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn nbd_client_co_preadv(BlockDriverState *bs, int64_t offset,
|
static int coroutine_fn GRAPH_RDLOCK
|
||||||
int64_t bytes, QEMUIOVector *qiov,
|
nbd_client_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||||
BdrvRequestFlags flags)
|
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||||
{
|
{
|
||||||
int ret, request_ret;
|
int ret, request_ret;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
@ -1266,9 +1268,9 @@ static int coroutine_fn nbd_client_co_preadv(BlockDriverState *bs, int64_t offse
|
|||||||
return ret ? ret : request_ret;
|
return ret ? ret : request_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn nbd_client_co_pwritev(BlockDriverState *bs, int64_t offset,
|
static int coroutine_fn GRAPH_RDLOCK
|
||||||
int64_t bytes, QEMUIOVector *qiov,
|
nbd_client_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||||
BdrvRequestFlags flags)
|
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||||
{
|
{
|
||||||
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
|
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
|
||||||
NBDRequest request = {
|
NBDRequest request = {
|
||||||
@ -1291,8 +1293,9 @@ static int coroutine_fn nbd_client_co_pwritev(BlockDriverState *bs, int64_t offs
|
|||||||
return nbd_co_request(bs, &request, qiov);
|
return nbd_co_request(bs, &request, qiov);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
|
static int coroutine_fn GRAPH_RDLOCK
|
||||||
int64_t bytes, BdrvRequestFlags flags)
|
nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||||
|
BdrvRequestFlags flags)
|
||||||
{
|
{
|
||||||
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
|
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
|
||||||
NBDRequest request = {
|
NBDRequest request = {
|
||||||
@ -1326,7 +1329,7 @@ static int coroutine_fn nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_
|
|||||||
return nbd_co_request(bs, &request, NULL);
|
return nbd_co_request(bs, &request, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn nbd_client_co_flush(BlockDriverState *bs)
|
static int coroutine_fn GRAPH_RDLOCK nbd_client_co_flush(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
|
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
|
||||||
NBDRequest request = { .type = NBD_CMD_FLUSH };
|
NBDRequest request = { .type = NBD_CMD_FLUSH };
|
||||||
@ -1341,8 +1344,8 @@ static int coroutine_fn nbd_client_co_flush(BlockDriverState *bs)
|
|||||||
return nbd_co_request(bs, &request, NULL);
|
return nbd_co_request(bs, &request, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset,
|
static int coroutine_fn GRAPH_RDLOCK
|
||||||
int64_t bytes)
|
nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||||
{
|
{
|
||||||
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
|
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
|
||||||
NBDRequest request = {
|
NBDRequest request = {
|
||||||
@ -1361,7 +1364,7 @@ static int coroutine_fn nbd_client_co_pdiscard(BlockDriverState *bs, int64_t off
|
|||||||
return nbd_co_request(bs, &request, NULL);
|
return nbd_co_request(bs, &request, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn nbd_client_co_block_status(
|
static int coroutine_fn GRAPH_RDLOCK nbd_client_co_block_status(
|
||||||
BlockDriverState *bs, bool want_zero, int64_t offset, int64_t bytes,
|
BlockDriverState *bs, bool want_zero, int64_t offset, int64_t bytes,
|
||||||
int64_t *pnum, int64_t *map, BlockDriverState **file)
|
int64_t *pnum, int64_t *map, BlockDriverState **file)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user