diff mbox

[v22,13/30] block: new bdrv_reopen_bitmaps_rw interface

Message ID 20170628120530.31251-14-vsementsov@virtuozzo.com
State New
Headers show

Commit Message

Vladimir Sementsov-Ogievskiy June 28, 2017, 12:05 p.m. UTC
Add format driver handler, which should mark loaded read-only
bitmaps as 'IN_USE' in the image and unset read_only field in
corresponding BdrvDirtyBitmap's.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: John Snow <jsnow@redhat.com>
---
 block.c                   | 19 +++++++++++++++++++
 include/block/block_int.h |  7 +++++++
 2 files changed, 26 insertions(+)

Comments

Vladimir Sementsov-Ogievskiy June 28, 2017, 12:10 p.m. UTC | #1
28.06.2017 15:05, Vladimir Sementsov-Ogievskiy wrote:
> Add format driver handler, which should mark loaded read-only
> bitmaps as 'IN_USE' in the image and unset read_only field in
> corresponding BdrvDirtyBitmap's.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy<vsementsov@virtuozzo.com>
> Reviewed-by: John Snow<jsnow@redhat.com>


Forgot to add:

Reviewed-by: Max Reitz<mreitz@redhat.com>
Eric Blake June 28, 2017, 12:36 p.m. UTC | #2
[meta-comment]

On 06/28/2017 07:10 AM, Vladimir Sementsov-Ogievskiy wrote:
> 28.06.2017 15:05, Vladimir Sementsov-Ogievskiy wrote:
>> Add format driver handler, which should mark loaded read-only
>> bitmaps as 'IN_USE' in the image and unset read_only field in
>> corresponding BdrvDirtyBitmap's.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy<vsementsov@virtuozzo.com>
>> Reviewed-by: John Snow<jsnow@redhat.com>

Your original message had spaces before '<' in the email addresses, but
it got lost here...

> 
> 
> Forgot to add:
> 
> Reviewed-by: Max Reitz<mreitz@redhat.com>

...this one also lacks the space.  I'm not sure if git cares, but it may
be worth investigating why your mailer eats the space when you reply
manually rather than sending via git; and for consistency, it is worth
keeping the space (for example, we like to grep 'git log' for learning
how active various contributors are, and having a consistent usage of
space before < in an email address can make the task easier).
Vladimir Sementsov-Ogievskiy June 28, 2017, 1:02 p.m. UTC | #3
It is interesting, but I see this problem only in your answers, in my 
letters I see this white-space on its place.

28.06.2017 15:36, Eric Blake wrote:
> [meta-comment]
>
> On 06/28/2017 07:10 AM, Vladimir Sementsov-Ogievskiy wrote:
>> 28.06.2017 15:05, Vladimir Sementsov-Ogievskiy wrote:
>>> Add format driver handler, which should mark loaded read-only
>>> bitmaps as 'IN_USE' in the image and unset read_only field in
>>> corresponding BdrvDirtyBitmap's.
>>>
>>> Signed-off-by: Vladimir Sementsov-Ogievskiy<vsementsov@virtuozzo.com>
>>> Reviewed-by: John Snow<jsnow@redhat.com>
> Your original message had spaces before '<' in the email addresses, but
> it got lost here...
>
>>
>> Forgot to add:
>>
>> Reviewed-by: Max Reitz<mreitz@redhat.com>
> ...this one also lacks the space.  I'm not sure if git cares, but it may
> be worth investigating why your mailer eats the space when you reply
> manually rather than sending via git; and for consistency, it is worth
> keeping the space (for example, we like to grep 'git log' for learning
> how active various contributors are, and having a consistent usage of
> space before < in an email address can make the task easier).
>
Vladimir Sementsov-Ogievskiy June 28, 2017, 1:13 p.m. UTC | #4
28.06.2017 16:02, Vladimir Sementsov-Ogievskiy wrote:
> It is interesting, but I see this problem only in your answers, in my 
> letters I see this white-space on its place.

In outgoing letter I see this white-space, but in letter from 
mailing-list it is absent.

>
> 28.06.2017 15:36, Eric Blake wrote:
>> [meta-comment]
>>
>> On 06/28/2017 07:10 AM, Vladimir Sementsov-Ogievskiy wrote:
>>> 28.06.2017 15:05, Vladimir Sementsov-Ogievskiy wrote:
>>>> Add format driver handler, which should mark loaded read-only
>>>> bitmaps as 'IN_USE' in the image and unset read_only field in
>>>> corresponding BdrvDirtyBitmap's.
>>>>
>>>> Signed-off-by: Vladimir Sementsov-Ogievskiy<vsementsov@virtuozzo.com>
>>>> Reviewed-by: John Snow<jsnow@redhat.com>
>> Your original message had spaces before '<' in the email addresses, but
>> it got lost here...
>>
>>>
>>> Forgot to add:
>>>
>>> Reviewed-by: Max Reitz<mreitz@redhat.com>
>> ...this one also lacks the space.  I'm not sure if git cares, but it may
>> be worth investigating why your mailer eats the space when you reply
>> manually rather than sending via git; and for consistency, it is worth
>> keeping the space (for example, we like to grep 'git log' for learning
>> how active various contributors are, and having a consistent usage of
>> space before < in an email address can make the task easier).
>>
>
Paolo Bonzini June 28, 2017, 1:31 p.m. UTC | #5
On 28/06/2017 15:02, Vladimir Sementsov-Ogievskiy wrote:
> It is interesting, but I see this problem only in your answers, in my
> letters I see this white-space on its place.

That's the good old Thunderbird "format=flowed" bug.

Vladimir, download
http://people.redhat.com/pbonzini/format-flawed.tar.gz and place it into
~/.thunderbird/<profile name>/extensions.  It works around the bug.

Paolo

> 28.06.2017 15:36, Eric Blake wrote:
>> [meta-comment]
>>
>> On 06/28/2017 07:10 AM, Vladimir Sementsov-Ogievskiy wrote:
>>> 28.06.2017 15:05, Vladimir Sementsov-Ogievskiy wrote:
>>>> Add format driver handler, which should mark loaded read-only
>>>> bitmaps as 'IN_USE' in the image and unset read_only field in
>>>> corresponding BdrvDirtyBitmap's.
>>>>
>>>> Signed-off-by: Vladimir Sementsov-Ogievskiy<vsementsov@virtuozzo.com>
>>>> Reviewed-by: John Snow<jsnow@redhat.com>
>> Your original message had spaces before '<' in the email addresses, but
>> it got lost here...
>>
Vladimir Sementsov-Ogievskiy June 28, 2017, 1:34 p.m. UTC | #6
Finally, it looks like thunderbird bug
https://bugzilla.mozilla.org/show_bug.cgi?id=1160880

[sorry for so much offtopic]

28.06.2017 16:13, Vladimir Sementsov-Ogievskiy wrote:
> 28.06.2017 16:02, Vladimir Sementsov-Ogievskiy wrote:
>> It is interesting, but I see this problem only in your answers, in my 
>> letters I see this white-space on its place.
> 
> In outgoing letter I see this white-space, but in letter from 
> mailing-list it is absent.
> 
>>
>> 28.06.2017 15:36, Eric Blake wrote:
>>> [meta-comment]
>>>
>>> On 06/28/2017 07:10 AM, Vladimir Sementsov-Ogievskiy wrote:
>>>> 28.06.2017 15:05, Vladimir Sementsov-Ogievskiy wrote:
>>>>> Add format driver handler, which should mark loaded read-only
>>>>> bitmaps as 'IN_USE' in the image and unset read_only field in
>>>>> corresponding BdrvDirtyBitmap's.
>>>>>
>>>>> Signed-off-by: Vladimir Sementsov-Ogievskiy<vsementsov@virtuozzo.com>
>>>>> Reviewed-by: John Snow<jsnow@redhat.com>
>>> Your original message had spaces before '<' in the email addresses, but
>>> it got lost here...
>>>
>>>>
>>>> Forgot to add:
>>>>
>>>> Reviewed-by: Max Reitz<mreitz@redhat.com>
>>> ...this one also lacks the space.  I'm not sure if git cares, but it may
>>> be worth investigating why your mailer eats the space when you reply
>>> manually rather than sending via git; and for consistency, it is worth
>>> keeping the space (for example, we like to grep 'git log' for learning
>>> how active various contributors are, and having a consistent usage of
>>> space before < in an email address can make the task easier).
>>>
>>
>
Vladimir Sementsov-Ogievskiy June 28, 2017, 2:36 p.m. UTC | #7
28.06.2017 16:31, Paolo Bonzini wrote:
>
> On 28/06/2017 15:02, Vladimir Sementsov-Ogievskiy wrote:
>> It is interesting, but I see this problem only in your answers, in my
>> letters I see this white-space on its place.
> That's the good old Thunderbird "format=flowed" bug.
>
> Vladimir, download
> http://people.redhat.com/pbonzini/format-flawed.tar.gz and place it into
> ~/.thunderbird/<profile name>/extensions.  It works around the bug.

unfortunately, with this buttons 'reply' and 'reply to all' do nothing..

>
> Paolo
>
>> 28.06.2017 15:36, Eric Blake wrote:
>>> [meta-comment]
>>>
>>> On 06/28/2017 07:10 AM, Vladimir Sementsov-Ogievskiy wrote:
>>>> 28.06.2017 15:05, Vladimir Sementsov-Ogievskiy wrote:
>>>>> Add format driver handler, which should mark loaded read-only
>>>>> bitmaps as 'IN_USE' in the image and unset read_only field in
>>>>> corresponding BdrvDirtyBitmap's.
>>>>>
>>>>> Signed-off-by: Vladimir Sementsov-Ogievskiy<vsementsov@virtuozzo.com>
>>>>> Reviewed-by: John Snow<jsnow@redhat.com>
>>> Your original message had spaces before '<' in the email addresses, but
>>> it got lost here...
>>>
diff mbox

Patch

diff --git a/block.c b/block.c
index 37d68e3276..3f83da178d 100644
--- a/block.c
+++ b/block.c
@@ -2990,12 +2990,16 @@  void bdrv_reopen_commit(BDRVReopenState *reopen_state)
 {
     BlockDriver *drv;
     BlockDriverState *bs;
+    bool old_can_write, new_can_write;
 
     assert(reopen_state != NULL);
     bs = reopen_state->bs;
     drv = bs->drv;
     assert(drv != NULL);
 
+    old_can_write =
+        !bdrv_is_read_only(bs) && !(bdrv_get_flags(bs) & BDRV_O_INACTIVE);
+
     /* If there are any driver level actions to take */
     if (drv->bdrv_reopen_commit) {
         drv->bdrv_reopen_commit(reopen_state);
@@ -3009,6 +3013,21 @@  void bdrv_reopen_commit(BDRVReopenState *reopen_state)
     bs->read_only = !(reopen_state->flags & BDRV_O_RDWR);
 
     bdrv_refresh_limits(bs, NULL);
+
+    new_can_write =
+        !bdrv_is_read_only(bs) && !(bdrv_get_flags(bs) & BDRV_O_INACTIVE);
+    if (!old_can_write && new_can_write && drv->bdrv_reopen_bitmaps_rw) {
+        Error *local_err = NULL;
+        if (drv->bdrv_reopen_bitmaps_rw(bs, &local_err) < 0) {
+            /* This is not fatal, bitmaps just left read-only, so all following
+             * writes will fail. User can remove read-only bitmaps to unblock
+             * writes.
+             */
+            error_reportf_err(local_err,
+                              "%s: Failed to make dirty bitmaps writable: ",
+                              bdrv_get_node_name(bs));
+        }
+    }
 }
 
 /*
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 748970055e..4ad8eec2dd 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -381,6 +381,13 @@  struct BlockDriver {
                              uint64_t parent_perm, uint64_t parent_shared,
                              uint64_t *nperm, uint64_t *nshared);
 
+    /**
+     * Bitmaps should be marked as 'IN_USE' in the image on reopening image
+     * as rw. This handler should realize it. It also should unset readonly
+     * field of BlockDirtyBitmap's in case of success.
+     */
+    int (*bdrv_reopen_bitmaps_rw)(BlockDriverState *bs, Error **errp);
+
     QLIST_ENTRY(BlockDriver) list;
 };