From: Linus Heckemann <git@sphalerite.org>
To: Christian Schoenebeck <qemu_oss@crudebyte.com>, qemu-devel@nongnu.org
Cc: Qemu-block <qemu-block@nongnu.org>, "Greg Kurz" <groug@kaod.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: Re: [PATCH v5] 9pfs: use GHashTable for fid table
Date: Tue, 27 Sep 2022 17:14:57 +0200 [thread overview]
Message-ID: <ygasfkcx30u.fsf@localhost> (raw)
In-Reply-To: <20220927142503.1694674-1-git@sphalerite.org>
Linus Heckemann <git@sphalerite.org> writes:
> static void coroutine_fn virtfs_reset(V9fsPDU *pdu)
> {
> V9fsState *s = pdu->s;
> V9fsFidState *fidp;
> + GList *freeing;
> + /* Get a list of all the values (fid states) in the table, which we then... */
> + g_autoptr(GList) fids = g_hash_table_get_values(s->fids);
>
> - /* Free all fids */
> - while (!QSIMPLEQ_EMPTY(&s->fid_list)) {
> - /* Get fid */
> - fidp = QSIMPLEQ_FIRST(&s->fid_list);
> - fidp->ref++;
> + /* ... remove from the table, taking over ownership. */
> + g_hash_table_steal_all(s->fids);
>
> - /* Clunk fid */
> - QSIMPLEQ_REMOVE(&s->fid_list, fidp, V9fsFidState, next);
> + /*
> + * This allows us to release our references to them asynchronously without
> + * iterating over the hash table and risking iterator invalidation
> + * through concurrent modifications.
> + */
> + for (freeing = fids; freeing; freeing = freeing->next) {
> + fidp = freeing->data;
> + fidp->ref++;
> fidp->clunked = true;
> -
> put_fid(pdu, fidp);
> }
> }
I'm not sure if this implementation is correct. I'm concerned that it
may result in dangling references, but haven't been able to find a
client that will send the TVERSION request on a connection that's
already been used in other ways, as opposed to when the connection is
first established. I suspect this will be very rare in general, so it
might be good to have a test case somewhere.
next prev parent reply other threads:[~2022-09-27 18:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-27 14:25 [PATCH v5] 9pfs: use GHashTable for fid table Linus Heckemann
2022-09-27 15:14 ` Linus Heckemann [this message]
2022-09-27 19:10 ` Christian Schoenebeck
2022-09-27 19:07 ` Christian Schoenebeck
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=ygasfkcx30u.fsf@localhost \
--to=git@sphalerite.org \
--cc=f4bug@amsat.org \
--cc=groug@kaod.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu_oss@crudebyte.com \
/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).