mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge tag 'for-upstream' of git://repo.or.cz/qemu/kevin into staging
Block layer patches - job: replace AioContext lock with job_mutex - Fixes to make coroutine_fn annotations more accurate - QAPI schema: Fix incorrect example - Code cleanup # -----BEGIN PGP SIGNATURE----- # # iQJFBAABCAAvFiEE3D3rFZqa+V09dFb+fwmycsiPL9YFAmNAAz8RHGt3b2xmQHJl # ZGhhdC5jb20ACgkQfwmycsiPL9a6zg//QYLx+FYMStb50lS+6VBio8AKOVbwn5zp # ZANoXinMknnxI5wTldjkkM1cBRg27BVjpOHz4XemBtQgT5nBqWq8+Ov31lwASVID # na/L9o4Pa0xmywM777K+edceWk0fpJTLmnFf1Qxan9qB/VSjNFtk+fjwFopoatKg # XbHd6maQtrY8bIOyBsBoZozNaS39E/uPqkP67V6GF09re17f0PBctGHKFkTKZr8w # 2HfyMt8/UIhFet++NFgxppTcvIKfZ20pk4AQ+yYsL+FxWr/cs4leKWl5BSc7thtP # Sm/y0WiEB4nPNo4CSf9sA1Vo8EIGYzBhUVteqYQUF2vSXSzFmZb191fLJRYwp5bQ # QxEmHzPVGqcUHr+jkfXI0yLolWduiKV1ATZ0zW3N41VfzGLYZdSgI2ZhbHJ0/yKO # ZhyC63gye9V6TXxviYIz2V6iOD8QuwJ8X1P0E3yRsGploF1UY/N1lwbmek1XhFn/ # +xn/mrTeV0lu4wKuWRpUfY2C/7SR0Za6MB2GqduRWnbcAonLH3/syAxXSfu2611N # Z1Cf9Wu8Mm0IQz0LbbVvEJZ4yoEPkg/tGH8q6dpau2uTfCb6sSylRxLcXEa5R0UQ # W+wX5GSoTDe4DQKOSaJE7jWV/QwY5diTLHBIvSF8uKAfeCenkDDLowrMvbWafL0X # XTFzpZ/1aA8= # =jMFT # -----END PGP SIGNATURE----- # gpg: Signature made Fri 07 Oct 2022 06:45:19 EDT # gpg: using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6 # gpg: issuer "kwolf@redhat.com" # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full] # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * tag 'for-upstream' of git://repo.or.cz/qemu/kevin: (50 commits) file-posix: Remove unused s->discard_zeroes job: remove unused functions blockjob: remove unused functions block_job_query: remove atomic read job.c: enable job lock/unlock and remove Aiocontext locks job.h: categorize JobDriver callbacks that need the AioContext lock blockjob: protect iostatus field in BlockJob struct blockjob: rename notifier callbacks as _locked blockjob.h: categorize fields in struct BlockJob jobs: protect job.aio_context with BQL and job_mutex job: detect change of aiocontext within job coroutine jobs: group together API calls under the same job lock block/mirror.c: use of job helpers in drivers jobs: use job locks also in the unit tests jobs: add job lock in find_* functions blockjob: introduce block_job _locked() APIs job: move and update comments from blockjob.c job.c: add job_lock/unlock while keeping job.h intact aio-wait.h: introduce AIO_WAIT_WHILE_UNLOCKED job.c: API functions not used outside should be static ... Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
@@ -631,9 +631,10 @@ static int64_t create_file_fallback_truncate(BlockBackend *blk,
|
||||
* Helper function for bdrv_create_file_fallback(): Zero the first
|
||||
* sector to remove any potentially pre-existing image header.
|
||||
*/
|
||||
static int create_file_fallback_zero_first_sector(BlockBackend *blk,
|
||||
int64_t current_size,
|
||||
Error **errp)
|
||||
static int coroutine_fn
|
||||
create_file_fallback_zero_first_sector(BlockBackend *blk,
|
||||
int64_t current_size,
|
||||
Error **errp)
|
||||
{
|
||||
int64_t bytes_to_clear;
|
||||
int ret;
|
||||
@@ -4980,8 +4981,8 @@ static void bdrv_close(BlockDriverState *bs)
|
||||
|
||||
void bdrv_close_all(void)
|
||||
{
|
||||
assert(job_next(NULL) == NULL);
|
||||
GLOBAL_STATE_CODE();
|
||||
assert(job_next(NULL) == NULL);
|
||||
|
||||
/* Drop references from requests still in flight, such as canceled block
|
||||
* jobs whose AIO context has not been polled yet */
|
||||
@@ -6167,13 +6168,16 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **errp)
|
||||
}
|
||||
}
|
||||
|
||||
for (job = block_job_next(NULL); job; job = block_job_next(job)) {
|
||||
GSList *el;
|
||||
WITH_JOB_LOCK_GUARD() {
|
||||
for (job = block_job_next_locked(NULL); job;
|
||||
job = block_job_next_locked(job)) {
|
||||
GSList *el;
|
||||
|
||||
xdbg_graph_add_node(gr, job, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_JOB,
|
||||
job->job.id);
|
||||
for (el = job->nodes; el; el = el->next) {
|
||||
xdbg_graph_add_edge(gr, job, (BdrvChild *)el->data);
|
||||
xdbg_graph_add_node(gr, job, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_JOB,
|
||||
job->job.id);
|
||||
for (el = job->nodes; el; el = el->next) {
|
||||
xdbg_graph_add_edge(gr, job, (BdrvChild *)el->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -258,7 +258,7 @@ blkverify_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
return blkverify_co_prwv(bs, &r, offset, bytes, qiov, qiov, flags, true);
|
||||
}
|
||||
|
||||
static int blkverify_co_flush(BlockDriverState *bs)
|
||||
static int coroutine_fn blkverify_co_flush(BlockDriverState *bs)
|
||||
{
|
||||
BDRVBlkverifyState *s = bs->opaque;
|
||||
|
||||
|
||||
@@ -1546,7 +1546,7 @@ static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset,
|
||||
return &acb->common;
|
||||
}
|
||||
|
||||
static void blk_aio_read_entry(void *opaque)
|
||||
static void coroutine_fn blk_aio_read_entry(void *opaque)
|
||||
{
|
||||
BlkAioEmAIOCB *acb = opaque;
|
||||
BlkRwCo *rwco = &acb->rwco;
|
||||
@@ -1558,7 +1558,7 @@ static void blk_aio_read_entry(void *opaque)
|
||||
blk_aio_complete(acb);
|
||||
}
|
||||
|
||||
static void blk_aio_write_entry(void *opaque)
|
||||
static void coroutine_fn blk_aio_write_entry(void *opaque)
|
||||
{
|
||||
BlkAioEmAIOCB *acb = opaque;
|
||||
BlkRwCo *rwco = &acb->rwco;
|
||||
@@ -1669,7 +1669,7 @@ int coroutine_fn blk_co_ioctl(BlockBackend *blk, unsigned long int req,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void blk_aio_ioctl_entry(void *opaque)
|
||||
static void coroutine_fn blk_aio_ioctl_entry(void *opaque)
|
||||
{
|
||||
BlkAioEmAIOCB *acb = opaque;
|
||||
BlkRwCo *rwco = &acb->rwco;
|
||||
@@ -1703,7 +1703,7 @@ blk_co_do_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes)
|
||||
return bdrv_co_pdiscard(blk->root, offset, bytes);
|
||||
}
|
||||
|
||||
static void blk_aio_pdiscard_entry(void *opaque)
|
||||
static void coroutine_fn blk_aio_pdiscard_entry(void *opaque)
|
||||
{
|
||||
BlkAioEmAIOCB *acb = opaque;
|
||||
BlkRwCo *rwco = &acb->rwco;
|
||||
@@ -1747,7 +1747,7 @@ static int coroutine_fn blk_co_do_flush(BlockBackend *blk)
|
||||
return bdrv_co_flush(blk_bs(blk));
|
||||
}
|
||||
|
||||
static void blk_aio_flush_entry(void *opaque)
|
||||
static void coroutine_fn blk_aio_flush_entry(void *opaque)
|
||||
{
|
||||
BlkAioEmAIOCB *acb = opaque;
|
||||
BlkRwCo *rwco = &acb->rwco;
|
||||
|
||||
@@ -203,9 +203,9 @@ static int coroutine_fn cbw_co_flush(BlockDriverState *bs)
|
||||
* It's guaranteed that guest writes will not interact in the region until
|
||||
* cbw_snapshot_read_unlock() called.
|
||||
*/
|
||||
static BlockReq *cbw_snapshot_read_lock(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes,
|
||||
int64_t *pnum, BdrvChild **file)
|
||||
static coroutine_fn BlockReq *
|
||||
cbw_snapshot_read_lock(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
int64_t *pnum, BdrvChild **file)
|
||||
{
|
||||
BDRVCopyBeforeWriteState *s = bs->opaque;
|
||||
BlockReq *req = g_new(BlockReq, 1);
|
||||
@@ -240,7 +240,8 @@ static BlockReq *cbw_snapshot_read_lock(BlockDriverState *bs,
|
||||
return req;
|
||||
}
|
||||
|
||||
static void cbw_snapshot_read_unlock(BlockDriverState *bs, BlockReq *req)
|
||||
static coroutine_fn void
|
||||
cbw_snapshot_read_unlock(BlockDriverState *bs, BlockReq *req)
|
||||
{
|
||||
BDRVCopyBeforeWriteState *s = bs->opaque;
|
||||
|
||||
|
||||
+1
-1
@@ -855,7 +855,7 @@ out_noclean:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static void curl_setup_preadv(BlockDriverState *bs, CURLAIOCB *acb)
|
||||
static void coroutine_fn curl_setup_preadv(BlockDriverState *bs, CURLAIOCB *acb)
|
||||
{
|
||||
CURLState *state;
|
||||
int running;
|
||||
|
||||
+1
-10
@@ -154,7 +154,6 @@ typedef struct BDRVRawState {
|
||||
|
||||
bool has_discard:1;
|
||||
bool has_write_zeroes:1;
|
||||
bool discard_zeroes:1;
|
||||
bool use_linux_aio:1;
|
||||
bool use_linux_io_uring:1;
|
||||
int page_cache_inconsistent; /* errno from fdatasync failure */
|
||||
@@ -755,7 +754,6 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
|
||||
ret = -EINVAL;
|
||||
goto fail;
|
||||
} else {
|
||||
s->discard_zeroes = true;
|
||||
s->has_fallocate = true;
|
||||
}
|
||||
} else {
|
||||
@@ -769,19 +767,12 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
|
||||
}
|
||||
|
||||
if (S_ISBLK(st.st_mode)) {
|
||||
#ifdef BLKDISCARDZEROES
|
||||
unsigned int arg;
|
||||
if (ioctl(s->fd, BLKDISCARDZEROES, &arg) == 0 && arg) {
|
||||
s->discard_zeroes = true;
|
||||
}
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
/* On Linux 3.10, BLKDISCARD leaves stale data in the page cache. Do
|
||||
* not rely on the contents of discarded blocks unless using O_DIRECT.
|
||||
* Same for BLKZEROOUT.
|
||||
*/
|
||||
if (!(bs->open_flags & BDRV_O_NOCACHE)) {
|
||||
s->discard_zeroes = false;
|
||||
s->has_write_zeroes = false;
|
||||
}
|
||||
#endif
|
||||
@@ -2180,7 +2171,7 @@ static void raw_aio_unplug(BlockDriverState *bs)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int raw_co_flush_to_disk(BlockDriverState *bs)
|
||||
static int coroutine_fn raw_co_flush_to_disk(BlockDriverState *bs)
|
||||
{
|
||||
BDRVRawState *s = bs->opaque;
|
||||
RawPosixAIOData acb;
|
||||
|
||||
+11
-11
@@ -751,11 +751,11 @@ static void coroutine_fn tracked_request_end(BdrvTrackedRequest *req)
|
||||
/**
|
||||
* Add an active request to the tracked requests list
|
||||
*/
|
||||
static void tracked_request_begin(BdrvTrackedRequest *req,
|
||||
BlockDriverState *bs,
|
||||
int64_t offset,
|
||||
int64_t bytes,
|
||||
enum BdrvTrackedRequestType type)
|
||||
static void coroutine_fn tracked_request_begin(BdrvTrackedRequest *req,
|
||||
BlockDriverState *bs,
|
||||
int64_t offset,
|
||||
int64_t bytes,
|
||||
enum BdrvTrackedRequestType type)
|
||||
{
|
||||
bdrv_check_request(offset, bytes, &error_abort);
|
||||
|
||||
@@ -794,7 +794,7 @@ static bool tracked_request_overlaps(BdrvTrackedRequest *req,
|
||||
}
|
||||
|
||||
/* Called with self->bs->reqs_lock held */
|
||||
static BdrvTrackedRequest *
|
||||
static coroutine_fn BdrvTrackedRequest *
|
||||
bdrv_find_conflicting_request(BdrvTrackedRequest *self)
|
||||
{
|
||||
BdrvTrackedRequest *req;
|
||||
@@ -1635,10 +1635,10 @@ static bool bdrv_init_padding(BlockDriverState *bs,
|
||||
return true;
|
||||
}
|
||||
|
||||
static int bdrv_padding_rmw_read(BdrvChild *child,
|
||||
BdrvTrackedRequest *req,
|
||||
BdrvRequestPadding *pad,
|
||||
bool zero_middle)
|
||||
static coroutine_fn int bdrv_padding_rmw_read(BdrvChild *child,
|
||||
BdrvTrackedRequest *req,
|
||||
BdrvRequestPadding *pad,
|
||||
bool zero_middle)
|
||||
{
|
||||
QEMUIOVector local_qiov;
|
||||
BlockDriverState *bs = child->bs;
|
||||
@@ -3159,7 +3159,7 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf)
|
||||
int coroutine_fn bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf)
|
||||
{
|
||||
BlockDriver *drv = bs->drv;
|
||||
CoroutineIOCompletion co = {
|
||||
|
||||
+2
-1
@@ -290,7 +290,8 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int status,
|
||||
}
|
||||
}
|
||||
|
||||
static void iscsi_co_init_iscsitask(IscsiLun *iscsilun, struct IscsiTask *iTask)
|
||||
static void coroutine_fn
|
||||
iscsi_co_init_iscsitask(IscsiLun *iscsilun, struct IscsiTask *iTask)
|
||||
{
|
||||
*iTask = (struct IscsiTask) {
|
||||
.co = qemu_coroutine_self(),
|
||||
|
||||
+14
-5
@@ -894,6 +894,7 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
|
||||
BlockDriverState *bs = s->mirror_top_bs->backing->bs;
|
||||
BlockDriverState *target_bs = blk_bs(s->target);
|
||||
bool need_drain = true;
|
||||
BlockDeviceIoStatus iostatus;
|
||||
int64_t length;
|
||||
int64_t target_length;
|
||||
BlockDriverInfo bdi;
|
||||
@@ -1016,8 +1017,11 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
|
||||
* We do so every BLKOCK_JOB_SLICE_TIME nanoseconds, or when there is
|
||||
* an error, or when the source is clean, whichever comes first. */
|
||||
delta = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->last_pause_ns;
|
||||
WITH_JOB_LOCK_GUARD() {
|
||||
iostatus = s->common.iostatus;
|
||||
}
|
||||
if (delta < BLOCK_JOB_SLICE_TIME &&
|
||||
s->common.iostatus == BLOCK_DEVICE_IO_STATUS_OK) {
|
||||
iostatus == BLOCK_DEVICE_IO_STATUS_OK) {
|
||||
if (s->in_flight >= MAX_IN_FLIGHT || s->buf_free_count == 0 ||
|
||||
(cnt == 0 && s->in_flight > 0)) {
|
||||
trace_mirror_yield(s, cnt, s->buf_free_count, s->in_flight);
|
||||
@@ -1152,8 +1156,10 @@ static void mirror_complete(Job *job, Error **errp)
|
||||
s->should_complete = true;
|
||||
|
||||
/* If the job is paused, it will be re-entered when it is resumed */
|
||||
if (!job->paused) {
|
||||
job_enter(job);
|
||||
WITH_JOB_LOCK_GUARD() {
|
||||
if (!job->paused) {
|
||||
job_enter_cond_locked(job, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1173,8 +1179,11 @@ static bool mirror_drained_poll(BlockJob *job)
|
||||
* from one of our own drain sections, to avoid a deadlock waiting for
|
||||
* ourselves.
|
||||
*/
|
||||
if (!s->common.job.paused && !job_is_cancelled(&job->job) && !s->in_drain) {
|
||||
return true;
|
||||
WITH_JOB_LOCK_GUARD() {
|
||||
if (!s->common.job.paused && !job_is_cancelled_locked(&job->job)
|
||||
&& !s->in_drain) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return !!s->in_flight;
|
||||
|
||||
+6
-5
@@ -983,11 +983,12 @@ static void nbd_iter_request_error(NBDReplyChunkIter *iter, int ret)
|
||||
* nbd_reply_chunk_iter_receive
|
||||
* The pointer stored in @payload requires g_free() to free it.
|
||||
*/
|
||||
static bool nbd_reply_chunk_iter_receive(BDRVNBDState *s,
|
||||
NBDReplyChunkIter *iter,
|
||||
uint64_t handle,
|
||||
QEMUIOVector *qiov, NBDReply *reply,
|
||||
void **payload)
|
||||
static bool coroutine_fn nbd_reply_chunk_iter_receive(BDRVNBDState *s,
|
||||
NBDReplyChunkIter *iter,
|
||||
uint64_t handle,
|
||||
QEMUIOVector *qiov,
|
||||
NBDReply *reply,
|
||||
void **payload)
|
||||
{
|
||||
int ret, request_ret;
|
||||
NBDReply local_reply;
|
||||
|
||||
+1
-1
@@ -223,7 +223,7 @@ static void nfs_process_write(void *arg)
|
||||
qemu_mutex_unlock(&client->mutex);
|
||||
}
|
||||
|
||||
static void nfs_co_init_task(BlockDriverState *bs, NFSRPC *task)
|
||||
static void coroutine_fn nfs_co_init_task(BlockDriverState *bs, NFSRPC *task)
|
||||
{
|
||||
*task = (NFSRPC) {
|
||||
.co = qemu_coroutine_self(),
|
||||
|
||||
+32
-22
@@ -293,34 +293,42 @@ static void nvme_kick(NVMeQueuePair *q)
|
||||
q->need_kick = 0;
|
||||
}
|
||||
|
||||
/* Find a free request element if any, otherwise:
|
||||
* a) if in coroutine context, try to wait for one to become available;
|
||||
* b) if not in coroutine, return NULL;
|
||||
*/
|
||||
static NVMeRequest *nvme_get_free_req(NVMeQueuePair *q)
|
||||
static NVMeRequest *nvme_get_free_req_nofail_locked(NVMeQueuePair *q)
|
||||
{
|
||||
NVMeRequest *req;
|
||||
|
||||
qemu_mutex_lock(&q->lock);
|
||||
|
||||
while (q->free_req_head == -1) {
|
||||
if (qemu_in_coroutine()) {
|
||||
trace_nvme_free_req_queue_wait(q->s, q->index);
|
||||
qemu_co_queue_wait(&q->free_req_queue, &q->lock);
|
||||
} else {
|
||||
qemu_mutex_unlock(&q->lock);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
req = &q->reqs[q->free_req_head];
|
||||
q->free_req_head = req->free_req_next;
|
||||
req->free_req_next = -1;
|
||||
|
||||
qemu_mutex_unlock(&q->lock);
|
||||
return req;
|
||||
}
|
||||
|
||||
/* Return a free request element if any, otherwise return NULL. */
|
||||
static NVMeRequest *nvme_get_free_req_nowait(NVMeQueuePair *q)
|
||||
{
|
||||
QEMU_LOCK_GUARD(&q->lock);
|
||||
if (q->free_req_head == -1) {
|
||||
return NULL;
|
||||
}
|
||||
return nvme_get_free_req_nofail_locked(q);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait for a free request to become available if necessary, then
|
||||
* return it.
|
||||
*/
|
||||
static coroutine_fn NVMeRequest *nvme_get_free_req(NVMeQueuePair *q)
|
||||
{
|
||||
QEMU_LOCK_GUARD(&q->lock);
|
||||
|
||||
while (q->free_req_head == -1) {
|
||||
trace_nvme_free_req_queue_wait(q->s, q->index);
|
||||
qemu_co_queue_wait(&q->free_req_queue, &q->lock);
|
||||
}
|
||||
|
||||
return nvme_get_free_req_nofail_locked(q);
|
||||
}
|
||||
|
||||
/* With q->lock */
|
||||
static void nvme_put_free_req_locked(NVMeQueuePair *q, NVMeRequest *req)
|
||||
{
|
||||
@@ -506,7 +514,7 @@ static int nvme_admin_cmd_sync(BlockDriverState *bs, NvmeCmd *cmd)
|
||||
AioContext *aio_context = bdrv_get_aio_context(bs);
|
||||
NVMeRequest *req;
|
||||
int ret = -EINPROGRESS;
|
||||
req = nvme_get_free_req(q);
|
||||
req = nvme_get_free_req_nowait(q);
|
||||
if (!req) {
|
||||
return -EBUSY;
|
||||
}
|
||||
@@ -1234,8 +1242,10 @@ static inline bool nvme_qiov_aligned(BlockDriverState *bs,
|
||||
return true;
|
||||
}
|
||||
|
||||
static int nvme_co_prw(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
|
||||
QEMUIOVector *qiov, bool is_write, int flags)
|
||||
static coroutine_fn int nvme_co_prw(BlockDriverState *bs,
|
||||
uint64_t offset, uint64_t bytes,
|
||||
QEMUIOVector *qiov, bool is_write,
|
||||
int flags)
|
||||
{
|
||||
BDRVNVMeState *s = bs->opaque;
|
||||
int r;
|
||||
|
||||
+3
-2
@@ -165,8 +165,9 @@ static int64_t block_status(BDRVParallelsState *s, int64_t sector_num,
|
||||
return start_off;
|
||||
}
|
||||
|
||||
static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num,
|
||||
int nb_sectors, int *pnum)
|
||||
static coroutine_fn int64_t allocate_clusters(BlockDriverState *bs,
|
||||
int64_t sector_num,
|
||||
int nb_sectors, int *pnum)
|
||||
{
|
||||
int ret = 0;
|
||||
BDRVParallelsState *s = bs->opaque;
|
||||
|
||||
+12
-9
@@ -884,7 +884,7 @@ int qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int perform_cow(BlockDriverState *bs, QCowL2Meta *m)
|
||||
static int coroutine_fn perform_cow(BlockDriverState *bs, QCowL2Meta *m)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
Qcow2COWRegion *start = &m->cow_start;
|
||||
@@ -1024,7 +1024,8 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
|
||||
int coroutine_fn qcow2_alloc_cluster_link_l2(BlockDriverState *bs,
|
||||
QCowL2Meta *m)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
int i, j = 0, l2_index, ret;
|
||||
@@ -1397,8 +1398,9 @@ static int count_single_write_clusters(BlockDriverState *bs, int nb_clusters,
|
||||
* information on cluster allocation may be invalid now. The caller
|
||||
* must start over anyway, so consider *cur_bytes undefined.
|
||||
*/
|
||||
static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset,
|
||||
uint64_t *cur_bytes, QCowL2Meta **m)
|
||||
static int coroutine_fn handle_dependencies(BlockDriverState *bs,
|
||||
uint64_t guest_offset,
|
||||
uint64_t *cur_bytes, QCowL2Meta **m)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
QCowL2Meta *old_alloc;
|
||||
@@ -1772,9 +1774,10 @@ out:
|
||||
*
|
||||
* Return 0 on success and -errno in error cases
|
||||
*/
|
||||
int qcow2_alloc_host_offset(BlockDriverState *bs, uint64_t offset,
|
||||
unsigned int *bytes, uint64_t *host_offset,
|
||||
QCowL2Meta **m)
|
||||
int coroutine_fn qcow2_alloc_host_offset(BlockDriverState *bs, uint64_t offset,
|
||||
unsigned int *bytes,
|
||||
uint64_t *host_offset,
|
||||
QCowL2Meta **m)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
uint64_t start, remaining;
|
||||
@@ -2105,8 +2108,8 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int qcow2_subcluster_zeroize(BlockDriverState *bs, uint64_t offset,
|
||||
uint64_t bytes, int flags)
|
||||
int coroutine_fn qcow2_subcluster_zeroize(BlockDriverState *bs, uint64_t offset,
|
||||
uint64_t bytes, int flags)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
uint64_t end_offset = offset + bytes;
|
||||
|
||||
@@ -1206,7 +1206,7 @@ void qcow2_free_any_cluster(BlockDriverState *bs, uint64_t l2_entry,
|
||||
}
|
||||
}
|
||||
|
||||
int coroutine_fn qcow2_write_caches(BlockDriverState *bs)
|
||||
int qcow2_write_caches(BlockDriverState *bs)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
int ret;
|
||||
@@ -1226,7 +1226,7 @@ int coroutine_fn qcow2_write_caches(BlockDriverState *bs)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int coroutine_fn qcow2_flush_caches(BlockDriverState *bs)
|
||||
int qcow2_flush_caches(BlockDriverState *bs)
|
||||
{
|
||||
int ret = qcow2_write_caches(bs);
|
||||
if (ret < 0) {
|
||||
@@ -3706,7 +3706,7 @@ int64_t qcow2_get_last_cluster(BlockDriverState *bs, int64_t size)
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
int qcow2_detect_metadata_preallocation(BlockDriverState *bs)
|
||||
int coroutine_fn qcow2_detect_metadata_preallocation(BlockDriverState *bs)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
int64_t i, end_cluster, cluster_count = 0, threshold;
|
||||
|
||||
+3
-2
@@ -2448,7 +2448,7 @@ static bool merge_cow(uint64_t offset, unsigned bytes,
|
||||
* Return 1 if the COW regions read as zeroes, 0 if not, < 0 on error.
|
||||
* Note that returning 0 does not guarantee non-zero data.
|
||||
*/
|
||||
static int is_zero_cow(BlockDriverState *bs, QCowL2Meta *m)
|
||||
static int coroutine_fn is_zero_cow(BlockDriverState *bs, QCowL2Meta *m)
|
||||
{
|
||||
/*
|
||||
* This check is designed for optimization shortcut so it must be
|
||||
@@ -2466,7 +2466,8 @@ static int is_zero_cow(BlockDriverState *bs, QCowL2Meta *m)
|
||||
m->cow_end.nb_bytes);
|
||||
}
|
||||
|
||||
static int handle_alloc_space(BlockDriverState *bs, QCowL2Meta *l2meta)
|
||||
static int coroutine_fn handle_alloc_space(BlockDriverState *bs,
|
||||
QCowL2Meta *l2meta)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
QCowL2Meta *m;
|
||||
|
||||
+10
-9
@@ -874,8 +874,8 @@ void qcow2_free_any_cluster(BlockDriverState *bs, uint64_t l2_entry,
|
||||
int qcow2_update_snapshot_refcount(BlockDriverState *bs,
|
||||
int64_t l1_table_offset, int l1_size, int addend);
|
||||
|
||||
int coroutine_fn qcow2_flush_caches(BlockDriverState *bs);
|
||||
int coroutine_fn qcow2_write_caches(BlockDriverState *bs);
|
||||
int qcow2_flush_caches(BlockDriverState *bs);
|
||||
int qcow2_write_caches(BlockDriverState *bs);
|
||||
int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
|
||||
BdrvCheckMode fix);
|
||||
|
||||
@@ -895,7 +895,7 @@ int qcow2_change_refcount_order(BlockDriverState *bs, int refcount_order,
|
||||
void *cb_opaque, Error **errp);
|
||||
int qcow2_shrink_reftable(BlockDriverState *bs);
|
||||
int64_t qcow2_get_last_cluster(BlockDriverState *bs, int64_t size);
|
||||
int qcow2_detect_metadata_preallocation(BlockDriverState *bs);
|
||||
int coroutine_fn qcow2_detect_metadata_preallocation(BlockDriverState *bs);
|
||||
|
||||
/* qcow2-cluster.c functions */
|
||||
int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,
|
||||
@@ -908,9 +908,9 @@ int qcow2_encrypt_sectors(BDRVQcow2State *s, int64_t sector_num,
|
||||
int qcow2_get_host_offset(BlockDriverState *bs, uint64_t offset,
|
||||
unsigned int *bytes, uint64_t *host_offset,
|
||||
QCow2SubclusterType *subcluster_type);
|
||||
int qcow2_alloc_host_offset(BlockDriverState *bs, uint64_t offset,
|
||||
unsigned int *bytes, uint64_t *host_offset,
|
||||
QCowL2Meta **m);
|
||||
int coroutine_fn qcow2_alloc_host_offset(BlockDriverState *bs, uint64_t offset,
|
||||
unsigned int *bytes,
|
||||
uint64_t *host_offset, QCowL2Meta **m);
|
||||
int qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
|
||||
uint64_t offset,
|
||||
int compressed_size,
|
||||
@@ -918,13 +918,14 @@ int qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
|
||||
void qcow2_parse_compressed_l2_entry(BlockDriverState *bs, uint64_t l2_entry,
|
||||
uint64_t *coffset, int *csize);
|
||||
|
||||
int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m);
|
||||
int coroutine_fn qcow2_alloc_cluster_link_l2(BlockDriverState *bs,
|
||||
QCowL2Meta *m);
|
||||
void qcow2_alloc_cluster_abort(BlockDriverState *bs, QCowL2Meta *m);
|
||||
int qcow2_cluster_discard(BlockDriverState *bs, uint64_t offset,
|
||||
uint64_t bytes, enum qcow2_discard_type type,
|
||||
bool full_discard);
|
||||
int qcow2_subcluster_zeroize(BlockDriverState *bs, uint64_t offset,
|
||||
uint64_t bytes, int flags);
|
||||
int coroutine_fn qcow2_subcluster_zeroize(BlockDriverState *bs, uint64_t offset,
|
||||
uint64_t bytes, int flags);
|
||||
|
||||
int qcow2_expand_zero_clusters(BlockDriverState *bs,
|
||||
BlockDriverAmendStatusCB *status_cb,
|
||||
|
||||
+2
-2
@@ -254,7 +254,7 @@ static CachedL2Table *qed_new_l2_table(BDRVQEDState *s)
|
||||
return l2_table;
|
||||
}
|
||||
|
||||
static bool qed_plug_allocating_write_reqs(BDRVQEDState *s)
|
||||
static bool coroutine_fn qed_plug_allocating_write_reqs(BDRVQEDState *s)
|
||||
{
|
||||
qemu_co_mutex_lock(&s->table_lock);
|
||||
|
||||
@@ -273,7 +273,7 @@ static bool qed_plug_allocating_write_reqs(BDRVQEDState *s)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void qed_unplug_allocating_write_reqs(BDRVQEDState *s)
|
||||
static void coroutine_fn qed_unplug_allocating_write_reqs(BDRVQEDState *s)
|
||||
{
|
||||
qemu_co_mutex_lock(&s->table_lock);
|
||||
assert(s->allocating_write_reqs_plugged);
|
||||
|
||||
+19
-19
@@ -161,11 +161,10 @@ static bool quorum_64bits_compare(QuorumVoteValue *a, QuorumVoteValue *b)
|
||||
return a->l == b->l;
|
||||
}
|
||||
|
||||
static QuorumAIOCB *quorum_aio_get(BlockDriverState *bs,
|
||||
QEMUIOVector *qiov,
|
||||
uint64_t offset,
|
||||
uint64_t bytes,
|
||||
int flags)
|
||||
static QuorumAIOCB *coroutine_fn quorum_aio_get(BlockDriverState *bs,
|
||||
QEMUIOVector *qiov,
|
||||
uint64_t offset, uint64_t bytes,
|
||||
int flags)
|
||||
{
|
||||
BDRVQuorumState *s = bs->opaque;
|
||||
QuorumAIOCB *acb = g_new(QuorumAIOCB, 1);
|
||||
@@ -233,8 +232,6 @@ static bool quorum_has_too_much_io_failed(QuorumAIOCB *acb)
|
||||
return false;
|
||||
}
|
||||
|
||||
static int read_fifo_child(QuorumAIOCB *acb);
|
||||
|
||||
static void quorum_copy_qiov(QEMUIOVector *dest, QEMUIOVector *source)
|
||||
{
|
||||
int i;
|
||||
@@ -273,7 +270,7 @@ static void quorum_report_bad_versions(BDRVQuorumState *s,
|
||||
}
|
||||
}
|
||||
|
||||
static void quorum_rewrite_entry(void *opaque)
|
||||
static void coroutine_fn quorum_rewrite_entry(void *opaque)
|
||||
{
|
||||
QuorumCo *co = opaque;
|
||||
QuorumAIOCB *acb = co->acb;
|
||||
@@ -574,7 +571,7 @@ free_exit:
|
||||
quorum_free_vote_list(&acb->votes);
|
||||
}
|
||||
|
||||
static void read_quorum_children_entry(void *opaque)
|
||||
static void coroutine_fn read_quorum_children_entry(void *opaque)
|
||||
{
|
||||
QuorumCo *co = opaque;
|
||||
QuorumAIOCB *acb = co->acb;
|
||||
@@ -602,7 +599,7 @@ static void read_quorum_children_entry(void *opaque)
|
||||
}
|
||||
}
|
||||
|
||||
static int read_quorum_children(QuorumAIOCB *acb)
|
||||
static int coroutine_fn read_quorum_children(QuorumAIOCB *acb)
|
||||
{
|
||||
BDRVQuorumState *s = acb->bs->opaque;
|
||||
int i;
|
||||
@@ -643,7 +640,7 @@ static int read_quorum_children(QuorumAIOCB *acb)
|
||||
return acb->vote_ret;
|
||||
}
|
||||
|
||||
static int read_fifo_child(QuorumAIOCB *acb)
|
||||
static int coroutine_fn read_fifo_child(QuorumAIOCB *acb)
|
||||
{
|
||||
BDRVQuorumState *s = acb->bs->opaque;
|
||||
int n, ret;
|
||||
@@ -664,8 +661,10 @@ static int read_fifo_child(QuorumAIOCB *acb)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int quorum_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
static int coroutine_fn quorum_co_preadv(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
BDRVQuorumState *s = bs->opaque;
|
||||
QuorumAIOCB *acb = quorum_aio_get(bs, qiov, offset, bytes, flags);
|
||||
@@ -684,7 +683,7 @@ static int quorum_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void write_quorum_entry(void *opaque)
|
||||
static void coroutine_fn write_quorum_entry(void *opaque)
|
||||
{
|
||||
QuorumCo *co = opaque;
|
||||
QuorumAIOCB *acb = co->acb;
|
||||
@@ -715,9 +714,9 @@ static void write_quorum_entry(void *opaque)
|
||||
}
|
||||
}
|
||||
|
||||
static int quorum_co_pwritev(BlockDriverState *bs, int64_t offset,
|
||||
int64_t bytes, QEMUIOVector *qiov,
|
||||
BdrvRequestFlags flags)
|
||||
static int coroutine_fn quorum_co_pwritev(BlockDriverState *bs, int64_t offset,
|
||||
int64_t bytes, QEMUIOVector *qiov,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
BDRVQuorumState *s = bs->opaque;
|
||||
QuorumAIOCB *acb = quorum_aio_get(bs, qiov, offset, bytes, flags);
|
||||
@@ -746,8 +745,9 @@ static int quorum_co_pwritev(BlockDriverState *bs, int64_t offset,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int quorum_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
|
||||
int64_t bytes, BdrvRequestFlags flags)
|
||||
static int coroutine_fn quorum_co_pwrite_zeroes(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes,
|
||||
BdrvRequestFlags flags)
|
||||
|
||||
{
|
||||
return quorum_co_pwritev(bs, offset, bytes, NULL,
|
||||
|
||||
+2
-1
@@ -411,7 +411,8 @@ static void raw_lock_medium(BlockDriverState *bs, bool locked)
|
||||
bdrv_lock_medium(bs->file->bs, locked);
|
||||
}
|
||||
|
||||
static int raw_co_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
|
||||
static int coroutine_fn raw_co_ioctl(BlockDriverState *bs,
|
||||
unsigned long int req, void *buf)
|
||||
{
|
||||
BDRVRawState *s = bs->opaque;
|
||||
if (s->offset || s->has_size) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user