From: Eric Blake <eblake@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org, famz@redhat.com, qemu-block@nongnu.org,
Ronnie Sahlberg <ronniesahlberg@gmail.com>,
Paolo Bonzini <pbonzini@redhat.com>, Peter Lieven <pl@kamp.de>,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v8 08/21] iscsi: Switch to .bdrv_co_block_status()
Date: Wed, 14 Feb 2018 08:33:30 -0600 [thread overview]
Message-ID: <1301339a-7d74-3deb-0f9c-b765951aa546@redhat.com> (raw)
In-Reply-To: <20180214115312.GA4766@localhost.localdomain>
On 02/14/2018 05:53 AM, Kevin Wolf wrote:
> Am 13.02.2018 um 21:26 hat Eric Blake geschrieben:
>> We are gradually moving away from sector-based interfaces, towards
>> byte-based. Update the iscsi driver accordingly. In this case,
>> it is handy to teach iscsi_co_block_status() to handle a NULL map
>> and file parameter, even though the block layer passes non-NULL
>> values, because we also call the function directly. For now, there
>> are no optimizations done based on the want_zero flag.
[1]
>>
>> We can also make the simplification of asserting that the block
>> layer passed in aligned values.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> Reviewed-by: Fam Zheng <famz@redhat.com>
>>
>> /* default to all sectors allocated */
>> - ret = BDRV_BLOCK_DATA;
>> - ret |= (sector_num << BDRV_SECTOR_BITS) | BDRV_BLOCK_OFFSET_VALID;
>> - *pnum = nb_sectors;
>> + ret = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID;
>> + if (map) {
>> + *map = offset;
>> + }
>
> Can map ever be NULL? You didn't have that check in other drivers.
The documentation in block_int.h states that io.c never passes NULL for
map. However, see my commit message [1], and the code below [2], for
why THIS driver has to check for NULL.
>> @@ -760,7 +758,7 @@ out:
>> if (iTask.task != NULL) {
>> scsi_free_scsi_task(iTask.task);
>> }
>> - if (ret > 0 && ret & BDRV_BLOCK_OFFSET_VALID) {
>> + if (ret > 0 && ret & BDRV_BLOCK_OFFSET_VALID && file) {
>> *file = bs;
>> }
>
> Can file ever be NULL?
Ditto.
>
>> return ret;
>> @@ -800,25 +798,24 @@ static int coroutine_fn iscsi_co_readv(BlockDriverState *bs,
>> nb_sectors * BDRV_SECTOR_SIZE) &&
>
> No iscsi_co_preadv() yet... :-(
Yeah, but that's for another day.
>
>> !iscsi_allocmap_is_allocated(iscsilun, sector_num * BDRV_SECTOR_SIZE,
>> nb_sectors * BDRV_SECTOR_SIZE)) {
>> - int pnum;
>> - BlockDriverState *file;
>> + int64_t pnum;
>> /* check the block status from the beginning of the cluster
>> * containing the start sector */
>> - int cluster_sectors = iscsilun->cluster_size >> BDRV_SECTOR_BITS;
>> - int head;
>> - int64_t ret;
>> + int64_t head;
>> + int ret;
>>
>> - assert(cluster_sectors);
>> - head = sector_num % cluster_sectors;
>> - ret = iscsi_co_get_block_status(bs, sector_num - head,
>> - BDRV_REQUEST_MAX_SECTORS, &pnum,
>> - &file);
>> + assert(iscsilun->cluster_size);
>> + head = (sector_num * BDRV_SECTOR_SIZE) % iscsilun->cluster_size;
>> + ret = iscsi_co_block_status(bs, false,
>> + sector_num * BDRV_SECTOR_SIZE - head,
>> + BDRV_REQUEST_MAX_BYTES, &pnum, NULL, NULL);
>
[2] This is the reason that THIS driver has to check for NULL, even
though the block layer never passes NULL.
> It doesn't make a difference with your current implementation because it
> ignores want_zero, but consistent with your approach that
> want_zero=false returns just that everyhting is allocated for drivers
> without support for backing files, I think you want want_zero=true here.
Makes sense. If that's the only tweak, can you make it while taking the
series, or will I need to respin?
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2018-02-14 14:34 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-13 20:26 [Qemu-devel] [PATCH v8 00/21] add byte-based block_status driver callbacks Eric Blake
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 01/21] block: Add .bdrv_co_block_status() callback Eric Blake
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 02/21] nvme: Drop pointless .bdrv_co_get_block_status() Eric Blake
2018-02-14 17:41 ` Philippe Mathieu-Daudé
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 03/21] block: Switch passthrough drivers to .bdrv_co_block_status() Eric Blake
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 04/21] file-posix: Switch " Eric Blake
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 05/21] gluster: " Eric Blake
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 06/21] iscsi: Switch cluster_sectors to byte-based Eric Blake
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 07/21] iscsi: Switch iscsi_allocmap_update() " Eric Blake
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 08/21] iscsi: Switch to .bdrv_co_block_status() Eric Blake
2018-02-14 11:53 ` Kevin Wolf
2018-02-14 14:33 ` Eric Blake [this message]
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 09/21] null: " Eric Blake
2018-02-14 12:05 ` Kevin Wolf
2018-02-14 14:44 ` Eric Blake
2018-02-14 14:55 ` Kevin Wolf
2018-02-23 16:43 ` Eric Blake
2018-02-23 17:05 ` Kevin Wolf
2018-02-23 23:38 ` Eric Blake
2018-02-26 14:05 ` Kevin Wolf
2018-03-01 7:25 ` Vladimir Sementsov-Ogievskiy
2018-03-01 9:48 ` Kevin Wolf
2018-03-01 9:57 ` Vladimir Sementsov-Ogievskiy
2018-03-01 10:13 ` Kevin Wolf
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 10/21] parallels: " Eric Blake
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 11/21] qcow: " Eric Blake
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 12/21] qcow2: " Eric Blake
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 13/21] qed: " Eric Blake
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 14/21] raw: " Eric Blake
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 15/21] sheepdog: " Eric Blake
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 16/21] vdi: Avoid bitrot of debugging code Eric Blake
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 17/21] vdi: Switch to .bdrv_co_block_status() Eric Blake
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 18/21] vmdk: " Eric Blake
2018-02-13 20:26 ` [Qemu-devel] [PATCH v8 19/21] vpc: " Eric Blake
2018-02-14 13:08 ` Kevin Wolf
2018-02-14 14:51 ` Eric Blake
2018-02-13 20:27 ` [Qemu-devel] [PATCH v8 20/21] vvfat: " Eric Blake
2018-02-14 13:12 ` Kevin Wolf
2018-02-14 14:50 ` Eric Blake
2018-02-14 15:00 ` Kevin Wolf
2018-02-13 20:27 ` [Qemu-devel] [PATCH v8 21/21] block: Drop unused .bdrv_co_get_block_status() Eric Blake
2018-02-14 17:11 ` [Qemu-devel] [PATCH v8 00/21] add byte-based block_status driver callbacks 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=1301339a-7d74-3deb-0f9c-b765951aa546@redhat.com \
--to=eblake@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pl@kamp.de \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=ronniesahlberg@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).