[16/29] block: add bdrv_load_dirty_bitmap()
diff mbox

Message ID 1470668720-211300-17-git-send-email-vsementsov@virtuozzo.com
State New
Headers show

Commit Message

Vladimir Sementsov-Ogievskiy Aug. 8, 2016, 3:05 p.m. UTC
The funcion loads dirty bitmap from file, using underlying driver
function.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/dirty-bitmap.c         | 16 ++++++++++++++++
 include/block/dirty-bitmap.h |  2 ++
 2 files changed, 18 insertions(+)

Comments

Kevin Wolf Aug. 11, 2016, 11:24 a.m. UTC | #1
Am 08.08.2016 um 17:05 hat Vladimir Sementsov-Ogievskiy geschrieben:
> The funcion loads dirty bitmap from file, using underlying driver
> function.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  block/dirty-bitmap.c         | 16 ++++++++++++++++
>  include/block/dirty-bitmap.h |  2 ++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
> index 6df7fe1..1d0ea25 100644
> --- a/block/dirty-bitmap.c
> +++ b/block/dirty-bitmap.c
> @@ -597,3 +597,19 @@ void bdrv_finalize_persistent_dirty_bitmaps(BlockDriverState *bs)
>          }
>      }
>  }
> +
> +BdrvDirtyBitmap *bdrv_load_dirty_bitmap(BlockDriverState *bs, const char *name,
> +                                        Error **errp)
> +{
> +    BlockDriver *drv = bs->drv;
> +    if (!drv) {
> +        return NULL;
> +    }
> +    if (drv->bdrv_dirty_bitmap_load) {
> +        return drv->bdrv_dirty_bitmap_load(bs, name, errp);

Why the inconsistency between load_dirty and dirty_load? The bdrv_*
wrappers usually have exactly the same name as the BlockDriver fields.

> +    }
> +    if (bs->file)  {
> +        return bdrv_load_dirty_bitmap(bs, name, errp);
> +    }
> +    return NULL;
> +}

Let me ask a general question about this series: What is the expected
state after it is applied?

I'm asking because even after the full series is applied, I don't see a
single user of bdrv_load_dirty_bitmap(), bdrv_load_check_dirty_bitmap()
or bdrv_store_dirty_bitmap(). Is all of this dead code?

Kevin
Vladimir Sementsov-Ogievskiy Aug. 11, 2016, 11:29 a.m. UTC | #2
On 11.08.2016 14:24, Kevin Wolf wrote:
> Am 08.08.2016 um 17:05 hat Vladimir Sementsov-Ogievskiy geschrieben:
>> The funcion loads dirty bitmap from file, using underlying driver
>> function.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>>   block/dirty-bitmap.c         | 16 ++++++++++++++++
>>   include/block/dirty-bitmap.h |  2 ++
>>   2 files changed, 18 insertions(+)
>>
>> diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
>> index 6df7fe1..1d0ea25 100644
>> --- a/block/dirty-bitmap.c
>> +++ b/block/dirty-bitmap.c
>> @@ -597,3 +597,19 @@ void bdrv_finalize_persistent_dirty_bitmaps(BlockDriverState *bs)
>>           }
>>       }
>>   }
>> +
>> +BdrvDirtyBitmap *bdrv_load_dirty_bitmap(BlockDriverState *bs, const char *name,
>> +                                        Error **errp)
>> +{
>> +    BlockDriver *drv = bs->drv;
>> +    if (!drv) {
>> +        return NULL;
>> +    }
>> +    if (drv->bdrv_dirty_bitmap_load) {
>> +        return drv->bdrv_dirty_bitmap_load(bs, name, errp);
> Why the inconsistency between load_dirty and dirty_load? The bdrv_*
> wrappers usually have exactly the same name as the BlockDriver fields.
>
>> +    }
>> +    if (bs->file)  {
>> +        return bdrv_load_dirty_bitmap(bs, name, errp);
>> +    }
>> +    return NULL;
>> +}
> Let me ask a general question about this series: What is the expected
> state after it is applied?
>
> I'm asking because even after the full series is applied, I don't see a
> single user of bdrv_load_dirty_bitmap(), bdrv_load_check_dirty_bitmap()
> or bdrv_store_dirty_bitmap(). Is all of this dead code?

Hmm, you are right, it's my mistake. It is dead code after removing 
command line options for dirty bitmaps from the series. Also, for now 
only autoloading bitmaps can be loaded. I'll remove these functions in 
next version, they may be added later, when we need loading bitmaps by 
request (qmp command or cmd line).

>
> Kevin

Patch
diff mbox

diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 6df7fe1..1d0ea25 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -597,3 +597,19 @@  void bdrv_finalize_persistent_dirty_bitmaps(BlockDriverState *bs)
         }
     }
 }
+
+BdrvDirtyBitmap *bdrv_load_dirty_bitmap(BlockDriverState *bs, const char *name,
+                                        Error **errp)
+{
+    BlockDriver *drv = bs->drv;
+    if (!drv) {
+        return NULL;
+    }
+    if (drv->bdrv_dirty_bitmap_load) {
+        return drv->bdrv_dirty_bitmap_load(bs, name, errp);
+    }
+    if (bs->file)  {
+        return bdrv_load_dirty_bitmap(bs, name, errp);
+    }
+    return NULL;
+}
diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index 05aa7f9..d482098 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -81,5 +81,7 @@  void bdrv_dirty_bitmap_set_persistance(BdrvDirtyBitmap *bitmap,
 void bdrv_store_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap,
                              Error **errp);
 void bdrv_finalize_persistent_dirty_bitmaps(BlockDriverState *bs);
+BdrvDirtyBitmap *bdrv_load_dirty_bitmap(BlockDriverState *bs, const char *name,
+                                        Error **errp);
 
 #endif