From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, mreitz@redhat.com, kwolf@redhat.com,
vsementsov@virtuozzo.com, den@openvz.org
Subject: [PATCH v2(RFC) 0/3] qcow2: fix parallel rewrite and discard
Date: Thu, 25 Feb 2021 14:52:02 +0300 [thread overview]
Message-ID: <20210225115205.249923-1-vsementsov@virtuozzo.com> (raw)
Hi all! It occurs that nothing prevents discarding and reallocating host
cluster during data writing. This way data writing will pollute another
newly allocated cluster of data or metadata.
OK, v2 is a try to solve the problem with CoRwlock.. And it is marked
RFC, because of a lot of iotest failures.. Some of problems with v2:
1. It's a more complicated to make a test, as everything is blocking
and I can't just break write and do discard.. I have to implement
aio_discard in qemu-io and rewrite test into several portions of io
commands splitted by "sleep 1".. OK, it's not a big problem, and I've
solved it.
2. iotest 7 fails with several leaked clusters. Seems, that it depend on
the fact that discard may be done in parallel with writes. Iotest 7 does
snapshots, so I think l1 table is updated to the moment when discard is
finally unlocked.. But I didn't dig into it, it's all my assumptions.
3. iotest 13 (and I think a lot more iotests) crashes on
assert(!to->locks_held); .. So with this assertion we can't keep rwlock
locked during data writing...
#3 in __assert_fail () from /lib64/libc.so.6
#4 in qemu_aio_coroutine_enter (ctx=0x55762120b700, co=0x55762121d700)
at ../util/qemu-coroutine.c:158
#5 in aio_co_enter (ctx=0x55762120b700, co=0x55762121d700) at ../util/async.c:628
#6 in aio_co_wake (co=0x55762121d700) at ../util/async.c:612
#7 in thread_pool_co_cb (opaque=0x7f17950daab0, ret=0) at ../util/thread-pool.c:279
#8 in thread_pool_completion_bh (opaque=0x5576211e5070) at ../util/thread-pool.c:188
#9 in aio_bh_call (bh=0x557621205df0) at ../util/async.c:136
#10 in aio_bh_poll (ctx=0x55762120b700) at ../util/async.c:164
#11 in aio_poll (ctx=0x55762120b700, blocking=true) at ../util/aio-posix.c:659
#12 in blk_prw (blk=0x557621205790, offset=4303351808,
buf=0x55762123e000 '\364' <repeats 199 times>, <incomplete sequence \364>..., bytes=12288,
co_entry=0x557620d9dc97 <blk_write_entry>, flags=0) at ../block/block-backend.c:1335
#13 in blk_pwrite (blk=0x557621205790, offset=4303351808, buf=0x55762123e000,
count=12288, flags=0) at ../block/block-backend.c:1501
So now I think that v1 is simpler.. It's more complicated (but not too
much) in code. But it keeps discards and data writes non-blocking each
other and avoids yields in critical sections.
Vladimir Sementsov-Ogievskiy (3):
qemu-io: add aio_discard
iotests: add qcow2-discard-during-rewrite
block/qcow2: introduce inflight writes counters: fix discard
block/qcow2.h | 2 +
block/qcow2-cluster.c | 4 +
block/qcow2.c | 18 ++-
qemu-io-cmds.c | 117 ++++++++++++++++++
.../tests/qcow2-discard-during-rewrite | 99 +++++++++++++++
.../tests/qcow2-discard-during-rewrite.out | 17 +++
6 files changed, 256 insertions(+), 1 deletion(-)
create mode 100755 tests/qemu-iotests/tests/qcow2-discard-during-rewrite
create mode 100644 tests/qemu-iotests/tests/qcow2-discard-during-rewrite.out
--
2.29.2
next reply other threads:[~2021-02-25 11:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-25 11:52 Vladimir Sementsov-Ogievskiy [this message]
2021-02-25 11:52 ` [PATCH v2 1/3] qemu-io: add aio_discard Vladimir Sementsov-Ogievskiy
2021-02-25 11:52 ` [PATCH v2 2/3] iotests: add qcow2-discard-during-rewrite Vladimir Sementsov-Ogievskiy
2021-02-25 11:52 ` [PATCH v2 3/3] block/qcow2: introduce inflight writes counters: fix discard Vladimir Sementsov-Ogievskiy
2021-03-12 15:24 ` [PATCH v2(RFC) 0/3] qcow2: fix parallel rewrite and discard Kevin Wolf
2021-03-12 15:54 ` Vladimir Sementsov-Ogievskiy
2021-03-18 15:37 ` Vladimir Sementsov-Ogievskiy
2021-03-18 15:51 ` Vladimir Sementsov-Ogievskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210225115205.249923-1-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=den@openvz.org \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).