From: Kevin Wolf <kwolf@redhat.com>
To: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH V17 4/6] rename qcow2-cache.c to block-cache.c
Date: Tue, 11 Dec 2012 09:59:43 +0100 [thread overview]
Message-ID: <50C6F5FF.7080900@redhat.com> (raw)
In-Reply-To: <CAGrFBshqd3gvz2k7_z5TUv2sCLz2yaiWp3rC8d7bZOk8-0Wz2g@mail.gmail.com>
Am 11.12.2012 09:25, schrieb Dong Xu Wang:
> On Tue, Dec 11, 2012 at 1:11 AM, Kevin Wolf <kwolf@redhat.com> wrote:
>> Am 06.12.2012 07:51, schrieb Dong Xu Wang:
>>> We will re-use qcow2-cache as block layer common cache code,
>>> so change its name and made some changes, define a struct named
>>> BlockTableType, pass BlockTableType and table size parameters to
>>> block cache initialization function.
>>>
>>> Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
>>> diff --git a/block/block-cache.h b/block/block-cache.h
>>> new file mode 100644
>>> index 0000000..4efa06e
>>> --- /dev/null
>>> +++ b/block/block-cache.h
>>> @@ -0,0 +1,76 @@
>>> +/*
>>> + * QEMU Block Layer Cache
>>> + *
>>> + * Copyright IBM, Corp. 2012
>>> + *
>>> + * Authors:
>>> + * Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
>>> + *
>>> + * This file is based on qcow2-cache.c, see its copyrights below:
>>> + *
>>> + * L2/refcount table cache for the QCOW2 format
>>> + *
>>> + * Copyright (c) 2010 Kevin Wolf <kwolf@redhat.com>
>>> + *
>>> + * Permission is hereby granted, free of charge, to any person obtaining a copy
>>> + * of this software and associated documentation files (the "Software"), to deal
>>> + * in the Software without restriction, including without limitation the rights
>>> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
>>> + * copies of the Software, and to permit persons to whom the Software is
>>> + * furnished to do so, subject to the following conditions:
>>> + *
>>> + * The above copyright notice and this permission notice shall be included in
>>> + * all copies or substantial portions of the Software.
>>> + *
>>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
>>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
>>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
>>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
>>> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
>>> + * THE SOFTWARE.
>>> + */
>>> +
>>> +#ifndef BLOCK_CACHE_H
>>> +#define BLOCK_CACHE_H
>>> +
>>> +typedef enum {
>>> + BLOCK_TABLE_REF,
>>> + BLOCK_TABLE_L2,
>>> +} BlockTableType;
>>
>> I'm not excited about exposing these types, but it's okay for now. We
>> can always change the implementation later to be nicer.
>>
>>> +
>>> +typedef struct BlockCachedTable {
>>> + void *table;
>>> + int64_t offset;
>>> + bool dirty;
>>> + int cache_hits;
>>> + int ref;
>>> +} BlockCachedTable;
>>> +
>>> +struct BlockCache {
>>> + BlockCachedTable *entries;
>>> + struct BlockCache *depends;
>>> + int size;
>>> + size_t cluster_size;
>>> + BlockTableType table_type;
>>> + bool depends_on_flush;
>>> +};
>>
>> Why have these definitions been moved to the header file? They are
>> supposed to be private to the implementation.
>>
> Both qcow2.h:BDRVQcowState and add-cow.c: BDRVAddCowState have a
> member typed BlockCache,
> such as:
> typedef struct BDRVAddCowState {
> BlockDriverState *image_hd;
> CoMutex lock;
> int cluster_size;
> BlockCache *bitmap_cache;
> uint64_t bitmap_size;
> AddCowHeader header;
> char backing_fmt[16];
> char image_fmt[16];
> } BDRVAddCowState;
>
> So I have to move the definitions to the header file, so that both
> add-cow.c and qcow2.h can use BlockCache.
> Is it Okay?
The fields are actually of the type BlockCache*, i.e. a pointer. They
don't need the full definition of the struct, a forward declaration is
sufficient. So it's enough to have these lines from qcow2.h in the header:
struct Qcow2Cache;
typedef struct Qcow2Cache Qcow2Cache;
Kevin
next prev parent reply other threads:[~2012-12-11 9:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-06 6:51 [Qemu-devel] [PATCH V17 0/6] add-cow file format Dong Xu Wang
2012-12-06 6:51 ` [Qemu-devel] [PATCH V17 1/6] docs: document for " Dong Xu Wang
2012-12-10 15:39 ` Kevin Wolf
2012-12-11 8:02 ` Dong Xu Wang
2012-12-06 6:51 ` [Qemu-devel] [PATCH V17 2/6] make path_has_protocol non static Dong Xu Wang
2012-12-06 6:51 ` [Qemu-devel] [PATCH V17 3/6] qed_read_string to bdrv_read_string Dong Xu Wang
2012-12-06 6:51 ` [Qemu-devel] [PATCH V17 4/6] rename qcow2-cache.c to block-cache.c Dong Xu Wang
2012-12-10 17:11 ` Kevin Wolf
2012-12-11 8:25 ` Dong Xu Wang
2012-12-11 8:59 ` Kevin Wolf [this message]
2012-12-06 6:51 ` [Qemu-devel] [PATCH V17 5/6] add-cow file format core code Dong Xu Wang
2012-12-10 17:54 ` Kevin Wolf
2012-12-11 8:11 ` Dong Xu Wang
2012-12-11 9:03 ` Kevin Wolf
2012-12-06 6:51 ` [Qemu-devel] [PATCH V17 6/6] qemu-iotests: add add-cow iotests support Dong Xu Wang
2012-12-10 17:15 ` Kevin Wolf
2012-12-11 8:02 ` Dong Xu Wang
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=50C6F5FF.7080900@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=wdongxu@linux.vnet.ibm.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 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.