qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Ashish Mittal <ashmit602@gmail.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, kwolf@redhat.com,
	armbru@redhat.com, berrange@redhat.com, jcody@redhat.com,
	famz@redhat.com, ashish.mittal@veritas.com,
	Ketan.Nilangekar@veritas.com, Abhijit.Dey@veritas.com
Subject: Re: [Qemu-devel] [PATCH v7 RFC] block/vxhs: Initial commit to add Veritas HyperScale VxHS block device support
Date: Wed, 28 Sep 2016 12:13:32 +0100	[thread overview]
Message-ID: <20160928111332.GD4196@stefanha-x1.localdomain> (raw)
In-Reply-To: <1475035789-685-1-git-send-email-ashish.mittal@veritas.com>

[-- Attachment #1: Type: text/plain, Size: 4749 bytes --]

On Tue, Sep 27, 2016 at 09:09:49PM -0700, Ashish Mittal wrote:
> +vxhs_bdrv_init(const char c) "Registering VxHS AIO driver%c"

Why do several trace events have a %c format specifier at the end and it
always takes a '.' value?

> +#define QNIO_CONNECT_TIMOUT_SECS    120

This isn't used and there is a typo (s/TIMOUT/TIMEOUT/).  Can it be
dropped?

> +static int32_t
> +vxhs_qnio_iio_ioctl(void *apictx, uint32_t rfd, uint32_t opcode, int64_t *in,
> +                    void *ctx, uint32_t flags)
> +{
> +    int   ret = 0;
> +
> +    switch (opcode) {
> +    case VDISK_STAT:

It seems unnecessary to abstract the iio_ioctl() constants and then have
a switch statement to translate to the actual library constants.  It
makes little sense since the flags argument already uses the library
constants.  Just use the library's constants.

> +        ret = iio_ioctl(apictx, rfd, IOR_VDISK_STAT,
> +                                     in, ctx, flags);
> +        break;
> +
> +    case VDISK_AIO_FLUSH:
> +        ret = iio_ioctl(apictx, rfd, IOR_VDISK_FLUSH,
> +                                     in, ctx, flags);
> +        break;
> +
> +    case VDISK_CHECK_IO_FAILOVER_READY:
> +        ret = iio_ioctl(apictx, rfd, IOR_VDISK_CHECK_IO_FAILOVER_READY,
> +                                     in, ctx, flags);
> +        break;
> +
> +    default:
> +        ret = -ENOTSUP;
> +        break;
> +    }
> +
> +    if (ret) {
> +        *in = 0;

Some callers pass in = NULL so this will crash.

The naming seems wrong: this is an output argument, not an input
argument.  Please call it "out_val" or similar.

> +    res = vxhs_reopen_vdisk(s, s->vdisk_ask_failover_idx);
> +    if (res == 0) {
> +        res = vxhs_qnio_iio_ioctl(s->qnio_ctx,
> +                  s->vdisk_hostinfo[s->vdisk_ask_failover_idx].vdisk_rfd,
> +                  VDISK_CHECK_IO_FAILOVER_READY, NULL, s, flags);

Looking at iio_ioctl(), I'm not sure how this can ever work.  The fourth
argument is NULL and iio_ioctl() will attempt *vdisk_size = 0 so this
will crash.

Do you have tests that exercise this code path?

> +/*
> + * This is called by QEMU when a flush gets triggered from within
> + * a guest at the block layer, either for IDE or SCSI disks.
> + */
> +static int vxhs_co_flush(BlockDriverState *bs)

This is called from coroutine context, please add the coroutine_fn
function attribute to document this.

> +{
> +    BDRVVXHSState *s = bs->opaque;
> +    int64_t size = 0;
> +    int ret = 0;
> +
> +    /*
> +     * VDISK_AIO_FLUSH ioctl is a no-op at present and will
> +     * always return success. This could change in the future.
> +     */
> +    ret = vxhs_qnio_iio_ioctl(s->qnio_ctx,
> +            s->vdisk_hostinfo[s->vdisk_cur_host_idx].vdisk_rfd,
> +            VDISK_AIO_FLUSH, &size, NULL, IIO_FLAG_SYNC);

This function is not allowed to block.  It cannot do a synchronous
flush.  This line is misleading because the constant is called
VDISK_AIO_FLUSH, but looking at the library code I see it's actually a
synchronous call that ends up in a loop that sleeps (!) waiting for the
response.

Please do an async flush and qemu_coroutine_yield() to return
control to QEMU's event loop.  When the flush completes you can
qemu_coroutine_enter() again to return from this function.

> +
> +    if (ret < 0) {
> +        trace_vxhs_co_flush(s->vdisk_guid, ret, errno);
> +        vxhs_close(bs);

This looks unsafe.  Won't it cause double close() calls for s->fds[]
when bdrv_close() is called later?

> +    }
> +
> +    return ret;
> +}
> +
> +static unsigned long vxhs_get_vdisk_stat(BDRVVXHSState *s)

sizeof(unsigned long) = 4 on some machines, please change it to int64_t.

I also suggest changing the function name to vxhs_get_vdisk_size() since
it only provides the size.

> +static int64_t vxhs_get_allocated_blocks(BlockDriverState *bs)
> +{
> +    BDRVVXHSState *s = bs->opaque;
> +    int64_t vdisk_size = 0;
> +
> +    if (s->vdisk_size > 0) {
> +        vdisk_size = s->vdisk_size;
> +    } else {
> +        /*
> +         * TODO:
> +         * Once HyperScale storage-virtualizer provides
> +         * actual physical allocation of blocks then
> +         * fetch that information and return back to the
> +         * caller but for now just get the full size.
> +         */
> +        vdisk_size = vxhs_get_vdisk_stat(s);
> +        if (vdisk_size > 0) {
> +            s->vdisk_size = vdisk_size;
> +        }
> +    }
> +
> +    if (vdisk_size > 0) {
> +        return vdisk_size; /* return size in bytes */
> +    }
> +
> +    return -EIO;
> +}

Why are you implementing this function if vxhs doesn't support querying
the allocated file size?  Don't return a bogus number.  Just don't
implement it like other block drivers.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  parent reply	other threads:[~2016-09-28 11:13 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-28  4:09 [Qemu-devel] [PATCH v7 RFC] block/vxhs: Initial commit to add Veritas HyperScale VxHS block device support Ashish Mittal
2016-09-28 11:12 ` Paolo Bonzini
2016-09-28 11:13 ` Stefan Hajnoczi [this message]
2016-10-05  4:02   ` Jeff Cody
2016-10-11  7:56     ` ashish mittal
2016-10-18 19:10       ` Jeff Cody
2016-10-19 20:01         ` Ketan Nilangekar
2016-09-28 11:36 ` Stefan Hajnoczi
2016-09-28 12:06 ` Daniel P. Berrange
2016-09-28 21:45 ` Stefan Hajnoczi
2016-11-14 15:05   ` Stefan Hajnoczi
2016-11-14 18:01     ` ashish mittal
2016-11-15 22:38   ` ashish mittal
2016-11-16  8:12     ` Stefan Hajnoczi
2016-11-18  7:26       ` Jeff Cody
2016-11-18  8:57         ` Daniel P. Berrange
2016-11-18 10:02         ` Stefan Hajnoczi
2016-11-18 10:57           ` Ketan Nilangekar
2016-11-18 11:03             ` Daniel P. Berrange
2016-11-18 11:36           ` Ketan Nilangekar
2016-11-18 11:54             ` Daniel P. Berrange
2016-11-18 13:25               ` Ketan Nilangekar
2016-11-18 13:36                 ` Daniel P. Berrange
2016-11-23  8:25                   ` Ketan Nilangekar
2016-11-23 22:09                     ` ashish mittal
2016-11-23 22:37                       ` Paolo Bonzini
2016-11-24  5:44                         ` Ketan Nilangekar
2016-11-24 11:11                           ` Stefan Hajnoczi
2016-11-24 11:31                             ` Ketan Nilangekar
2016-11-24 16:08                               ` Stefan Hajnoczi
2016-11-25  8:27                                 ` Ketan Nilangekar
2016-11-25 11:35                                   ` Stefan Hajnoczi
2016-11-28 10:23                                     ` Ketan Nilangekar
2016-11-28 14:17                                       ` Stefan Hajnoczi
2016-11-30  0:45                                         ` ashish mittal
2016-11-30  4:20                                           ` Rakesh Ranjan
2016-11-30  8:35                                             ` Stefan Hajnoczi
2016-11-30  9:01                                         ` Stefan Hajnoczi
2016-11-28  7:15                                   ` Fam Zheng
2016-11-24 10:15                       ` Daniel P. Berrange
2016-11-18 10:34         ` Ketan Nilangekar
2016-11-18 14:49           ` Markus Armbruster
2016-11-18 16:19           ` Jeff Cody
2016-09-29  1:46 ` Jeff Cody
2016-09-29  2:18 ` Jeff Cody
2016-09-29 17:30   ` ashish mittal
2016-09-30  8:36 ` Stefan Hajnoczi
2016-10-01  3:10   ` ashish mittal
2016-10-03 14:10     ` Stefan Hajnoczi
2016-10-20  1:31   ` Ketan Nilangekar
2016-10-24 14:24     ` Paolo Bonzini
2016-10-25  1:56       ` Abhijit Dey
2016-10-25  5:07       ` Ketan Nilangekar
2016-10-25  5:15         ` Abhijit Dey
2016-10-25 11:01         ` Paolo Bonzini
2016-10-25 21:53           ` Ketan Nilangekar
2016-10-25 21:59             ` Paolo Bonzini
     [not found]               ` <21994ADD-7BC5-4C77-8D18-C1D4F9A52277@veritas.com>
     [not found]                 ` <ac0aa87f-702d-b53f-a6b7-2257b25a4a2a@redhat.com>
2016-10-26 22:17                   ` Ketan Nilangekar
2016-11-04  9:49     ` Stefan Hajnoczi
2016-11-04 18:44       ` Ketan Nilangekar
2016-11-04  9:52     ` Stefan Hajnoczi
2016-11-04 18:30       ` Ketan Nilangekar
2016-11-07 10:22         ` Stefan Hajnoczi
2016-11-07 20:27           ` Ketan Nilangekar
2016-11-08 15:39             ` Stefan Hajnoczi
2016-11-09 12:47               ` Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2016-12-14  0:06 ashish mittal
2016-12-14  7:23 ` Stefan Hajnoczi
2016-12-16  1:42   ` Buddhi Madhav
2016-12-16  8:09     ` Stefan Hajnoczi
2017-02-01 23:59       ` Ketan Nilangekar
2017-02-02  9:53         ` Daniel P. Berrange
2017-02-02 10:07         ` Stefan Hajnoczi
2017-02-02 10:15           ` Daniel P. Berrange
2017-02-02 20:57             ` Ketan Nilangekar
2017-02-02 21:22               ` Ketan Nilangekar
2017-02-03  9:45                 ` Daniel P. Berrange
2017-02-03 21:32                   ` Ketan Nilangekar
2017-02-02 20:53           ` Ketan Nilangekar

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=20160928111332.GD4196@stefanha-x1.localdomain \
    --to=stefanha@gmail.com \
    --cc=Abhijit.Dey@veritas.com \
    --cc=Ketan.Nilangekar@veritas.com \
    --cc=armbru@redhat.com \
    --cc=ashish.mittal@veritas.com \
    --cc=ashmit602@gmail.com \
    --cc=berrange@redhat.com \
    --cc=famz@redhat.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).