qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rjones@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: josh.durgin@dreamhost.com, tailai.ly@taobao.com,
	Peter Lieven <pl@kamp.de>,
	qemu-devel@nongnu.org, stefanha@redhat.com,
	bharata@linux.vnet.ibm.com, morita.kazutaka@lab.ntt.co.jp
Subject: Re: [Qemu-devel] block: Review of .has_zero_init use
Date: Tue, 25 Jun 2013 13:05:33 +0100	[thread overview]
Message-ID: <20130625120533.GP1882@redhat.com> (raw)
In-Reply-To: <20130625113911.GD3539@dhcp-200-207.str.redhat.com>

On Tue, Jun 25, 2013 at 01:39:11PM +0200, Kevin Wolf wrote:
> * ssh           - currently has_zero_init = 1 (is this correct?)
[...]
> It might be possible that the correct value depends on the backend on
> the server side for some protocols - for example, I think for SSH it
> depends on whether you access a regular file or a block device on the
> other host (if accessing a block device is even possible).

This seems to depend on the behaviour of O_TRUNC on block devices.
The man page says it's unspecified, but I tested it on Linux, and
Linux ignores it (for logical volumes anyway).

When the ssh driver is asked to do bdrv_create it does on the
remote end:

 - open (filename, O_RDWR|O_CREAT|O_TRUNC, 0644) [1]
 - lseek (fd, size-1, SEEK_SET)                  [2]
 - write (fd, &'\0', 1)

In other words for regular files, it creates a sparse file.  For block
devices, I tested the sequence above, and it doesn't fail.

So .. I guess that has_zero_init = 0 would be correct?

Unless we fstat the fd after opening it and return some conditional
value from bdrv_has_zero_init eg if it's a block device.  Is that
possible?

Rich.

[1] Mode 0644 is hard-coded :-(

[2] I realize now it's actually possible to use ftruncate, although
it's not obvious.  There is no explicit truncate operation in sftp.
But there is a "setattr" operation, which if you try to set the size
attr in fact does a truncate at the remote end.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/

  reply	other threads:[~2013-06-25 12:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-25 11:39 [Qemu-devel] block: Review of .has_zero_init use Kevin Wolf
2013-06-25 12:05 ` Richard W.M. Jones [this message]
2013-06-25 12:27   ` Kevin Wolf
2013-06-25 13:11 ` MORITA Kazutaka
2013-06-25 13:20   ` Kevin Wolf
2013-06-25 13:42     ` MORITA Kazutaka
2013-06-25 13:45       ` Kevin Wolf
2013-06-25 15:06 ` Josh Durgin
2013-06-26  3:14 ` Bharata B Rao
2013-06-26  5:59   ` Peter Lieven
2013-06-26  6:46     ` Bharata B Rao
2013-06-26  7:36       ` Kevin Wolf

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=20130625120533.GP1882@redhat.com \
    --to=rjones@redhat.com \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=josh.durgin@dreamhost.com \
    --cc=kwolf@redhat.com \
    --cc=morita.kazutaka@lab.ntt.co.jp \
    --cc=pl@kamp.de \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=tailai.ly@taobao.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).