From: Eric Blake <eblake@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>, Lin Ma <LMa@suse.com>
Cc: "fam@euphon.net" <fam@euphon.net>,
"kwolf@redhat.com" <kwolf@redhat.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"mreitz@redhat.com" <mreitz@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
"pbonzini@redhat.com" <pbonzini@redhat.com>
Subject: Re: [PATCH v2 3/3] scsi-disk: Add support for the GET LBA STATUS 16 command
Date: Mon, 29 Jun 2020 11:02:04 -0500 [thread overview]
Message-ID: <556bd179-71b5-cbe7-1d8b-eff20e70a7c0@redhat.com> (raw)
In-Reply-To: <20200629103948.GF31392@stefanha-x1.localdomain>
On 6/29/20 5:39 AM, Stefan Hajnoczi wrote:
>>> SCSI defines 3 values and QEMU can represent all of them:
>>>
>>> 0 - mapped or unknown
>>> 1 - deallocated
>>> 2 - anchored
>>>
>>> See the BDRV_BLOCK_* constants in include/block/block.h. The
>>> is_deallocated boolean is not enough to represent this state, but the
>>> bdrv_block_status() return value can be used instead.
>>
>> I don't know which one in BDRV_BLOCK_* can be used to represent 'anchored'.
>> It seems that I need to use BDRV_BLOCK_* combination to recognized 'anchored',
>>
>> I'd like to use these combinations to analyze the bdrv_block_status() return value:
>> 'deallocated': BDRV_BLOCK_ALLOCATED | BDRV_BLOCK_OFFSET_VALID | BDRV_BLOCK_ZERO
>> 'anchored': BDRV_BLOCK_ALLOCATED | BDRV_BLOCK_OFFSET_VALID | ! BDRV_BLOCK_ZERO | ! BDRV_BLOCK_DATA
>> Am I right?
>
> My understanding is that the SCSI status are mapped to QEMU block status
> as follows:
>
> allocated: BDRV_BLOCK_DATA | !BDRV_BLOCK_ZERO | BDRV_BLOCK_OFFSET_VALID
I haven't read the scsi code, but as written, I would assume that any
portion of the block status with this result has the following properties:
- reading sees guest-visible data; we cannot guarantee whether it is all
zero, and the data reserves actual space
> anchored: BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO | BDRV_BLOCK_OFFSET_VALID
- reading sees all zeros, but the disk has reserved actual space such
that future writes will not run out of space
> deallocated: !BDRV_BLOCK_DATA
- reading does not see data; future writes will have to reserve space.
I would expect this option might also have '| BDRV_BLOCK_ZERO' depending
on whether this particular scsi device guarantees that reads of an
unallocated portion see all zeros instead of unspecified garbage.
>
> I have CCed Eric Blake, who is familiar with block status.
Adding Vladimir in CC as well, as he has pending patches that try to
clear up the use of BDRV_BLOCK_* constants with regards to two different
queries:
- allocation implies that data comes from this layer of a backing chain,
rather than deferring to a backing image
- allocation implies that storage is reserved (that is, not sparse)
It sounds like we are trying to represent the second question for scsi
(namely, the same question that gets answered by lseek(SEEK_HOLE) for
POSIX files), and not the first (namely, the question answered for qcow2
images).
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2020-06-29 16:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 13:31 [PATCH v2 3/3] scsi-disk: Add support for the GET LBA STATUS 16 command Lin Ma
2020-06-29 10:39 ` Stefan Hajnoczi
2020-06-29 13:01 ` Paolo Bonzini
2020-06-29 16:02 ` Eric Blake [this message]
2020-06-30 15:40 ` Paolo Bonzini
-- strict thread matches above, loose matches on Subject: below --
2020-06-17 10:30 [PATCH v2 0/3] Add Support for GET LBA STATUS 16 command in scsi emulation Lin Ma
2020-06-17 10:30 ` [PATCH v2 3/3] scsi-disk: Add support for the GET LBA STATUS 16 command Lin Ma
2020-06-22 12:14 ` Stefan Hajnoczi
2020-06-17 10:20 [PATCH v2 0/3] Add Support for GET LBA STATUS 16 command in scsi emulation Lin Ma
2020-06-17 10:20 ` [PATCH v2 3/3] scsi-disk: Add support for the GET LBA STATUS 16 command Lin Ma
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=556bd179-71b5-cbe7-1d8b-eff20e70a7c0@redhat.com \
--to=eblake@redhat.com \
--cc=LMa@suse.com \
--cc=fam@euphon.net \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=stefanha@redhat.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).