From: Kevin Wolf <kwolf@redhat.com>
To: Alberto Garcia <berto@igalia.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] qcow2: Release dirty entries with cache-clean-interval
Date: Thu, 9 Aug 2018 15:30:38 +0200 [thread overview]
Message-ID: <20180809133038.GC4320@localhost.localdomain> (raw)
In-Reply-To: <w51mutvbsak.fsf@maestria.local.igalia.com>
Am 09.08.2018 um 15:09 hat Alberto Garcia geschrieben:
> On Mon 06 Aug 2018 05:58:41 PM CEST, Kevin Wolf wrote:
> > Am 06.08.2018 um 17:20 hat Alberto Garcia geschrieben:
> >> On Mon 06 Aug 2018 05:05:41 PM CEST, Kevin Wolf wrote:
> >> > Am 06.08.2018 um 16:13 hat Alberto Garcia geschrieben:
> >> >> -static inline bool can_clean_entry(Qcow2Cache *c, int i)
> >> >> +static inline bool can_clean_entry(BlockDriverState *bs, Qcow2Cache *c, int i)
> >> >> {
> >> >> Qcow2CachedTable *t = &c->entries[i];
> >> >> - return t->ref == 0 && !t->dirty && t->offset != 0 &&
> >> >> - t->lru_counter <= c->cache_clean_lru_counter;
> >> >> + if (t->ref || !t->offset || t->lru_counter > c->cache_clean_lru_counter) {
> >> >> + return false;
> >> >> + }
> >> >> +
> >> >> + if (qcow2_cache_entry_flush(bs, c, i) < 0) {
> >> >> + return false;
> >> >> + }
> >> >
> >> > We're not in coroutine context here, so qcow2_cache_entry_flush() will
> >> > be blocking. I don't think that's acceptable in a timer callback.
> >> >
> >> > On the other hand, if we made it non-blocking by moving it into a
> >> > coroutine that could yield, we would have to consider races with other
> >> > parts of the code and at least take s->lock and implement
> >> > .bdrv_co_drain_begin/end callbacks.
> >>
> >> Oh, I see... it's probably not worth complicating the code for this then.
> >
> > On second thoughts, I actually think we can do without the drain
> > callbacks if we just add a bdrv_inc/dec_in_flight() pair around
> > qcow2_cache_clean_unused().
> >
> > We'd still have to create a coroutine in cache_clean_timer_cb() and take
> > the lock, but that sounds more managable.
>
> When we're waiting for a cache entry to flush and the coroutine yields,
> can the previous (already checked) cache entries become dirty?
qcow2_cache_entry_mark_dirty() should only ever be called under s->lock,
so as long as you take the lock, I don't think so.
Kevin
prev parent reply other threads:[~2018-08-09 13:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-06 14:13 [Qemu-devel] [PATCH] qcow2: Release dirty entries with cache-clean-interval Alberto Garcia
2018-08-06 15:05 ` Kevin Wolf
2018-08-06 15:20 ` Alberto Garcia
2018-08-06 15:58 ` Kevin Wolf
2018-08-09 13:09 ` Alberto Garcia
2018-08-09 13:30 ` Kevin Wolf [this message]
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=20180809133038.GC4320@localhost.localdomain \
--to=kwolf@redhat.com \
--cc=berto@igalia.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).