From: Jan Kiszka <jan.kiszka@siemens.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] Fix race in POSIX AIO emulation
Date: Tue, 13 Jan 2009 10:17:18 +0100 [thread overview]
Message-ID: <496C5C1E.1070900@siemens.com> (raw)
In-Reply-To: <494B95CC.8070008@siemens.com>
Jan Kiszka wrote:
> When we cancel an AIO request that is already being processed by
> aio_thread, qemu_paio_cancel should return QEMU_PAIO_NOTCANCELED as long
> as aio_thread isn't done with this request. But as the latter currently
> updates aiocb->ret after every block of the request, we may report
> QEMU_PAIO_ALLDONE too early.
>
> Futhermore, in case some zero-length request should have been queued,
> aiocb->ret is never set to != -EINPROGRESS and callers like
> raw_aio_cancel could get stuck in an endless loop.
>
> Fix those issues by updating aiocb->ret _after_ the request has been
> fully processed. This also simplifies the locking.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>
> posix-aio-compat.c | 9 ++-------
> 1 files changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/posix-aio-compat.c b/posix-aio-compat.c
> index 92ec234..c919e3b 100644
> --- a/posix-aio-compat.c
> +++ b/posix-aio-compat.c
> @@ -81,21 +81,16 @@ static void *aio_thread(void *unused)
> if (len == -1 && errno == EINTR)
> continue;
> else if (len == -1) {
> - pthread_mutex_lock(&lock);
> - aiocb->ret = -errno;
> - pthread_mutex_unlock(&lock);
> + offset = -errno;
> break;
> } else if (len == 0)
> break;
>
> offset += len;
> -
> - pthread_mutex_lock(&lock);
> - aiocb->ret = offset;
> - pthread_mutex_unlock(&lock);
> }
>
> pthread_mutex_lock(&lock);
> + aiocb->ret = offset;
> idle_threads++;
> pthread_mutex_unlock(&lock);
>
>
Problem still exists, patch still applies - but no feedback yet.
Forgotten under the Christmas tree?
Jan
--
Siemens AG, Corporate Technology, CT SE 26
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2009-01-13 9:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-19 12:38 [Qemu-devel] [PATCH] Fix race in POSIX AIO emulation Jan Kiszka
2009-01-13 9:17 ` Jan Kiszka [this message]
2009-01-13 15:14 ` [Qemu-devel] " Anthony Liguori
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=496C5C1E.1070900@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=anthony@codemonkey.ws \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.