Re: [PATCH 1/2] block-backend: add drained_poll
On Tue, Jun 01, 2021 at 05:59:10PM +0200, Kevin Wolf wrote: > > +++ b/block/block-backend.c > > @@ -2393,8 +2393,13 @@ static void blk_root_drained_begin(BdrvChild *child) > > static bool blk_root_drained_poll(BdrvChild *child) > > { > > BlockBackend *blk = child->opaque; > > +int ret = 0; > > It's really a bool. > > > assert(blk->quiesce_counter); > > -return !!blk->in_flight; > > + > > +if (blk->dev_ops && blk->dev_ops->drained_poll) { > > +ret = blk->dev_ops->drained_poll(blk->dev_opaque); > > +} > > +return ret || !!blk->in_flight; > > } > > Doesn't make a difference for correctness, of course, so whether you > change it or not: > > Reviewed-by: Kevin Wolf Likewise, with that cosmetic change, Reviewed-by: Eric Blake -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [PATCH 1/2] block-backend: add drained_poll
On Tue, Jun 01, 2021 at 05:59:10PM +0200, Kevin Wolf wrote: > Am 01.06.2021 um 07:57 hat Sergio Lopez geschrieben: > > Allow block backends to poll their devices/users to check if they have > > been quiesced when entering a drained section. > > > > This will be used in the next patch to wait for the NBD server to be > > completely quiesced. > > > > Suggested-by: Kevin Wolf > > Signed-off-by: Sergio Lopez > > --- > > block/block-backend.c | 7 ++- > > include/sysemu/block-backend.h | 4 > > 2 files changed, 10 insertions(+), 1 deletion(-) > > > > diff --git a/block/block-backend.c b/block/block-backend.c > > index de5496af66..163ca05b97 100644 > > --- a/block/block-backend.c > > +++ b/block/block-backend.c > > @@ -2393,8 +2393,13 @@ static void blk_root_drained_begin(BdrvChild *child) > > static bool blk_root_drained_poll(BdrvChild *child) > > { > > BlockBackend *blk = child->opaque; > > +int ret = 0; > > It's really a bool. I'll fix this in v2. Thanks, Sergio. > > assert(blk->quiesce_counter); > > -return !!blk->in_flight; > > + > > +if (blk->dev_ops && blk->dev_ops->drained_poll) { > > +ret = blk->dev_ops->drained_poll(blk->dev_opaque); > > +} > > +return ret || !!blk->in_flight; > > } > > Doesn't make a difference for correctness, of course, so whether you > change it or not: > > Reviewed-by: Kevin Wolf > signature.asc Description: PGP signature
Re: [PATCH 1/2] block-backend: add drained_poll
Am 01.06.2021 um 07:57 hat Sergio Lopez geschrieben: > Allow block backends to poll their devices/users to check if they have > been quiesced when entering a drained section. > > This will be used in the next patch to wait for the NBD server to be > completely quiesced. > > Suggested-by: Kevin Wolf > Signed-off-by: Sergio Lopez > --- > block/block-backend.c | 7 ++- > include/sysemu/block-backend.h | 4 > 2 files changed, 10 insertions(+), 1 deletion(-) > > diff --git a/block/block-backend.c b/block/block-backend.c > index de5496af66..163ca05b97 100644 > --- a/block/block-backend.c > +++ b/block/block-backend.c > @@ -2393,8 +2393,13 @@ static void blk_root_drained_begin(BdrvChild *child) > static bool blk_root_drained_poll(BdrvChild *child) > { > BlockBackend *blk = child->opaque; > +int ret = 0; It's really a bool. > assert(blk->quiesce_counter); > -return !!blk->in_flight; > + > +if (blk->dev_ops && blk->dev_ops->drained_poll) { > +ret = blk->dev_ops->drained_poll(blk->dev_opaque); > +} > +return ret || !!blk->in_flight; > } Doesn't make a difference for correctness, of course, so whether you change it or not: Reviewed-by: Kevin Wolf
[PATCH 1/2] block-backend: add drained_poll
Allow block backends to poll their devices/users to check if they have been quiesced when entering a drained section. This will be used in the next patch to wait for the NBD server to be completely quiesced. Suggested-by: Kevin Wolf Signed-off-by: Sergio Lopez --- block/block-backend.c | 7 ++- include/sysemu/block-backend.h | 4 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index de5496af66..163ca05b97 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2393,8 +2393,13 @@ static void blk_root_drained_begin(BdrvChild *child) static bool blk_root_drained_poll(BdrvChild *child) { BlockBackend *blk = child->opaque; +int ret = 0; assert(blk->quiesce_counter); -return !!blk->in_flight; + +if (blk->dev_ops && blk->dev_ops->drained_poll) { +ret = blk->dev_ops->drained_poll(blk->dev_opaque); +} +return ret || !!blk->in_flight; } static void blk_root_drained_end(BdrvChild *child, int *drained_end_counter) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 880e903293..9992072e18 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -66,6 +66,10 @@ typedef struct BlockDevOps { * Runs when the backend's last drain request ends. */ void (*drained_end)(void *opaque); +/* + * Is the device drained? + */ +bool (*drained_poll)(void *opaque); } BlockDevOps; /* This struct is embedded in (the private) BlockBackend struct and contains -- 2.26.2