All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>,
	kwolf@redhat.com, Xiao Guangrong <guangrong.xiao@linux.intel.com>,
	Peter Crosthwaite <crosthwaite.peter@gmail.com>,
	qemu-devel@nongnu.org, mreitz@redhat.com,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH] hostmem-file: add a property 'notrunc' to avoid data corruption
Date: Thu, 20 Oct 2016 13:14:22 -0200	[thread overview]
Message-ID: <20161020151422.GC5057@thinpad.lan.raisama.net> (raw)
In-Reply-To: <20161020142253.g3xmizuq43s6r7pq@hz-desktop>

On Thu, Oct 20, 2016 at 10:22:53PM +0800, Haozhong Zhang wrote:
> On 10/20/16 11:56 -0200, Eduardo Habkost wrote:
> > On Thu, Oct 20, 2016 at 03:42:15PM +0200, Igor Mammedov wrote:
> > > On Thu, 20 Oct 2016 21:11:38 +0800
> > > Haozhong Zhang <haozhong.zhang@intel.com> wrote:
> > > 
> > > > On 10/20/16 14:34 +0200, Igor Mammedov wrote:
> > > > >On Thu, 20 Oct 2016 14:13:01 +0800
> > > > >Haozhong Zhang <haozhong.zhang@intel.com> wrote:
> > > > >
> > > > >> If a file is used as the backend of memory-backend-file and its size is
> > > > >> not identical to the property 'size', the file will be truncated. For a
> > > > >> file used as the backend of vNVDIMM, its data is expected to be
> > > > >> persistent and the truncation may corrupt the existing data.
> > > > >I wonder if it's possible just skip 'size' property in your case instead
> > > > >'notrunc' property. That way if size is not present one'd get actual size
> > > > >using get_file_size() and set 'size' to it?
> > > > >And if 'size' is provided and 'size' != file_size then error out.
> > > > >
> > > >
> > > > I don't know how this can be implemented in QEMU. Specially, how does
> > > > the memory-backend-file know it's used for vNVDIMM, so that it can
> > > > skip the 'size' property?
> > > Does memory-backend-file needs to know that it's used by NVDIMM?
> > > Looking at nvdimm_realize it doesn't as it's assumes
> > >   hostemem_size == pmem_size + label_size
> > > 
> > > I'd make hostmem_file.size optional and take size from file
> > > and if 'size' is specified explictly require it to mach file size.
> > > It's generic and has nothing to do with nvdimm.
> > 
> > We can take size from file, or take size from the
> > host_memory_backend_get_memory() callers.
> > 
> > Enumerating all sizes that QEMU can use as input:
> > 
> > A) Backend file size
> > B) memory backend "size" option
> > C) frontend-provided size (-numa size, -m, or pc-dimm "size"
> >    property)
> > 
> > My suggestion is:
> > * B should be optional.
> > * If B is omitted, we should never truncate the file to a smaller
> >  size.
> > * If B is omitted, we can use C as the size when mapping the
> >  file.
> > * If B is omitted, and C > A, maybe we could use ftruncate() to
> >  extend the file to make users happy. But I'm not sure we
> >  should (I think B should be the only option that cause
> >  truncation).
> 
> For the words in parentheses, I have one question: what does size B mean?
> 1) The user knows the file size is the one specified (size B),
>   and, if it's not, all bad results are user's fault.

The only use case I see for B is to force allocation and
ftruncate to a larger size. All other uses should be covered by
C. But note that Igor and I are having an ongoing discussion in
this thread about using C vs A/B.

> or
> 2) The user wants only the part of size B is used. How the other part
>   is used is unspecified, which, I think, implies the user does not
>   expect QEMU to touch it.

We don't have an option meaning "please touch only this specific
region of the file, leave the rest alone". In this case, not
truncating even when "size" is explicitly set would make sense.

If we wanted that "please don't touch the rest of the file" mode
to be supported, this doesn't seem to be the use case we have in
mind right now, does it? If we did, I believe we would have an
"offset" parameter too.

> If it's 1), I think it's reasonable to truncate when B is given.
> Otherwise, if B is given, QEMU can truncate the file only if B > A.

I would say it's still (1), but we don't need to truncate the
file if B < A, so we can avoid it because it's safer.

> 
> Haozhong
> 
> > * If we want to make C optional on some cases, we could use A if
> >  B is omitted.
> > 
> > Does that make sense?
> > 
> > -- 
> > Eduardo

-- 
Eduardo

  reply	other threads:[~2016-10-20 15:14 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-20  6:13 [Qemu-devel] [PATCH] hostmem-file: add a property 'notrunc' to avoid data corruption Haozhong Zhang
2016-10-20  6:35 ` no-reply
2016-10-20 12:34 ` Igor Mammedov
2016-10-20 13:11   ` Haozhong Zhang
2016-10-20 13:34     ` Eduardo Habkost
2016-10-20 13:47       ` Haozhong Zhang
2016-10-20 13:42     ` Igor Mammedov
2016-10-20 13:56       ` Eduardo Habkost
2016-10-20 14:15         ` Igor Mammedov
2016-10-20 14:47           ` Eduardo Habkost
2016-10-20 15:35             ` Igor Mammedov
2016-10-20 16:56               ` Eduardo Habkost
2016-10-21  9:31                 ` Igor Mammedov
2016-10-21 11:53                   ` Eduardo Habkost
2016-10-21 13:26                     ` Igor Mammedov
2016-10-21  7:22               ` Haozhong Zhang
2016-10-21 11:07                 ` Igor Mammedov
2016-10-21 11:25                   ` Haozhong Zhang
2016-10-21 11:56                   ` Eduardo Habkost
2016-10-20 14:22         ` Haozhong Zhang
2016-10-20 15:14           ` Eduardo Habkost [this message]
2016-10-20 13:56       ` Haozhong Zhang
2016-10-20 13:21   ` Eduardo Habkost
2016-10-20 13:33     ` Haozhong Zhang
2016-10-20 13:47       ` Eduardo Habkost
2016-10-20 14:17         ` Igor Mammedov
2016-10-20 15:15           ` Eduardo Habkost
2016-10-20 15:41             ` Igor Mammedov
2016-10-20 16:59               ` Eduardo Habkost
2016-10-21 10:28                 ` Igor Mammedov
2016-10-21 11:44                   ` Eduardo Habkost
2016-10-20 13:47       ` Igor Mammedov
2016-10-20 13:57         ` Eduardo Habkost
2016-10-20 14:18           ` Igor Mammedov
2016-10-20 15:00             ` Eduardo Habkost
2016-10-20 15:14               ` Igor Mammedov
2016-10-20 13:27   ` Daniel P. Berrange
2016-10-20 13:40     ` Eduardo Habkost
2016-10-20 13:54     ` Igor Mammedov
2016-10-20 13:55   ` Kevin Wolf
2016-10-24 13:10     ` Eduardo Habkost
2016-10-25  6:42       ` Haozhong Zhang
2016-10-25 10:01         ` Eduardo Habkost

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=20161020151422.GC5057@thinpad.lan.raisama.net \
    --to=ehabkost@redhat.com \
    --cc=crosthwaite.peter@gmail.com \
    --cc=guangrong.xiao@linux.intel.com \
    --cc=imammedo@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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.