All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Greg Kurz <groug@kaod.org>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, armbru@redhat.com,
	berto@igalia.com, eblake@redhat.com, jsnow@redhat.com,
	stefanha@redhat.com, pbonzini@redhat.com,
	pavel.dovgaluk@ispras.ru, ari@tuxera.com, mreitz@redhat.com,
	kwolf@redhat.com
Subject: Re: [PATCH 11/14] block/qcow2-bitmap: return startus from qcow2_store_persistent_dirty_bitmaps
Date: Fri, 11 Sep 2020 14:39:27 +0300	[thread overview]
Message-ID: <12a7ab93-6545-a221-e9ff-4328c781fbb3@virtuozzo.com> (raw)
In-Reply-To: <20200911132152.01855289@bahia.lan>

11.09.2020 14:21, Greg Kurz wrote:
> On Fri, 11 Sep 2020 13:18:32 +0300
> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:
> 
>> 11.09.2020 12:38, Greg Kurz wrote:
>>> s/startus/status
>>>
>>> On Wed,  9 Sep 2020 21:59:27 +0300
>>> Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> wrote:
>>>
>>>> It's better to return status together with setting errp. It makes
>>>> possible to avoid error propagation.
>>>>
>>>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>>>> ---
>>>>    block/qcow2.h        |  2 +-
>>>>    block/qcow2-bitmap.c | 13 ++++++-------
>>>>    2 files changed, 7 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/block/qcow2.h b/block/qcow2.h
>>>> index e7e662533b..49824be5c6 100644
>>>> --- a/block/qcow2.h
>>>> +++ b/block/qcow2.h
>>>> @@ -972,7 +972,7 @@ bool qcow2_get_bitmap_info_list(BlockDriverState *bs,
>>>>                                    Qcow2BitmapInfoList **info_list, Error **errp);
>>>>    int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp);
>>>>    int qcow2_truncate_bitmaps_check(BlockDriverState *bs, Error **errp);
>>>> -void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs,
>>>> +bool qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs,
>>>>                                              bool release_stored, Error **errp);
>>>>    int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp);
>>>>    bool qcow2_co_can_store_new_dirty_bitmap(BlockDriverState *bs,
>>>> diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
>>>> index f58923fce3..5eeff1cb1c 100644
>>>> --- a/block/qcow2-bitmap.c
>>>> +++ b/block/qcow2-bitmap.c
>>>> @@ -1524,9 +1524,10 @@ out:
>>>>     * readonly to begin with, and whether we opened directly or reopened to that
>>>>     * state shouldn't matter for the state we get afterward.
>>>>     */
>>>> -void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs,
>>>> +bool qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs,
>>>>                                              bool release_stored, Error **errp)
>>>>    {
>>>> +    ERRP_GUARD();
>>>
>>> Maybe worth mentioning in the changelog that this ERRP_GUARD() fixes
>>> an error_prepend(errp, ...) not visible in the patch context.
>>
>> Ah yes. Actually this is occasional thing I didn't want to include into this patch
>> (and int this part I). So we can just drop it and leave for part II or part III,
>> or add a note into commit message
>>
>>>
>>> Anyway,
>>>
>>> Reviewed-by: Greg Kurz <groug@kaod.org>
>>
>> Thanks a lot for reviewing :)
>>
> 
> Don't mention it :)
> 
>> Hmm.. With this series I understand the following:
>>
>> 1. It's no sense in simple applying scripts/coccinelle/errp-guard.cocci to the whole code-base, because:
>>
>>     - it produces a lot of "if (*errp)" in places where it is really simple to avoid error propagation at all, like in this series
>>     - reviewing is the hardest part of the process
>>
>> So, if we have to review these changes anyway, it's better to invest a bit more time into patch creation, and make code correspond to our modern error API recommendations.
>>
>> 2. So, the process turns into following steps:
>>
>>     - apply scripts/coccinelle/errp-guard.cocci
>>     - look through patches and do obvious refactorings (like this series)
>>     - keep ERRP_GUARD where necessary (appending info to error, or where refactoring of function return status is too invasive and not simple)
>>
> 
> I've started to follow this process for the spapr code and, indeed, I
> can come up with better changes by refactoring some code manually.
> Some of these changes are not that obvious that they could be made
> by someone who doesn't know the code, so I tend to agree with your
> arguments in 1.
> 
> This is also the reason I didn't review patches 10, 13 and 14 because
> they looked like I should understand the corresponding code a bit more.
> 
>> 3. Obviously, that's too much for me :) Of course, I will invest some time into making the series like this one, and reviewing them, but I can't do it for weeks and months. (My original сunning plan to simply push ~100 generated commits with my s-o-b and become the greatest contributor failed:)
>>
> 
> Ha ha :D ... as a consolation prize, maybe we can reach a fair number
> of r-b by reviewing each other's _simple_ cleanups ;-)
> 
>> The good thing is that now, with ERRP_GUARD finally merged, we can produce parallel series like this, and they will be processed in parallel by different maintainers (and Markus will have to merge series for subsystems with unavailable maintainers).
>>
> 
> This sounds nice. My only concern would be to end up fixing code nobody
> uses or cares for, so I guess it would be better that active maintainers
> or supporters give impetus on that.
> 
>> So, everybody is welcome to the process [2]. Probably we want to make a separate announcement in a list with short recommendations and instructions? But who read announcements..
>>
> 
> I don't :) but the very massive series that were posted on the topic
> the last few months look like an announcement to me, at least for
> active maintainers and supporters.

Aha, I know. Better than announcement is improving checkpatch.

> 
>>>
>>>>        BdrvDirtyBitmap *bitmap;
>>>>        BDRVQcow2State *s = bs->opaque;
>>>>        uint32_t new_nb_bitmaps = s->nb_bitmaps;
>>>> @@ -1546,7 +1547,7 @@ void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs,
>>>>            bm_list = bitmap_list_load(bs, s->bitmap_directory_offset,
>>>>                                       s->bitmap_directory_size, errp);
>>>>            if (bm_list == NULL) {
>>>> -            return;
>>>> +            return false;
>>>>            }
>>>>        }
>>>>    
>>>> @@ -1661,7 +1662,7 @@ success:
>>>>        }
>>>>    
>>>>        bitmap_list_free(bm_list);
>>>> -    return;
>>>> +    return true;
>>>>    
>>>>    fail:
>>>>        QSIMPLEQ_FOREACH(bm, bm_list, entry) {
>>>> @@ -1679,16 +1680,14 @@ fail:
>>>>        }
>>>>    
>>>>        bitmap_list_free(bm_list);
>>>> +    return false;
>>>>    }
>>>>    
>>>>    int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp)
>>>>    {
>>>>        BdrvDirtyBitmap *bitmap;
>>>> -    Error *local_err = NULL;
>>>>    
>>>> -    qcow2_store_persistent_dirty_bitmaps(bs, false, &local_err);
>>>> -    if (local_err != NULL) {
>>>> -        error_propagate(errp, local_err);
>>>> +    if (!qcow2_store_persistent_dirty_bitmaps(bs, false, errp)) {
>>>>            return -EINVAL;
>>>>        }
>>>>    
>>>
>>
>>
> 


-- 
Best regards,
Vladimir


  reply	other threads:[~2020-09-11 11:40 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-09 18:59 [PATCH 00/14] block: deal with errp: part I Vladimir Sementsov-Ogievskiy
2020-09-09 18:59 ` [PATCH 01/14] block: return status from bdrv_append and friends Vladimir Sementsov-Ogievskiy
2020-09-10 15:51   ` Greg Kurz
2020-09-17 14:13   ` Alberto Garcia
2020-09-09 18:59 ` [PATCH 02/14] block: use return status of bdrv_append() Vladimir Sementsov-Ogievskiy
2020-09-10 16:10   ` Greg Kurz
2020-09-17 19:21     ` Vladimir Sementsov-Ogievskiy
2020-09-17 13:59   ` Alberto Garcia
2020-09-09 18:59 ` [PATCH 03/14] block: check return value of bdrv_open_child and drop error propagation Vladimir Sementsov-Ogievskiy
2020-09-10 16:21   ` Greg Kurz
2020-09-17 14:47   ` Alberto Garcia
2020-09-09 18:59 ` [PATCH 04/14] blockdev: fix drive_backup_prepare() missed error Vladimir Sementsov-Ogievskiy
2020-09-10 16:26   ` Greg Kurz
2020-09-17 13:56   ` Alberto Garcia
2020-09-09 18:59 ` [PATCH 05/14] block: drop extra error propagation for bdrv_set_backing_hd Vladimir Sementsov-Ogievskiy
2020-09-10 16:30   ` Greg Kurz
2020-09-17 13:57   ` Alberto Garcia
2020-09-09 18:59 ` [PATCH 06/14] block/mirror: drop extra error propagation in commit_active_start() Vladimir Sementsov-Ogievskiy
2020-09-10 16:32   ` Greg Kurz
2020-09-17 14:48   ` Alberto Garcia
2020-09-09 18:59 ` [PATCH 07/14] block/blklogwrites: drop error propagation Vladimir Sementsov-Ogievskiy
2020-09-10 17:24   ` Greg Kurz
2020-09-11  5:23     ` Markus Armbruster
2020-09-11  5:30       ` Markus Armbruster
2020-09-11  6:19         ` Greg Kurz
2020-09-11 14:43           ` Markus Armbruster
2020-09-10 21:01   ` Ari Sundholm
2020-09-11  8:03     ` Markus Armbruster
2020-09-16 16:52       ` Ari Sundholm
2020-09-17  7:12         ` Markus Armbruster
2020-09-09 18:59 ` [PATCH 08/14] blockjob: return status from block_job_set_speed() Vladimir Sementsov-Ogievskiy
2020-09-11  8:34   ` Greg Kurz
2020-09-17 14:01   ` Alberto Garcia
2020-09-09 18:59 ` [PATCH 09/14] block/qcow2: qcow2_get_specific_info(): drop error propagation Vladimir Sementsov-Ogievskiy
2020-09-11  8:41   ` Greg Kurz
2020-09-17 16:32   ` Alberto Garcia
2020-09-17 18:52     ` Vladimir Sementsov-Ogievskiy
2020-09-09 18:59 ` [PATCH 10/14] block/qcow2-bitmap: improve qcow2_load_dirty_bitmaps() interface Vladimir Sementsov-Ogievskiy
2020-09-17 16:35   ` Alberto Garcia
2020-09-17 18:58     ` Vladimir Sementsov-Ogievskiy
2020-09-09 18:59 ` [PATCH 11/14] block/qcow2-bitmap: return startus from qcow2_store_persistent_dirty_bitmaps Vladimir Sementsov-Ogievskiy
2020-09-11  9:38   ` Greg Kurz
2020-09-11 10:18     ` Vladimir Sementsov-Ogievskiy
2020-09-11 11:21       ` Greg Kurz
2020-09-11 11:39         ` Vladimir Sementsov-Ogievskiy [this message]
2020-09-11 15:22           ` Markus Armbruster
2020-09-11 17:20             ` Vladimir Sementsov-Ogievskiy
2020-09-14  6:53               ` Markus Armbruster
2020-09-17 14:50   ` Alberto Garcia
2020-09-09 18:59 ` [PATCH 12/14] block/qcow2: read_cache_sizes: return status value Vladimir Sementsov-Ogievskiy
2020-09-11  9:40   ` Greg Kurz
2020-09-17 14:51   ` Alberto Garcia
2020-09-09 18:59 ` [PATCH 13/14] block/qcow2: qcow2_do_open: deal with errp Vladimir Sementsov-Ogievskiy
2020-09-17 16:23   ` Alberto Garcia
2020-09-17 17:44     ` Vladimir Sementsov-Ogievskiy
2020-09-09 18:59 ` [PATCH 14/14] block/qed: bdrv_qed_do_open: " Vladimir Sementsov-Ogievskiy
2020-09-17 16:25   ` Alberto Garcia

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=12a7ab93-6545-a221-e9ff-4328c781fbb3@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=ari@tuxera.com \
    --cc=armbru@redhat.com \
    --cc=berto@igalia.com \
    --cc=eblake@redhat.com \
    --cc=groug@kaod.org \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pavel.dovgaluk@ispras.ru \
    --cc=pbonzini@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.