From patchwork Tue Jul 5 18:17:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 103373 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 54573B6F6C for ; Wed, 6 Jul 2011 05:29:33 +1000 (EST) Received: from localhost ([::1]:38114 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QeBJJ-0002g1-ES for incoming@patchwork.ozlabs.org; Tue, 05 Jul 2011 15:29:29 -0400 Received: from eggs.gnu.org ([140.186.70.92]:33765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QeACR-00009i-ON for qemu-devel@nongnu.org; Tue, 05 Jul 2011 14:18:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QeACQ-00028B-0P for qemu-devel@nongnu.org; Tue, 05 Jul 2011 14:18:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34286) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QeACP-00027x-8t for qemu-devel@nongnu.org; Tue, 05 Jul 2011 14:18:17 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p65IIC4W016785 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 5 Jul 2011 14:18:13 -0400 Received: from localhost (ovpn-113-99.phx2.redhat.com [10.3.113.99]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p65IIB8x005083; Tue, 5 Jul 2011 14:18:12 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Tue, 5 Jul 2011 15:17:46 -0300 Message-Id: <1309889871-6267-4-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1309889871-6267-1-git-send-email-lcapitulino@redhat.com> References: <1309889871-6267-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, jan.kiszka@siemens.com, armbru@redhat.com, stefanha@gmail.com, jdenemar@redhat.com Subject: [Qemu-devel] [PATCH 3/8] block: Support to keep track of I/O status 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 This commit adds support to the BlockDriverState type to keep track of the last I/O status. That is, at every I/O operation we update a status field in the BlockDriverState instance. Valid statuses are: OK, FAILED and ENOSPC. ENOSPC is distinguished from FAILED because an management application can use it to implement thin-provisioning. This feature has to be explicit enabled by buses/devices supporting it. Signed-off-by: Luiz Capitulino --- block.c | 18 ++++++++++++++++++ block.h | 7 +++++++ block_int.h | 2 ++ 3 files changed, 27 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 24a25d5..cc0a34e 100644 --- a/block.c +++ b/block.c @@ -195,6 +195,7 @@ BlockDriverState *bdrv_new(const char *device_name) if (device_name[0] != '\0') { QTAILQ_INSERT_TAIL(&bdrv_states, bs, list); } + bs->iostatus_enabled = false; return bs; } @@ -2876,6 +2877,23 @@ int bdrv_in_use(BlockDriverState *bs) return bs->in_use; } +void bdrv_enable_iostatus(BlockDriverState *bs) +{ + bs->iostatus_enabled = true; +} + +void bdrv_iostatus_update(BlockDriverState *bs, int error) +{ + error = abs(error); + + if (!error) { + bs->iostatus = BDRV_IOS_OK; + } else { + bs->iostatus = (error == ENOSPC) ? BDRV_IOS_ENOSPC : + BDRV_IOS_FAILED; + } +} + int bdrv_img_create(const char *filename, const char *fmt, const char *base_filename, const char *base_fmt, char *options, uint64_t img_size, int flags) diff --git a/block.h b/block.h index 859d1d9..0dca1bb 100644 --- a/block.h +++ b/block.h @@ -50,6 +50,13 @@ typedef enum { BDRV_ACTION_REPORT, BDRV_ACTION_IGNORE, BDRV_ACTION_STOP } BlockMonEventAction; +typedef enum { + BDRV_IOS_OK, BDRV_IOS_FAILED, BDRV_IOS_ENOSPC +} BlockIOStatus; + +void bdrv_iostatus_update(BlockDriverState *bs, int error); +void bdrv_enable_iostatus(BlockDriverState *bs); +void bdrv_enable_io_status(BlockDriverState *bs); void bdrv_mon_event(const BlockDriverState *bdrv, BlockMonEventAction action, int is_read); void bdrv_info_print(Monitor *mon, const QObject *data); diff --git a/block_int.h b/block_int.h index 1e265d2..09f038d 100644 --- a/block_int.h +++ b/block_int.h @@ -195,6 +195,8 @@ struct BlockDriverState { drivers. They are not used by the block driver */ int cyls, heads, secs, translation; BlockErrorAction on_read_error, on_write_error; + bool iostatus_enabled; + BlockIOStatus iostatus; char device_name[32]; unsigned long *dirty_bitmap; int64_t dirty_count;