From patchwork Wed Apr 4 15:08:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 150851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A3C37B7039 for ; Thu, 5 Apr 2012 13:43:12 +1000 (EST) Received: from localhost ([::1]:59895 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFRq6-0004jE-1Z for incoming@patchwork.ozlabs.org; Wed, 04 Apr 2012 11:09:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFRp5-0001nb-AK for qemu-devel@nongnu.org; Wed, 04 Apr 2012 11:08:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SFRov-0005yh-4h for qemu-devel@nongnu.org; Wed, 04 Apr 2012 11:08:34 -0400 Received: from goliath.siemens.de ([192.35.17.28]:15253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFRou-0005wl-Qj for qemu-devel@nongnu.org; Wed, 04 Apr 2012 11:08:25 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.13.6/8.13.6) with ESMTP id q34F8GHE009099; Wed, 4 Apr 2012 17:08:17 +0200 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id q34F8Gs4000310; Wed, 4 Apr 2012 17:08:16 +0200 From: Jan Kiszka To: Anthony Liguori , qemu-devel@nongnu.org Date: Wed, 4 Apr 2012 17:08:14 +0200 Message-Id: <12b72fe27ce10d16328f5bc9945dfb5d68405459.1333552093.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.28 Cc: Kevin Wolf , Paolo Bonzini Subject: [Qemu-devel] [PATCH 4/5] Reorder POSIX compat AIO code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Effectively no functional changes. This just moves posix_aio_notify_event up without modifying it and folds die/die2 into their only remaining user. Signed-off-by: Jan Kiszka --- posix-aio-compat.c | 44 ++++++++++++++++---------------------------- 1 files changed, 16 insertions(+), 28 deletions(-) diff --git a/posix-aio-compat.c b/posix-aio-compat.c index 7c3ff6e..f093156 100644 --- a/posix-aio-compat.c +++ b/posix-aio-compat.c @@ -71,6 +71,7 @@ static int new_threads = 0; /* backlog of threads we need to create */ static int pending_threads = 0; /* threads created but not running yet */ static QEMUBH *new_thread_bh; static QTAILQ_HEAD(, qemu_paiocb) request_list; +static PosixAioState *posix_aio_state; #ifdef CONFIG_PREADV static int preadv_present = 1; @@ -78,17 +79,6 @@ static int preadv_present = 1; static int preadv_present = 0; #endif -static void die2(int err, const char *what) -{ - fprintf(stderr, "%s failed: %s\n", what, strerror(err)); - abort(); -} - -static void die(const char *what) -{ - die2(errno, what); -} - static ssize_t handle_aiocb_ioctl(struct qemu_paiocb *aiocb) { int ret; @@ -277,7 +267,21 @@ static ssize_t handle_aiocb_rw(struct qemu_paiocb *aiocb) return nbytes; } -static void posix_aio_notify_event(void); +static void posix_aio_notify_event(void) +{ + /* Write 8 bytes to be compatible with eventfd. */ + static const uint64_t val = 1; + ssize_t ret; + + do { + ret = write(posix_aio_state->wfd, &val, sizeof(val)); + } while (ret < 0 && errno == EINTR); + + if (ret < 0 && errno != EAGAIN) { + fprintf(stderr, "write() failed: %s\n", strerror(errno)); + abort(); + } +} static void *aio_thread(void *unused) { @@ -502,22 +506,6 @@ static int posix_aio_flush(void *opaque) return !!s->first_aio; } -static PosixAioState *posix_aio_state; - -static void posix_aio_notify_event(void) -{ - /* Write 8 bytes to be compatible with eventfd. */ - static const uint64_t val = 1; - ssize_t ret; - - do { - ret = write(posix_aio_state->wfd, &val, sizeof(val)); - } while (ret < 0 && errno == EINTR); - - if (ret < 0 && errno != EAGAIN) - die("write()"); -} - static void paio_remove(struct qemu_paiocb *acb) { struct qemu_paiocb **pacb;