All of lore.kernel.org
 help / color / mirror / Atom feed
From: Auger Eric <eric.auger@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>, qemu-devel@nongnu.org
Cc: Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>,
	Keith Busch <kbusch@kernel.org>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Klaus Jensen <its@irrelevant.dk>
Subject: Re: [PATCH 12/25] block/nvme: Make nvme_init_queue() return boolean indicating error
Date: Wed, 28 Oct 2020 12:10:12 +0100	[thread overview]
Message-ID: <6ff35b3e-e502-c7a5-fd78-a198565d70c8@redhat.com> (raw)
In-Reply-To: <20201027135547.374946-13-philmd@redhat.com>

Hi,
On 10/27/20 2:55 PM, Philippe Mathieu-Daudé wrote:
> Just for consistency, following the example documented since
> commit e3fe3988d7 ("error: Document Error API usage rules"),
> return a boolean value indicating an error is set or not.
> This simplifies a bit nvme_create_queue_pair().
also directly pass errp as the local_err is not requested in our case.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  block/nvme.c | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/block/nvme.c b/block/nvme.c
> index 74994c442e5..9324f0bfdc4 100644
> --- a/block/nvme.c
> +++ b/block/nvme.c
> @@ -160,7 +160,8 @@ static QemuOptsList runtime_opts = {
>      },
>  };
>  
> -static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
> +/* Returns true on success, false on failure. */
> +static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
>                              unsigned nentries, size_t entry_bytes, Error **errp)
>  {
>      size_t bytes;
> @@ -171,13 +172,14 @@ static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
I personally prefer returning a conventional int instead of bool.
>      q->queue = qemu_try_memalign(s->page_size, bytes);
>      if (!q->queue) {
>          error_setg(errp, "Cannot allocate queue");
> -        return;
> +        return false;
>      }
>      memset(q->queue, 0, bytes);
>      r = qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova);
>      if (r) {
>          error_setg(errp, "Cannot map queue");
>      }
> +    return r == 0;
also avoids that kind of conversion and use of !() in the called
>  }
>  
>  static void nvme_free_queue_pair(NVMeQueuePair *q)
> @@ -210,7 +212,6 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
>                                               Error **errp)
>  {
>      int i, r;
> -    Error *local_err = NULL;
>      NVMeQueuePair *q;
>      uint64_t prp_list_iova;
>  
> @@ -247,16 +248,12 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
>          req->prp_list_iova = prp_list_iova + i * s->page_size;
>      }
>  
> -    nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    if (!nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, errp)) {
>          goto fail;
>      }
>      q->sq.doorbell = &s->doorbells[idx * s->doorbell_scale].sq_tail;
>  
> -    nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> +    if (!nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, errp)) {
>          goto fail;
>      }
>      q->cq.doorbell = &s->doorbells[idx * s->doorbell_scale].cq_head;
> 
Thanks

Eric



  reply	other threads:[~2020-10-28 11:11 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27 13:55 [PATCH 00/25] block/nvme: Fix Aarch64 host Philippe Mathieu-Daudé
2020-10-27 13:55 ` [PATCH 01/25] MAINTAINERS: Cover 'block/nvme.h' file Philippe Mathieu-Daudé
2020-10-28 15:47   ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 02/25] block/nvme: Use hex format to display offset in trace events Philippe Mathieu-Daudé
2020-10-28 10:21   ` Auger Eric
2020-10-28 15:47   ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 03/25] block/nvme: Report warning with warn_report() Philippe Mathieu-Daudé
2020-10-27 14:45   ` Keith Busch
2020-10-27 15:33     ` Philippe Mathieu-Daudé
2020-10-27 15:54       ` Philippe Mathieu-Daudé
2020-10-28 10:22   ` Auger Eric
2020-10-28 15:47   ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 04/25] block/nvme: Trace controller capabilities Philippe Mathieu-Daudé
2020-10-28 10:20   ` Auger Eric
2020-10-28 10:25     ` Philippe Mathieu-Daudé
2020-10-28 10:36       ` Auger Eric
2020-10-27 13:55 ` [PATCH 05/25] block/nvme: Trace nvme_poll_queue() per queue Philippe Mathieu-Daudé
2020-10-28 10:31   ` Auger Eric
2020-10-28 15:48   ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 06/25] block/nvme: Improve nvme_free_req_queue_wait() trace information Philippe Mathieu-Daudé
2020-10-28 10:32   ` Auger Eric
2020-10-28 15:48   ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 07/25] block/nvme: Trace queue pair creation/deletion Philippe Mathieu-Daudé
2020-10-28 10:28   ` Auger Eric
2020-10-28 15:48   ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 08/25] block/nvme: Simplify device reset Philippe Mathieu-Daudé
2020-10-27 14:54   ` Keith Busch
2020-10-27 14:58   ` Keith Busch
2020-10-27 15:53     ` Philippe Mathieu-Daudé
2020-10-27 16:55       ` Keith Busch
2020-10-28 15:02         ` Stefan Hajnoczi
2020-10-28 15:10           ` Keith Busch
2020-10-27 13:55 ` [PATCH 09/25] block/nvme: Move definitions before structure declarations Philippe Mathieu-Daudé
2020-10-28 10:44   ` Auger Eric
2020-10-28 15:49   ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 10/25] block/nvme: Use unsigned integer for queue counter/size Philippe Mathieu-Daudé
2020-10-28 10:48   ` Auger Eric
2020-10-28 15:49   ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 11/25] block/nvme: Make nvme_identify() return boolean indicating error Philippe Mathieu-Daudé
2020-10-28 11:03   ` Auger Eric
2020-10-28 15:07     ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 12/25] block/nvme: Make nvme_init_queue() " Philippe Mathieu-Daudé
2020-10-28 11:10   ` Auger Eric [this message]
2020-10-28 15:11   ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 13/25] block/nvme: Introduce Completion Queue definitions Philippe Mathieu-Daudé
2020-10-28 11:18   ` Auger Eric
2020-10-28 15:10   ` Stefan Hajnoczi
2020-10-28 15:16   ` Stefan Hajnoczi
2020-10-28 18:24     ` Philippe Mathieu-Daudé
2020-10-29  9:02       ` Philippe Mathieu-Daudé
2020-10-30 11:46         ` Stefan Hajnoczi
2020-10-30 14:51           ` Philippe Mathieu-Daudé
2020-10-27 13:55 ` [PATCH 14/25] block/nvme: Use definitions instead of magic values in add_io_queue() Philippe Mathieu-Daudé
2020-10-28 14:17   ` Auger Eric
2020-10-28 15:16   ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 15/25] block/nvme: Correctly initialize Admin Queue Attributes Philippe Mathieu-Daudé
2020-10-28 14:21   ` Auger Eric
2020-10-28 15:17   ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 16/25] block/nvme: Simplify ADMIN queue access Philippe Mathieu-Daudé
2020-10-28 14:25   ` Auger Eric
2020-10-28 15:19   ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 17/25] block/nvme: Simplify nvme_cmd_sync() Philippe Mathieu-Daudé
2020-10-28 14:27   ` Auger Eric
2020-10-28 15:21   ` Stefan Hajnoczi
2020-10-29  7:35     ` Philippe Mathieu-Daudé
2020-10-27 13:55 ` [PATCH 18/25] block/nvme: Pass AioContext argument to nvme_add_io_queue() Philippe Mathieu-Daudé
2020-10-28 14:30   ` Auger Eric
2020-10-28 15:30   ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 19/25] block/nvme: Set request_alignment at initialization Philippe Mathieu-Daudé
2020-10-27 13:55 ` [PATCH 20/25] block/nvme: Correct minimum device page size Philippe Mathieu-Daudé
2020-10-27 13:55 ` [PATCH 21/25] block/nvme: Change size and alignment of IDENTIFY response buffer Philippe Mathieu-Daudé
2020-10-28 15:35   ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 22/25] block/nvme: Change size and alignment of queue Philippe Mathieu-Daudé
2020-10-28 15:37   ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 23/25] block/nvme: Change size and alignment of prp_list_pages Philippe Mathieu-Daudé
2020-10-28 15:38   ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 24/25] block/nvme: Align iov's va and size on host page size Philippe Mathieu-Daudé
2020-10-28 15:41   ` Stefan Hajnoczi
2020-10-27 13:55 ` [RFC PATCH 25/25] block/nvme: Fix use of write-only doorbells page on Aarch64 arch Philippe Mathieu-Daudé
2020-10-28 15:47   ` Stefan Hajnoczi
2020-10-28 16:12   ` Auger Eric
2020-10-28 18:10 ` [PATCH 00/25] block/nvme: Fix Aarch64 host Auger Eric
2020-10-29  9:08   ` Philippe Mathieu-Daudé

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=6ff35b3e-e502-c7a5-fd78-a198565d70c8@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=fam@euphon.net \
    --cc=its@irrelevant.dk \
    --cc=kbusch@kernel.org \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.