From: Kevin Wolf <kwolf@redhat.com>
To: Federico Simoncelli <fsimonce@redhat.com>
Cc: kvm@vger.kernel.org, Avi Kivity <avi@redhat.com>
Subject: Re: [PATCH] qemu-img: Add nocache command line option
Date: Wed, 15 Jun 2011 14:26:37 +0200 [thread overview]
Message-ID: <4DF8A4FD.6050807@redhat.com> (raw)
In-Reply-To: <293830786.685648.1308140154234.JavaMail.root@zmail02.collab.prod.int.phx2.redhat.com>
Am 15.06.2011 14:15, schrieb Federico Simoncelli:
> ----- Original Message -----
>> From: "Kevin Wolf" <kwolf@redhat.com>
>> To: "Federico Simoncelli" <fsimonce@redhat.com>
>> Cc: kvm@vger.kernel.org, "Avi Kivity" <avi@redhat.com>
>> Sent: Wednesday, June 15, 2011 1:45:02 PM
>> Subject: Re: [PATCH] qemu-img: Add nocache command line option
>> Am 15.06.2011 13:17, schrieb Federico Simoncelli:
>>> ----- Original Message -----
>>>> From: "Kevin Wolf" <kwolf@redhat.com>
>>>> To: "Avi Kivity" <avi@redhat.com>
>>>> Cc: "Federico Simoncelli" <fsimonce@redhat.com>,
>>>> kvm@vger.kernel.org
>>>> Sent: Wednesday, June 15, 2011 12:50:21 PM
>>>> Subject: Re: [PATCH] qemu-img: Add nocache command line option
>>>>
>>>> Your patch confuses a write-through cache (cache=writethrough ==
>>>> O_SYNC)
>>>> with bypassing the cache (cache=none == O_DIRECT), which are
>>>> entirely
>>>> different.
>>>
>>> I know the difference, how am I confusing them in the patch?
>>> I am using BDRV_O_NOCACHE which is translated to O_DIRECT, which is
>>> what I wanted to use (as per commit message: nocache).
>>> Maybe I overlooked something, can you point me to the code parts you
>>> suppose are wrong?
>>
>> The first thing that I noticed is that you call it write-through in
>> the
>> help message. But you also unset BDRV_O_CACHE_WB, while cache=none is
>> a
>> write-back cache mode, in fact.
>
> You are totally right, I overlooked the help message!
> What confuses me is that cache=none shouldn't be write-back (strictly
> speaking), but it probably does just to avoid the use of O_DIRECT
> with O_DSYNC:
And this is exactly what makes it a write-back mode.
I know that people often don't expect this, but even though we're
bypassing the host page cache, it's a write-back mode. The data might be
cached in a volatile write cache of the disk, for example.
> [blockdev.c:330]
>
> if (!strcmp(buf, "off") || !strcmp(buf, "none")) {
> bdrv_flags |= BDRV_O_NOCACHE | BDRV_O_CACHE_WB;
> } else if [...]
>
> [block/raw-posix.c:203]
>
> if ((bdrv_flags & BDRV_O_NOCACHE))
> s->open_flags |= O_DIRECT;
> if (!(bdrv_flags & BDRV_O_CACHE_WB))
> s->open_flags |= O_DSYNC;
>
>>>>> IMO better to use the existing qemu option format, say -o
>>>>> cache=writeback|writethrough|none|volatile.
>>>>
>>>> No, -o is used with qemu-img create for options that change what
>>>> the
>>>> image will look like (e.g. setting flags in the image header). This
>>>> options is about the cache mode that is used for various
>>>> operations.
>>>
>>> Actually I am just working over this. I am going to add a qemu-img
>>> specific option, roughly something like this:
>>>
>>> static QEMUOptionParameter qemuimg_options[] = {
>>> {
>>> .name = QEMUIMG_OPT_CACHE,
>>> .type = OPT_STRING,
>>> .help = "Write cache method"
>>> },
>>> { NULL }
>>> };
>>> [...]
>>> create_options = append_option_parameters(create_options,
>>> qemuimg_options);
>>> [...]
>>> /* Setting output cache flag */
>>> out_flags = BDRV_O_RDWR | BDRV_O_NO_FLUSH;
>>> ret = qemuimg_option_cache(param, &out_flags);
>>> if (ret < 0) {
>>> goto out;
>>> }
>>
>> My concerns were not about the implementation (I'm sure that you can
>> do
>> that), but rather on a conceptual level. Persistent image options are
>> semantically different from options only used for the qemu-img
>> operation, so mixing the two things gives you a bad user interface.
>
> What I understood was that we were trying to conform to the qemu-kvm
> -drive option which already looks very similar:
>
> cache=<mode>,format=<fmt>,...
>
> So in the final analysis which one do you prefer?
>
> qemu-img -t none|writeback|writethrough ...
> qemu-img -o cache=none|writeback|writethrough ...
I would pick the former.
Maybe we can even use a cache=<mode>,format=<fmt> style thing that
resembles -drive. Just don't make it -o but something separate.
Kevin
next prev parent reply other threads:[~2011-06-15 12:23 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-14 12:09 [PATCH] qemu-img: Add nocache command line option Federico Simoncelli
2011-06-14 13:13 ` Avi Kivity
2011-06-15 10:50 ` Kevin Wolf
2011-06-15 11:17 ` Federico Simoncelli
2011-06-15 11:45 ` Kevin Wolf
2011-06-15 12:15 ` Federico Simoncelli
2011-06-15 12:26 ` Kevin Wolf [this message]
2011-06-15 13:46 ` [PATCH] qemu-img: Add cache " Federico Simoncelli
2011-06-15 13:46 ` [Qemu-devel] " Federico Simoncelli
2011-06-15 13:51 ` [PATCHv2] " Federico Simoncelli
2011-06-15 13:51 ` [Qemu-devel] " Federico Simoncelli
2011-06-16 11:58 ` [PATCHv3] " Federico Simoncelli
2011-06-16 11:58 ` [Qemu-devel] " Federico Simoncelli
2011-06-16 14:28 ` [Qemu-devel] [PATCH] " Christoph Hellwig
2011-06-16 14:28 ` Christoph Hellwig
2011-06-16 14:43 ` Kevin Wolf
2011-06-16 14:43 ` Kevin Wolf
2011-06-20 14:47 ` Kevin Wolf
2011-06-20 16:48 ` [PATCHv4] " Federico Simoncelli
2011-06-20 16:48 ` [Qemu-devel] " Federico Simoncelli
2011-06-29 9:48 ` Kevin Wolf
2011-06-29 9:48 ` [Qemu-devel] " Kevin Wolf
2011-06-16 14:44 ` [Qemu-devel] [PATCH] " Federico Simoncelli
2011-06-16 14:44 ` Federico Simoncelli
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=4DF8A4FD.6050807@redhat.com \
--to=kwolf@redhat.com \
--cc=avi@redhat.com \
--cc=fsimonce@redhat.com \
--cc=kvm@vger.kernel.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.