From: Kevin Wolf <kwolf@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: stefanha@gmail.com, jan.kiszka@siemens.com, jdenemar@redhat.com,
qemu-devel@nongnu.org, Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 3/8] block: Support to keep track of I/O status
Date: Tue, 12 Jul 2011 10:33:35 +0200 [thread overview]
Message-ID: <4E1C06DF.2050302@redhat.com> (raw)
In-Reply-To: <m3oc106iyo.fsf@blackfin.pond.sub.org>
Am 12.07.2011 09:45, schrieb Markus Armbruster:
> Luiz Capitulino <lcapitulino@redhat.com> writes:
>
>> 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.
>
> buses?
>
>>
>> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
>> ---
>> 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;
>
> Okay, let's see what we got here.
>
> The block layer merely holds I/O status, device models set it.
>
> Device I/O status is not migrated. Why?
>
> bdrv_new() creates the BDS with I/O status tracking disabled. Devices
> that do tracking enable it in their qdev init method. If a device gets
> hot unplugged, tracking remains enabled. If the BDS then gets reused
> with a device that doesn't do tracking, I/O status becomes incorrect.
> Can't happen right now, because we automatically delete the BDS on hot
> unplug, but it's a trap. Suggest to disable tracking in bdrv_detach().
>
> Actually, this is a symptom of the midlayer disease. I suspect things
> would be simpler if we hold the status in its rightful owner, the device
> model. Need a getter for it. I'm working on a patch series that moves
> misplaced state out of the block layer into device models and block
> drivers, and a I/O status getter will fit in easily there.
This is host state, so the device is not the rightful owner. Devices
should not even be involved with enabling it.
Kevin
next prev parent reply other threads:[~2011-07-12 8:30 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-05 18:17 [Qemu-devel] [PATCH v1 0/8]: QMP: Thin provisioning support Luiz Capitulino
2011-07-05 18:17 ` [Qemu-devel] [PATCH 1/8] Introduce the VMStatus type Luiz Capitulino
2011-07-05 18:33 ` Anthony Liguori
2011-07-05 18:51 ` Luiz Capitulino
2011-07-05 18:58 ` Anthony Liguori
2011-07-05 19:34 ` Luiz Capitulino
2011-07-12 7:28 ` Markus Armbruster
2011-07-12 14:25 ` Luiz Capitulino
2011-07-12 14:51 ` Kevin Wolf
2011-07-12 15:12 ` Luiz Capitulino
2011-07-12 16:03 ` Luiz Capitulino
2011-07-12 16:16 ` Kevin Wolf
2011-07-12 17:59 ` Luiz Capitulino
2011-07-05 18:17 ` [Qemu-devel] [PATCH 2/8] QMP: query-status: Introduce 'status' key Luiz Capitulino
2011-07-05 18:17 ` [Qemu-devel] [PATCH 3/8] block: Support to keep track of I/O status Luiz Capitulino
2011-07-12 7:45 ` Markus Armbruster
2011-07-12 8:33 ` Kevin Wolf [this message]
2011-07-12 9:12 ` Markus Armbruster
2011-07-12 14:38 ` Luiz Capitulino
2011-07-12 14:25 ` Kevin Wolf
2011-07-12 14:56 ` Luiz Capitulino
2011-07-05 18:17 ` [Qemu-devel] [PATCH 4/8] ide: Support " Luiz Capitulino
2011-07-05 18:17 ` [Qemu-devel] [PATCH 5/8] virtio: " Luiz Capitulino
2011-07-05 18:17 ` [Qemu-devel] [PATCH 6/8] scsi: " Luiz Capitulino
2011-07-05 18:17 ` [Qemu-devel] [PATCH 7/8] QMP: query-status: Add 'io-status' key Luiz Capitulino
2011-07-12 7:47 ` Markus Armbruster
2011-07-12 14:56 ` Luiz Capitulino
2011-07-05 18:17 ` [Qemu-devel] [PATCH 8/8] HMP: Print 'io-status' information Luiz Capitulino
2011-07-11 17:43 ` [Qemu-devel] [PATCH v1 0/8]: QMP: Thin provisioning support Luiz Capitulino
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=4E1C06DF.2050302@redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=jdenemar@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.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).