qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ari Sundholm <ari@tuxera.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org,
	Aapo Vienamo <aapo@tuxera.com>
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 1/5] block: Add blklogwrites
Date: Thu, 7 Jun 2018 16:13:05 +0300	[thread overview]
Message-ID: <5767dab6-12c7-a83c-45a3-06c55be359d0@tuxera.com> (raw)
In-Reply-To: <20180607123056.GG19032@stefanha-x1.localdomain>

On 06/07/2018 03:30 PM, Stefan Hajnoczi wrote:
> On Mon, Jun 04, 2018 at 03:10:47PM +0300, Ari Sundholm wrote:
>> On 06/04/2018 12:51 PM, Stefan Hajnoczi wrote:
>>> On Fri, Jun 01, 2018 at 05:24:53PM +0300, Ari Sundholm wrote:
>>>> On 06/01/2018 04:32 PM, Stefan Hajnoczi wrote:
>>>>> On Fri, Jun 01, 2018 at 12:17:19AM +0300, Ari Sundholm wrote:
>>>>>> From: Aapo Vienamo <aapo@tuxera.com>
>>>>>
>>>>> Thanks for the patch!
>>>>>
>>>>>> Implements a block device write logging system, similar to Linux kernel
>>>>>> device mapper dm-log-writes. The write operations that are performed
>>>>>> on a block device are logged to a file or another block device. The
>>>>>> write log format is identical to the dm-log-writes format. Currently,
>>>>>> log markers are not supported.
>>>>>>
>>>>>> This functionality can be used for fail-safe and fs consistency
>>>>>> testing. By implementing it in qemu, tests utilizing write logs can be
>>>>>> be used to test non-Linux drivers and older kernels.
>>>>>
>>>>> This patch doesn't implement the same semantics as dm-log-writes, where
>>>>> only completed writes are logged to make fs consistency testing easier.
>>>>> If you intend to use it for this purpose, shouldn't it act the same way
>>>>> as dm-log-writes?
>>>>>
>>>>
>>>> I am not quite sure what you mean. I am not the original author of this
>>>> proposed feature, but to me (admittedly with little experience of qemu
>>>> internals), it looks like the driver accurately logs the writes and flushes
>>>> performed on the guest block device. It intentionally does not concern
>>>> itself with when the write actually hits the physical host block device or
>>>> file, as we're interested in the direct interactions between a filesystem
>>>> driver and the guest block device. The write hitting the various levels of
>>>> the host-side caches and devices is left up to the caching mode. But perhaps
>>>> there's something obvious I'm not seeing?
>>>
>>> Linux dm-log-writes is specific about when logging happens:
>>>
>>>    * We log writes only after they have been flushed, this makes the log describe
>>>    * close to the order in which the data hits the actual disk, not its cache.  So
>>>    * for example the following sequence (W means write, C means complete)
>>>    *
>>>    * Wa,Wb,Wc,Cc,Ca,FLUSH,FUAd,Cb,CFLUSH,CFUAd
>>>    *
>>>    * Would result in the log looking like this:
>>>    *
>>>    * c,a,flush,fuad,b,<other writes>,<next flush>
>>>    *
>>>    * This is meant to help expose problems where file systems do not properly wait
>>>    * on data being written before invoking a FLUSH.  FUA bypasses cache so once it
>>>    * completes it is added to the log as it should be on disk.
>>>
>>> This patch implements the same on-disk format but the semantics are
>>> different since it doesn't wait for a flush.
>>>
>>> If I use dm-log-writes on a linear device-mapper target inside the guest
>>> or on the host, then I would have expected the same output as QEMU's
>>> dm-log-writes, but I think this is not the case.
>>>
>>> It's worth at least documenting this quirk.
>>
>> Oh, now I see what you mean.
>>
>> I was under the impression that when we do the logging at the level it is
>> done now, we see the actual writes to the guest block device to completion,
>> as far as the guest is concerned (being safely in the host's page cache is
>> enough for this). Is this understanding incorrect?
> 
> .bdrv_co_pwritev is called on request submission.
> blk_log_writes_co_log() spawns a coroutine for
> blk_log_writes_co_do_log(), which appends a struct log_write_entry to
> the log file independently of the other coroutine that is doing the
> actual write to the underlying file.
> 
> This means the entry could be added to the log file before the write
> request completes.
> 
> If you want to log on request completion then you cannot spawn the log
> coroutine in parallel with the write coroutine.  Instead you would have
> to complete the write and then update the log.
> 

Thank you. I can't believe I missed that...

Will be fixed in next version by making things sequential.

>> Regarding the issue of waiting for flushes, as it is now, the driver only
>> updates the superblock of the log on flush, and everything in the log
>> file/device beyond the limits set by the values in the superblock is
>> typically ignored as garbage by tools handling dm-log-writes logs. (I wonder
>> if dm-log-writes actually works similarly by exploiting this fact?)
> 
> This does work in the current patch because the log is updated before
> the write has completed.
> 
> Stefan
> 

Best regards,
Ari Sundholm
ari@tuxera.com

      reply	other threads:[~2018-06-07 13:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-31 21:17 [Qemu-devel] [PATCH 1/5] block: Add blklogwrites Ari Sundholm
2018-05-31 21:17 ` [Qemu-devel] [PATCH 2/5] block: Add a mechanism for passing a block driver a block configuration Ari Sundholm
2018-05-31 21:17   ` [Qemu-devel] [PATCH 3/5] hw/scsi/scsi-disk: Always apply block configuration to block driver Ari Sundholm
2018-05-31 21:17     ` [Qemu-devel] [PATCH 4/5] block/blklogwrites: Use block limits from the backend block configuration Ari Sundholm
2018-05-31 21:17       ` [Qemu-devel] [PATCH 5/5] block/blklogwrites: Use the block device logical sector size when logging writes Ari Sundholm
2018-06-01 12:26 ` [Qemu-devel] [PATCH 1/5] block: Add blklogwrites Eric Blake
2018-06-01 13:31   ` Ari Sundholm
2018-06-01 15:05     ` Eric Blake
2018-06-01 15:15       ` Ari Sundholm
2018-06-01 15:44         ` Eric Blake
2018-06-04  9:59   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2018-06-01 13:32 ` Stefan Hajnoczi
2018-06-01 14:24   ` Ari Sundholm
2018-06-04  9:51     ` Stefan Hajnoczi
2018-06-04 12:10       ` Ari Sundholm
2018-06-07 12:30         ` Stefan Hajnoczi
2018-06-07 13:13           ` Ari Sundholm [this message]

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=5767dab6-12c7-a83c-45a3-06c55be359d0@tuxera.com \
    --to=ari@tuxera.com \
    --cc=aapo@tuxera.com \
    --cc=qemu-block@nongnu.org \
    --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).