From nobody Tue Apr 8 17:37:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677178640; cv=none; d=zohomail.com; s=zohoarc; b=K0ko0LGfxAWJIf8QXmtPLRrPjI2Wq/q3OBLfUHremt6ml+wMJ7cxrhekWzDMHAj2RiBcBQ9gJ6aRTRJF3Iv1nJhOVn1oHu9KcEe1/thMmz1jWfPz5q2ks+8ECv4Z+HsHBg3b9weLcYu5UH/8DSikGxffGnHdOg8U5t8sUQFdWvk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677178640; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gZWadILoWUksiS0KjCZg8zbq9RgX0lVki/lMxezM3Gg=; b=R2mtRSCr3oNW/RZn04IfTh87Xr72PVB+tit0hzd7/v3tEVWyfkZ8eRW5Lx2uqrbp2G4iEAnLnObyKxRqjUwe3nNwRv/NFiTzCHdeSGxWlu43YAq+h6CMI+uEdRwRuH6+gUK7GrTh+OekAYH7MgXj1IZAZXC71yEOokN1+HU8vFs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677178640897996.1898175603874; Thu, 23 Feb 2023 10:57:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVGhP-0006r7-RH; Thu, 23 Feb 2023 13:52:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVGhM-0006p9-Ea for qemu-devel@nongnu.org; Thu, 23 Feb 2023 13:52:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVGhI-000364-HA for qemu-devel@nongnu.org; Thu, 23 Feb 2023 13:52:07 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-662-7iTi1N8-M--Kiwho4n0X2w-1; Thu, 23 Feb 2023 13:52:00 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E9A7B86C165; Thu, 23 Feb 2023 18:51:59 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.192.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42B231121314; Thu, 23 Feb 2023 18:51:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677178323; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gZWadILoWUksiS0KjCZg8zbq9RgX0lVki/lMxezM3Gg=; b=FWJGgLIcLjnX12HXyBimAAdRLJUBqaCp39AFRHSMSkt1DG3ndNpmgtl4GZVp7RiOqHVmBX vbllogUQ9KBYZL18q6PKL2lzVT0nxQPSDwgFAm26rWrjHEySrHm/fSDokNaLw75+fcscMX yVQbM/EsD4IJ8RxeoSmshfJ1KE0/Zqs= X-MC-Unique: 7iTi1N8-M--Kiwho4n0X2w-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [PULL 09/29] block: Mark bdrv_co_pwrite_zeroes() and callers GRAPH_RDLOCK Date: Thu, 23 Feb 2023 19:51:26 +0100 Message-Id: <20230223185146.306454-10-kwolf@redhat.com> In-Reply-To: <20230223185146.306454-1-kwolf@redhat.com> References: <20230223185146.306454-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677178642194100005 Content-Type: text/plain; charset="utf-8" This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_co_pwrite_zeroes() need to hold a reader lock for the graph. For some places, we know that they will hold the lock, but we don't have the GRAPH_RDLOCK annotations yet. In this case, add assume_graph_lock() with a FIXME comment. These places will be removed once everything is properly annotated. Signed-off-by: Kevin Wolf Message-Id: <20230203152202.49054-10-kwolf@redhat.com> Reviewed-by: Emanuele Giuseppe Esposito Signed-off-by: Kevin Wolf --- block/qcow2.h | 6 ++++-- include/block/block-io.h | 9 +++++---- include/block/block_int-common.h | 5 +++-- block/blkdebug.c | 6 +++--- block/blklogwrites.c | 5 ++--- block/blkreplay.c | 5 +++-- block/block-copy.c | 13 +++++++------ block/copy-before-write.c | 5 +++-- block/copy-on-read.c | 6 +++--- block/filter-compress.c | 6 +++--- block/io.c | 12 +++++++++--- block/mirror.c | 6 +++--- block/preallocate.c | 11 +++++++---- block/qcow2.c | 30 ++++++++++++++++++------------ block/qed.c | 9 +++------ block/quorum.c | 15 ++++++++++----- block/raw-format.c | 6 +++--- block/throttle.c | 6 +++--- 18 files changed, 92 insertions(+), 69 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 7a02699bfa..82cd1664cf 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -927,8 +927,10 @@ void qcow2_alloc_cluster_abort(BlockDriverState *bs, Q= CowL2Meta *m); int qcow2_cluster_discard(BlockDriverState *bs, uint64_t offset, uint64_t bytes, enum qcow2_discard_type type, bool full_discard); -int coroutine_fn qcow2_subcluster_zeroize(BlockDriverState *bs, uint64_t o= ffset, - uint64_t bytes, int flags); + +int coroutine_fn GRAPH_RDLOCK +qcow2_subcluster_zeroize(BlockDriverState *bs, uint64_t offset, uint64_t b= ytes, + int flags); =20 int qcow2_expand_zero_clusters(BlockDriverState *bs, BlockDriverAmendStatusCB *status_cb, diff --git a/include/block/block-io.h b/include/block/block-io.h index 627061fd5f..ec26f07d60 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -69,8 +69,9 @@ int coroutine_fn bdrv_co_pwrite_sync(BdrvChild *child, in= t64_t offset, * function is not suitable for zeroing the entire image in a single reque= st * because it may allocate memory for the entire region. */ -int coroutine_fn bdrv_co_pwrite_zeroes(BdrvChild *child, int64_t offset, - int64_t bytes, BdrvRequestFlags fla= gs); +int coroutine_fn GRAPH_RDLOCK +bdrv_co_pwrite_zeroes(BdrvChild *child, int64_t offset, int64_t bytes, + BdrvRequestFlags flags); =20 int coroutine_fn GRAPH_RDLOCK bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact, @@ -133,8 +134,8 @@ int bdrv_is_allocated_above(BlockDriverState *top, Bloc= kDriverState *base, bool include_base, int64_t offset, int64_t byt= es, int64_t *pnum); =20 -int coroutine_fn bdrv_co_is_zero_fast(BlockDriverState *bs, int64_t offset, - int64_t bytes); +int coroutine_fn GRAPH_RDLOCK +bdrv_co_is_zero_fast(BlockDriverState *bs, int64_t offset, int64_t bytes); =20 int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg, Error **errp); diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index c52190abdb..21b4cb1101 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -542,8 +542,9 @@ struct BlockDriver { * function pointer may be NULL or return -ENOSUP and .bdrv_co_writev() * will be called instead. */ - int coroutine_fn (*bdrv_co_pwrite_zeroes)(BlockDriverState *bs, - int64_t offset, int64_t bytes, BdrvRequestFlags flags); + int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_pwrite_zeroes)( + BlockDriverState *bs, int64_t offset, int64_t bytes, + BdrvRequestFlags flags); =20 int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_pdiscard)( BlockDriverState *bs, int64_t offset, int64_t bytes); diff --git a/block/blkdebug.c b/block/blkdebug.c index 8506004707..eed03bfe7e 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -679,9 +679,9 @@ static int GRAPH_RDLOCK coroutine_fn blkdebug_co_flush(= BlockDriverState *bs) return bdrv_co_flush(bs->file->bs); } =20 -static int coroutine_fn blkdebug_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int64_t = bytes, - BdrvRequestFlags flags) +static int coroutine_fn GRAPH_RDLOCK +blkdebug_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t by= tes, + BdrvRequestFlags flags) { uint32_t align =3D MAX(bs->bl.request_alignment, bs->bl.pwrite_zeroes_alignment); diff --git a/block/blklogwrites.c b/block/blklogwrites.c index 3033f5035b..bdaa2a57a2 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -437,7 +437,7 @@ blk_log_writes_co_do_file_pwritev(BlkLogWritesFileReq *= fr) fr->qiov, fr->file_flags); } =20 -static int coroutine_fn +static int coroutine_fn GRAPH_RDLOCK blk_log_writes_co_do_file_pwrite_zeroes(BlkLogWritesFileReq *fr) { return bdrv_co_pwrite_zeroes(fr->bs->file, fr->offset, fr->bytes, @@ -465,11 +465,10 @@ blk_log_writes_co_pwritev(BlockDriverState *bs, int64= _t offset, int64_t bytes, blk_log_writes_co_do_file_pwritev, 0, fal= se); } =20 -static int coroutine_fn +static int coroutine_fn GRAPH_RDLOCK blk_log_writes_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes, BdrvRequestFlags flags) { - assume_graph_lock(); /* FIXME */ return blk_log_writes_co_log(bs, offset, bytes, NULL, flags, blk_log_writes_co_do_file_pwrite_zeroes, = 0, true); diff --git a/block/blkreplay.c b/block/blkreplay.c index c18d3a755d..2703a0c8c6 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -91,8 +91,9 @@ static int coroutine_fn blkreplay_co_pwritev(BlockDriverS= tate *bs, return ret; } =20 -static int coroutine_fn blkreplay_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int64_t bytes, BdrvRequestFlags flags) +static int coroutine_fn GRAPH_RDLOCK +blkreplay_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t b= ytes, + BdrvRequestFlags flags) { uint64_t reqid =3D blkreplay_next_id(); int ret =3D bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); diff --git a/block/block-copy.c b/block/block-copy.c index d299fac7cc..e13d7bc6b6 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -469,10 +469,9 @@ static coroutine_fn int block_copy_task_run(AioTaskPoo= l *pool, * value of @method should be used for subsequent tasks. * Returns 0 on success. */ -static int coroutine_fn block_copy_do_copy(BlockCopyState *s, - int64_t offset, int64_t bytes, - BlockCopyMethod *method, - bool *error_is_read) +static int coroutine_fn GRAPH_RDLOCK +block_copy_do_copy(BlockCopyState *s, int64_t offset, int64_t bytes, + BlockCopyMethod *method, bool *error_is_read) { int ret; int64_t nbytes =3D MIN(offset + bytes, s->len) - offset; @@ -558,8 +557,10 @@ static coroutine_fn int block_copy_task_entry(AioTask = *task) BlockCopyMethod method =3D t->method; int ret; =20 - ret =3D block_copy_do_copy(s, t->req.offset, t->req.bytes, &method, - &error_is_read); + WITH_GRAPH_RDLOCK_GUARD() { + ret =3D block_copy_do_copy(s, t->req.offset, t->req.bytes, &method, + &error_is_read); + } =20 WITH_QEMU_LOCK_GUARD(&s->lock) { if (s->method =3D=3D t->method) { diff --git a/block/copy-before-write.c b/block/copy-before-write.c index 42b46e746a..61854beae2 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -160,8 +160,9 @@ cbw_co_pdiscard(BlockDriverState *bs, int64_t offset, i= nt64_t bytes) return bdrv_co_pdiscard(bs->file, offset, bytes); } =20 -static int coroutine_fn cbw_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int64_t bytes, BdrvRequestFlags flags) +static int coroutine_fn GRAPH_RDLOCK +cbw_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes, + BdrvRequestFlags flags) { int ret =3D cbw_do_copy_before_write(bs, offset, bytes, flags); if (ret < 0) { diff --git a/block/copy-on-read.c b/block/copy-on-read.c index b564f1ca3f..ebf6864dd3 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -192,9 +192,9 @@ static int coroutine_fn cor_co_pwritev_part(BlockDriver= State *bs, } =20 =20 -static int coroutine_fn cor_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int64_t bytes, - BdrvRequestFlags flags) +static int coroutine_fn GRAPH_RDLOCK +cor_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes, + BdrvRequestFlags flags) { return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); } diff --git a/block/filter-compress.c b/block/filter-compress.c index 083aaef53c..7a632f47fe 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -84,9 +84,9 @@ static int coroutine_fn compress_co_pwritev_part(BlockDri= verState *bs, } =20 =20 -static int coroutine_fn compress_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int64_t = bytes, - BdrvRequestFlags flags) +static int coroutine_fn GRAPH_RDLOCK +compress_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t by= tes, + BdrvRequestFlags flags) { return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); } diff --git a/block/io.c b/block/io.c index e97adb5ba4..00843362e9 100644 --- a/block/io.c +++ b/block/io.c @@ -1172,6 +1172,8 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(Bdrv= Child *child, int64_t progress =3D 0; bool skip_write; =20 + assume_graph_lock(); /* FIXME */ + bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort= ); =20 if (!drv) { @@ -1692,6 +1694,7 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(Bloc= kDriverState *bs, bs->bl.request_alignment); int max_transfer =3D MIN_NON_ZERO(bs->bl.max_transfer, MAX_BOUNCE_BUFF= ER); =20 + assert_bdrv_graph_readable(); bdrv_check_request(offset, bytes, &error_abort); =20 if (!drv) { @@ -1907,6 +1910,8 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChil= d *child, int64_t bytes_remaining =3D bytes; int max_transfer; =20 + assume_graph_lock(); /* FIXME */ + bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort= ); =20 if (!drv) { @@ -2159,6 +2164,7 @@ int coroutine_fn bdrv_co_pwrite_zeroes(BdrvChild *chi= ld, int64_t offset, { IO_CODE(); trace_bdrv_co_pwrite_zeroes(child->bs, offset, bytes, flags); + assert_bdrv_graph_readable(); =20 if (!(child->bs->open_flags & BDRV_O_UNMAP)) { flags &=3D ~BDRV_REQ_MAY_UNMAP; @@ -2602,8 +2608,6 @@ int coroutine_fn bdrv_co_is_zero_fast(BlockDriverStat= e *bs, int64_t offset, int64_t pnum =3D bytes; IO_CODE(); =20 - assume_graph_lock(); /* FIXME */ - if (!bytes) { return 1; } @@ -3241,7 +3245,7 @@ void bdrv_unregister_buf(BlockDriverState *bs, void *= host, size_t size) } } =20 -static int coroutine_fn bdrv_co_copy_range_internal( +static int coroutine_fn GRAPH_RDLOCK bdrv_co_copy_range_internal( BdrvChild *src, int64_t src_offset, BdrvChild *dst, int64_t dst_offset, int64_t bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags, @@ -3330,6 +3334,7 @@ int coroutine_fn bdrv_co_copy_range_from(BdrvChild *s= rc, int64_t src_offset, BdrvRequestFlags write_flags) { IO_CODE(); + assume_graph_lock(); /* FIXME */ trace_bdrv_co_copy_range_from(src, src_offset, dst, dst_offset, bytes, read_flags, write_flags); return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset, @@ -3347,6 +3352,7 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src= , int64_t src_offset, BdrvRequestFlags write_flags) { IO_CODE(); + assume_graph_lock(); /* FIXME */ trace_bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes, read_flags, write_flags); return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset, diff --git a/block/mirror.c b/block/mirror.c index b67e8b14f8..a6f4ec6282 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1547,10 +1547,10 @@ static int coroutine_fn GRAPH_RDLOCK bdrv_mirror_to= p_flush(BlockDriverState *bs) return bdrv_co_flush(bs->backing->bs); } =20 -static int coroutine_fn bdrv_mirror_top_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int64_t bytes, BdrvRequestFlags flags) +static int coroutine_fn GRAPH_RDLOCK +bdrv_mirror_top_pwrite_zeroes(BlockDriverState *bs, int64_t offset, + int64_t bytes, BdrvRequestFlags flags) { - assume_graph_lock(); /* FIXME */ return bdrv_mirror_top_do_write(bs, MIRROR_METHOD_ZERO, offset, bytes,= NULL, flags); } diff --git a/block/preallocate.c b/block/preallocate.c index c2c2dc8a8c..91d73c81c6 100644 --- a/block/preallocate.c +++ b/block/preallocate.c @@ -269,8 +269,9 @@ static bool has_prealloc_perms(BlockDriverState *bs) * want_merge_zero is used to merge write-zero request with preallocation = in * one bdrv_co_pwrite_zeroes() call. */ -static bool coroutine_fn handle_write(BlockDriverState *bs, int64_t offset, - int64_t bytes, bool want_merge_zero) +static bool coroutine_fn GRAPH_RDLOCK +handle_write(BlockDriverState *bs, int64_t offset, int64_t bytes, + bool want_merge_zero) { BDRVPreallocateState *s =3D bs->opaque; int64_t end =3D offset + bytes; @@ -345,8 +346,9 @@ static bool coroutine_fn handle_write(BlockDriverState = *bs, int64_t offset, return want_merge_zero; } =20 -static int coroutine_fn preallocate_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int64_t bytes, BdrvRequestFlags flags) +static int coroutine_fn GRAPH_RDLOCK +preallocate_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, + int64_t bytes, BdrvRequestFlags flags) { bool want_merge_zero =3D !(flags & ~(BDRV_REQ_ZERO_WRITE | BDRV_REQ_NO_FALLBACK)); @@ -364,6 +366,7 @@ static coroutine_fn int preallocate_co_pwritev_part(Blo= ckDriverState *bs, size_t qiov_offset, BdrvRequestFlags flags) { + assume_graph_lock(); /* FIXME */ handle_write(bs, offset, bytes, false); =20 return bdrv_co_pwritev_part(bs->file, offset, bytes, qiov, qiov_offset, diff --git a/block/qcow2.c b/block/qcow2.c index e06ea7b5ff..89c3edbd61 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2450,7 +2450,8 @@ 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 coroutine_fn is_zero_cow(BlockDriverState *bs, QCowL2Meta *m) +static int coroutine_fn GRAPH_RDLOCK +is_zero_cow(BlockDriverState *bs, QCowL2Meta *m) { /* * This check is designed for optimization shortcut so it must be @@ -2468,8 +2469,8 @@ static int coroutine_fn is_zero_cow(BlockDriverState = *bs, QCowL2Meta *m) m->cow_end.nb_bytes); } =20 -static int coroutine_fn handle_alloc_space(BlockDriverState *bs, - QCowL2Meta *l2meta) +static int coroutine_fn GRAPH_RDLOCK +handle_alloc_space(BlockDriverState *bs, QCowL2Meta *l2meta) { BDRVQcow2State *s =3D bs->opaque; QCowL2Meta *m; @@ -2532,12 +2533,10 @@ static int coroutine_fn handle_alloc_space(BlockDri= verState *bs, * l2meta - if not NULL, qcow2_co_pwritev_task() will consume it. Caller = must * not use it somehow after qcow2_co_pwritev_task() call */ -static coroutine_fn int qcow2_co_pwritev_task(BlockDriverState *bs, - uint64_t host_offset, - uint64_t offset, uint64_t by= tes, - QEMUIOVector *qiov, - uint64_t qiov_offset, - QCowL2Meta *l2meta) +static coroutine_fn GRAPH_RDLOCK +int qcow2_co_pwritev_task(BlockDriverState *bs, uint64_t host_offset, + uint64_t offset, uint64_t bytes, QEMUIOVector *q= iov, + uint64_t qiov_offset, QCowL2Meta *l2meta) { int ret; BDRVQcow2State *s =3D bs->opaque; @@ -2603,7 +2602,11 @@ out_locked: return ret; } =20 -static coroutine_fn int qcow2_co_pwritev_task_entry(AioTask *task) +/* + * This function can count as GRAPH_RDLOCK because qcow2_co_pwritev_part()= holds + * the graph lock and keeps it until this coroutine has terminated. + */ +static coroutine_fn GRAPH_RDLOCK int qcow2_co_pwritev_task_entry(AioTask *= task) { Qcow2AioTask *t =3D container_of(task, Qcow2AioTask, task); =20 @@ -2626,6 +2629,8 @@ static coroutine_fn int qcow2_co_pwritev_part( QCowL2Meta *l2meta =3D NULL; AioTaskPool *aio =3D NULL; =20 + assume_graph_lock(); /* FIXME */ + trace_qcow2_writev_start_req(qemu_coroutine_self(), offset, bytes); =20 while (bytes !=3D 0 && aio_task_pool_status(aio) =3D=3D 0) { @@ -3974,8 +3979,9 @@ static bool is_zero(BlockDriverState *bs, int64_t off= set, int64_t bytes) return res >=3D 0 && (res & BDRV_BLOCK_ZERO) && bytes =3D=3D 0; } =20 -static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int64_t bytes, BdrvRequestFlags flags) +static int coroutine_fn GRAPH_RDLOCK +qcow2_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes, + BdrvRequestFlags flags) { int ret; BDRVQcow2State *s =3D bs->opaque; diff --git a/block/qed.c b/block/qed.c index cf794a1add..bdcb6de6df 100644 --- a/block/qed.c +++ b/block/qed.c @@ -1420,15 +1420,12 @@ static int coroutine_fn bdrv_qed_co_writev(BlockDri= verState *bs, return qed_co_request(bs, sector_num, qiov, nb_sectors, QED_AIOCB_WRIT= E); } =20 -static int coroutine_fn bdrv_qed_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, - int64_t bytes, - BdrvRequestFlags flags) +static int coroutine_fn GRAPH_RDLOCK +bdrv_qed_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t by= tes, + BdrvRequestFlags flags) { BDRVQEDState *s =3D bs->opaque; =20 - assume_graph_lock(); /* FIXME */ - /* * Zero writes start without an I/O buffer. If a buffer becomes neces= sary * then it will be allocated during request processing. diff --git a/block/quorum.c b/block/quorum.c index 3fe3791ab2..02ae0d8343 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -683,7 +683,11 @@ static int coroutine_fn quorum_co_preadv(BlockDriverSt= ate *bs, return ret; } =20 -static void coroutine_fn write_quorum_entry(void *opaque) +/* + * This function can count as GRAPH_RDLOCK because quorum_co_pwritev() hol= ds the + * graph lock and keeps it until this coroutine has terminated. + */ +static void coroutine_fn GRAPH_RDLOCK write_quorum_entry(void *opaque) { QuorumCo *co =3D opaque; QuorumAIOCB *acb =3D co->acb; @@ -722,6 +726,8 @@ static int coroutine_fn quorum_co_pwritev(BlockDriverSt= ate *bs, int64_t offset, QuorumAIOCB *acb =3D quorum_aio_get(bs, qiov, offset, bytes, flags); int i, ret; =20 + assume_graph_lock(); /* FIXME */ + for (i =3D 0; i < s->num_children; i++) { Coroutine *co; QuorumCo data =3D { @@ -745,10 +751,9 @@ static int coroutine_fn quorum_co_pwritev(BlockDriverS= tate *bs, int64_t offset, return ret; } =20 -static int coroutine_fn quorum_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int64_t by= tes, - BdrvRequestFlags flags) - +static int coroutine_fn GRAPH_RDLOCK +quorum_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t byte= s, + BdrvRequestFlags flags) { return quorum_co_pwritev(bs, offset, bytes, NULL, flags | BDRV_REQ_ZERO_WRITE); diff --git a/block/raw-format.c b/block/raw-format.c index 7f1036ebed..007d7f6e42 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -292,9 +292,9 @@ static int coroutine_fn raw_co_block_status(BlockDriver= State *bs, return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID; } =20 -static int coroutine_fn raw_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int64_t bytes, - BdrvRequestFlags flags) +static int coroutine_fn GRAPH_RDLOCK +raw_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes, + BdrvRequestFlags flags) { int ret; =20 diff --git a/block/throttle.c b/block/throttle.c index b07d853c0a..3db4fa3c40 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -134,9 +134,9 @@ static int coroutine_fn throttle_co_pwritev(BlockDriver= State *bs, return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags); } =20 -static int coroutine_fn throttle_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, int64_t = bytes, - BdrvRequestFlags flags) +static int coroutine_fn GRAPH_RDLOCK +throttle_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t by= tes, + BdrvRequestFlags flags) { ThrottleGroupMember *tgm =3D bs->opaque; throttle_group_co_io_limits_intercept(tgm, bytes, true); --=20 2.39.2