qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <v.sementsov-og@mail.ru>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: eblake@redhat.com
Subject: Re: [PATCH v2 for-7.1 6/9] nbd: code motion and function renaming
Date: Sat, 16 Apr 2022 15:37:28 +0300	[thread overview]
Message-ID: <2fe67c67-bffa-078c-d16a-a63d2736ba7d@mail.ru> (raw)
In-Reply-To: <20220414175756.671165-7-pbonzini@redhat.com>

14.04.2022 20:57, Paolo Bonzini wrote:
> Prepare for the next patch, so that the diff is less confusing.
> 
> nbd_client_connecting is moved closer to the definition point.

Amm. To usage-point you mean?
The original idea was to keep simple state-reading helpers definitions together :)

> 
> nbd_client_connecting_wait() is kept only for the reconnection
> logic; when it is used to check if a request has to be reissued,
> use the renamed function nbd_client_will_reconnect().  In the
> next patch, the two cases will have different locking requirements.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>

> ---
>   block/nbd.c | 24 ++++++++++++++----------
>   1 file changed, 14 insertions(+), 10 deletions(-)
> 
> diff --git a/block/nbd.c b/block/nbd.c
> index a2414566d1..37d466e435 100644
> --- a/block/nbd.c
> +++ b/block/nbd.c
> @@ -254,18 +254,15 @@ static void open_timer_init(BDRVNBDState *s, uint64_t expire_time_ns)
>       timer_mod(s->open_timer, expire_time_ns);
>   }
>   
> -static bool nbd_client_connecting(BDRVNBDState *s)
> -{
> -    NBDClientState state = qatomic_load_acquire(&s->state);
> -    return state == NBD_CLIENT_CONNECTING_WAIT ||
> -        state == NBD_CLIENT_CONNECTING_NOWAIT;
> -}
> -
>   static bool nbd_client_connecting_wait(BDRVNBDState *s)
>   {
>       return qatomic_load_acquire(&s->state) == NBD_CLIENT_CONNECTING_WAIT;
>   }
>   
> +static bool nbd_client_will_reconnect(BDRVNBDState *s)
> +{
> +    return qatomic_load_acquire(&s->state) == NBD_CLIENT_CONNECTING_WAIT;
> +}
>   /*
>    * Update @bs with information learned during a completed negotiation process.
>    * Return failure if the server's advertised options are incompatible with the
> @@ -355,6 +352,13 @@ int coroutine_fn nbd_co_do_establish_connection(BlockDriverState *bs,
>       return 0;
>   }
>   
> +static bool nbd_client_connecting(BDRVNBDState *s)
> +{
> +    NBDClientState state = qatomic_load_acquire(&s->state);
> +    return state == NBD_CLIENT_CONNECTING_WAIT ||
> +        state == NBD_CLIENT_CONNECTING_NOWAIT;
> +}
> +
>   /* Called with s->requests_lock taken.  */
>   static coroutine_fn void nbd_reconnect_attempt(BDRVNBDState *s)
>   {
> @@ -1190,7 +1194,7 @@ static int coroutine_fn nbd_co_request(BlockDriverState *bs, NBDRequest *request
>               error_free(local_err);
>               local_err = NULL;
>           }
> -    } while (ret < 0 && nbd_client_connecting_wait(s));
> +    } while (ret < 0 && nbd_client_will_reconnect(s));
>   
>       return ret ? ret : request_ret;
>   }
> @@ -1249,7 +1253,7 @@ static int coroutine_fn nbd_client_co_preadv(BlockDriverState *bs, int64_t offse
>               error_free(local_err);
>               local_err = NULL;
>           }
> -    } while (ret < 0 && nbd_client_connecting_wait(s));
> +    } while (ret < 0 && nbd_client_will_reconnect(s));
>   
>       return ret ? ret : request_ret;
>   }
> @@ -1407,7 +1411,7 @@ static int coroutine_fn nbd_client_co_block_status(
>               error_free(local_err);
>               local_err = NULL;
>           }
> -    } while (ret < 0 && nbd_client_connecting_wait(s));
> +    } while (ret < 0 && nbd_client_will_reconnect(s));
>   
>       if (ret < 0 || request_ret < 0) {
>           return ret ? ret : request_ret;


-- 
Best regards,
Vladimir


  parent reply	other threads:[~2022-04-16 12:38 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-14 17:57 [PATCH v2 for-7.1 0/9] nbd: actually make s->state thread-safe Paolo Bonzini
2022-04-14 17:57 ` [PATCH v2 for-7.1 1/9] nbd: safeguard against waking up invalid coroutine Paolo Bonzini
2022-04-14 19:02   ` Eric Blake
2022-04-15  9:53   ` Vladimir Sementsov-Ogievskiy
2022-04-14 17:57 ` [PATCH v2 for-7.1 2/9] nbd: mark more coroutine_fns Paolo Bonzini
2022-04-15 10:12   ` Vladimir Sementsov-Ogievskiy
2022-04-14 17:57 ` [PATCH v2 for-7.1 3/9] nbd: remove peppering of nbd_client_connected Paolo Bonzini
2022-04-15 17:01   ` Vladimir Sementsov-Ogievskiy
2022-04-23  8:30     ` Paolo Bonzini
2022-04-14 17:57 ` [PATCH v2 for-7.1 4/9] nbd: keep send_mutex/free_sema handling outside nbd_co_do_establish_connection Paolo Bonzini
2022-04-14 19:11   ` Eric Blake
2022-04-16 11:54   ` Vladimir Sementsov-Ogievskiy
2022-04-23  8:34     ` Paolo Bonzini
2022-04-14 17:57 ` [PATCH v2 for-7.1 5/9] nbd: use a QemuMutex to synchronize yanking, reconnection and coroutines Paolo Bonzini
2022-04-14 19:33   ` Eric Blake
2022-04-16 12:18   ` Vladimir Sementsov-Ogievskiy
2022-04-23  8:37     ` Paolo Bonzini
2022-04-14 17:57 ` [PATCH v2 for-7.1 6/9] nbd: code motion and function renaming Paolo Bonzini
2022-04-14 19:37   ` Eric Blake
2022-04-16 12:37   ` Vladimir Sementsov-Ogievskiy [this message]
2022-04-23  8:38     ` Paolo Bonzini
2022-04-14 17:57 ` [PATCH v2 for-7.1 7/9] nbd: move s->state under requests_lock Paolo Bonzini
2022-04-14 19:40   ` Eric Blake
2022-04-16 13:37   ` Vladimir Sementsov-Ogievskiy
2022-04-14 17:57 ` [PATCH v2 for-7.1 8/9] nbd: take receive_mutex when reading requests[].receiving Paolo Bonzini
2022-04-14 19:42   ` Eric Blake
2022-04-16 13:54   ` Vladimir Sementsov-Ogievskiy
2022-04-14 17:57 ` [PATCH v2 for-7.1 9/9] nbd: document what is protected by the CoMutexes Paolo Bonzini
2022-04-14 19:42   ` Eric Blake
2022-04-16 14:00   ` Vladimir Sementsov-Ogievskiy
2022-04-23  8:41     ` Paolo Bonzini
2022-04-16 19:03 ` [PATCH v2 for-7.1 0/9] nbd: actually make s->state thread-safe Lukas Straub
2022-04-22 20:39   ` Eric Blake

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=2fe67c67-bffa-078c-d16a-a63d2736ba7d@mail.ru \
    --to=v.sementsov-og@mail.ru \
    --cc=eblake@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).