From: Kevin Wolf <kwolf@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: Nir Soffer <nirsof@gmail.com>,
qemu-block@nongnu.org, qemu-devel@nongnu.org,
Max Reitz <mreitz@redhat.com>, Nir Soffer <nsoffer@redhat.com>
Subject: Re: [PATCH] nbd: server: Report holes for raw images
Date: Thu, 4 Mar 2021 13:22:11 +0100 [thread overview]
Message-ID: <20210304122211.GB9607@merkur.fritz.box> (raw)
In-Reply-To: <6a714e21-0da5-7eb1-1350-277a25e23be4@virtuozzo.com>
Am 25.02.2021 um 19:50 hat Vladimir Sementsov-Ogievskiy geschrieben:
> 19.02.2021 19:58, Eric Blake wrote:
> > On 2/19/21 10:42 AM, Eric Blake wrote:
> >
> > > > To me, data=false looks compatible with NBD_STATE_HOLE. From user point
> > > > of view, getting same results from qemu-nbd and qemu-img is more
> > > > important than being more correct about allocation status.
> > >
> > > More to the point, here is our inconsistency:
> > >
> > > In nbd/server.c, we turn !BDRV_BLOCK_ALLOCATED into NBD_STATE_HOLE
> > >
> > > In block/nbd.c, we turn !NBD_STATE_HOLE into BDRV_BLOCK_DATA
> > >
> > > The fact that we are not doing a round-trip conversion means that one of
> > > the two places is wrong. And your argument that the server side is
> > > wrong makes sense to me.
> >
> > In fact, when I went back and researched when this was introduced (see
> > commit e7b1948d51 in 2018), we may have been aware of the inconsistency
> > between client and server, but didn't make up our minds at the time:
> > https://lists.gnu.org/archive/html/qemu-devel/2018-03/msg03465.html
> > "? Hm, don't remember, what we decided about DATA/HOLE flags mapping.."
> >
> > >
> > > I'll wait a few days for any other reviewer commentary before taking
> > > this through my NBD tree.
> > >
> >
>
>
> I can add the following.
>
> First, link to my research of block_status in Qemu:
> https://lists.gnu.org/archive/html/qemu-devel/2020-04/msg05136.html
>
> And about HOLE and ZERO..
>
> As I've noted in the research above, SCSI may return HOLE & !ZERO:
>
> from SCSI: Logical Block Provisioning Read Zeros (LBPRZ) bit 1 If
> the logical block provisioning read zeros (LBPRZ) bit is set to one,
> then, for an unmapped LBA specified by a read operation, the
> deviceserver shall send user data with all bits set to zero to the
> data-in buffer. 0 If the TPRZ bit is set to zero, then, for an
> unmapped LBA specified by a read operation, the device server may send
> user data with all bitsset to any value to the data-in buffer.
>
> So we can have an unmapped area that can be read as any random data.
> Same thing can be said about null-co driver with read-zeroes=false
>
> Also, qcow2 support ALLOCATED ZERO clusters which reads as zero but
> data is allocated - they are reasonable to report as ZERO & !HOLE
>
> And of-course UNALLOCATED ZERO clusters in qcow2 and lseek-holes are
> reasonable to report as ZERO & HOLE, because they reads as zero and
> "future writes to that area may cause fragmentation or encounter an
> NBD_ENOSPC"..
>
> So, all combination are reasonable, we just need to fix Qemu NBD
> server to report correct statuses in all these cases.
>
> It seems that ZERO/HOLE specification is a lot more reasonable than
> what we have with ZERO/DATA/ALLOCATED in Qemu, and may be true way is
> move internal block_status to use NBD terms.
Is there not a 1:1 correspondence between our internal flags and the NBD
ones? ZERO is exactly the same, and HOLE is the inversion of DATA.
ALLOCATED is important internally when finding the node in a backing
file chain that actually defines the content, but for a user it doesn't
make a difference. This is why it isn't exposed in NBD.
So I think both QEMU and NBD use the flags that make sense in the
respective context.
Kevin
next prev parent reply other threads:[~2021-03-04 12:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-19 16:07 [PATCH] nbd: server: Report holes for raw images Nir Soffer
2021-02-19 16:42 ` Eric Blake
2021-02-19 16:58 ` Eric Blake
2021-02-25 18:50 ` Vladimir Sementsov-Ogievskiy
2021-03-03 21:45 ` Nir Soffer
2021-03-03 21:51 ` Eric Blake
2021-03-04 12:22 ` Kevin Wolf [this message]
2021-02-25 18:15 ` Vladimir Sementsov-Ogievskiy
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=20210304122211.GB9607@merkur.fritz.box \
--to=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=nirsof@gmail.com \
--cc=nsoffer@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.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).