qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Claudio Fontana <cfontana@suse.de>
To: Lin Ma <lma@suse.com>, qemu-devel@nongnu.org
Cc: Fam Zheng <fam@euphon.net>, pbonzini@redhat.com, stefanha@redhat.com
Subject: Re: [PATCH 1/4] block: Add bdrv_co_get_lba_status
Date: Wed, 3 Jun 2020 16:46:33 +0200	[thread overview]
Message-ID: <40137f16-2be0-e9c1-32be-e3567a7a9b82@suse.de> (raw)
In-Reply-To: <20200602074201.10879-2-lma@suse.com>

Hi Lin,

just a couple of things, leaving the core aspects to more knowledgeable people in this area to address.

In general, you want all patches in the series to build correctly.

Applying only PATCH 1/4 breaks the build for me with:

/home/claudio/git/qemu/block/io.c:2190:1: error: no previous prototype for ‘bdrv_co_get_lba_status’ [-Werror=missing-prototypes]
 bdrv_co_get_lba_status(BdrvChild *child, int64_t offset, int64_t bytes,
 ^~~~~~~~~~~~~~~~~~~~~~
/home/claudio/git/qemu/block/io.c: In function ‘bdrv_co_get_lba_status’:
/home/claudio/git/qemu/block/io.c:2194:9: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     int ret;
         ^~~
cc1: all warnings being treated as errors

On 6/2/20 9:41 AM, Lin Ma wrote:
> The get lba status wrapper based on the bdrv_block_status. The following
> patches will add GET LBA STATUS 16 support for scsi emulation layer.
> 
> Signed-off-by: Lin Ma <lma@suse.com>
> ---
>  block/io.c | 43 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
> 
> diff --git a/block/io.c b/block/io.c
> index 121ce17a49..dacc3c2471 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -2186,6 +2186,49 @@ int coroutine_fn bdrv_co_pwrite_zeroes(BdrvChild *child, int64_t offset,
>                             BDRV_REQ_ZERO_WRITE | flags);
>  }
>  
> +int coroutine_fn
> +bdrv_co_get_lba_status(BdrvChild *child, int64_t offset, int64_t bytes,
> +                       uint32_t *num_blocks, uint32_t *is_deallocated)
> +{
> +    BlockDriverState *bs = child->bs;
> +    int ret;
> +    int64_t target_size, count = 0;
> +    bool first = true;
> +    uint8_t wanted_bit1 = 0;
> +
> +    target_size = bdrv_getlength(bs);
> +    if (target_size < 0) {
> +        return -EIO;
> +    }
> +
> +    if (offset < 0 || bytes < 0) {
> +        return -EIO;
> +    }
> +
> +    for ( ; offset <= target_size - bytes; offset += count) {
> +        ret = bdrv_block_status(bs, offset, bytes, &count, NULL, NULL);
> +        if (ret < 0) {
> +            goto out;
> +        }
> +        if (first) {
> +            if (ret & BDRV_BLOCK_ZERO) {
> +                wanted_bit1 = BDRV_BLOCK_ZERO >> 1;;

extra ; at the end of the line

> +                *is_deallocated = 1;
> +            } else {
> +                wanted_bit1 = 0;
> +            }
> +            first = false;
> +        }
> +        if ((ret & BDRV_BLOCK_ZERO) >> 1 == wanted_bit1) {
> +            (*num_blocks)++;
> +        } else {
> +            break;
> +        }
> +    }
> +out:
> +    return ret;
> +}
> +
>  /*
>   * Flush ALL BDSes regardless of if they are reachable via a BlkBackend or not.
>   */
> 

Ciao,

CLaudio


  reply	other threads:[~2020-06-03 14:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-02  7:41 [PATCH 0/4] Add Support for GET LBA STATUS 16 command in scsi emulation Lin Ma
2020-06-02  7:41 ` [PATCH 1/4] block: Add bdrv_co_get_lba_status Lin Ma
2020-06-03 14:46   ` Claudio Fontana [this message]
2020-06-02  7:41 ` [PATCH 2/4] block: Add GET LBA STATUS support Lin Ma
2020-06-02  7:42 ` [PATCH 3/4] block: Add block accounting code for GET LBA STATUS Lin Ma
2020-06-03 14:53   ` Claudio Fontana
2020-06-02  7:42 ` [PATCH 4/4] scsi-disk: Add support for the GET LBA STATUS 16 command Lin Ma
2020-06-03 14:51   ` Claudio Fontana
2020-06-02  7:52 ` [PATCH 0/4] Add Support for GET LBA STATUS 16 command in scsi emulation no-reply
2020-06-02  7:53 ` no-reply
2020-06-02  7:54 ` no-reply
2020-06-02  7:56 ` no-reply

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=40137f16-2be0-e9c1-32be-e3567a7a9b82@suse.de \
    --to=cfontana@suse.de \
    --cc=fam@euphon.net \
    --cc=lma@suse.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --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).