diff mbox

[v4,7/7] block: Allow backup on referenced named BlockDriverState

Message ID 1385097894-1380-8-git-send-email-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng Nov. 22, 2013, 5:24 a.m. UTC
Drive backup is a read only operation on source bs. We want to allow
this specific case to enable image-fleecing. Note that when
image-fleecing job starts, the job still add its blocker to source bs,
and any other operation on it will be blocked by that.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Kevin Wolf Nov. 25, 2013, 11:23 a.m. UTC | #1
Am 22.11.2013 um 06:24 hat Fam Zheng geschrieben:
> Drive backup is a read only operation on source bs. We want to allow
> this specific case to enable image-fleecing. Note that when
> image-fleecing job starts, the job still add its blocker to source bs,
> and any other operation on it will be blocked by that.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  block.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/block.c b/block.c
> index a5da656..d30be51 100644
> --- a/block.c
> +++ b/block.c
> @@ -1179,6 +1179,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
>                             "device is used as backing hd of '%s'",
>                             bs->device_name);
>                  bdrv_op_block_all(bs->backing_hd, bs->backing_blocker);
> +                bdrv_op_unblock(bs->backing_hd, BLOCK_OP_TYPE_BACKUP,
> +                                bs->backing_blocker);
>                  pstrcpy(bs->backing_file, sizeof(bs->backing_file),
>                          bs->backing_hd->filename);
>                  pstrcpy(bs->backing_format, sizeof(bs->backing_format),

We probably need separate blockers for "can be a backup source" and "can
be a backup target". Because I think this allows using it as a
read-write target as well, which was not intended.

Do we need to cover this in other parts of the code as well, like when
adding a new BDS during external snapshot creation?

Kevin
Fam Zheng Nov. 26, 2013, 3:06 a.m. UTC | #2
On 2013年11月25日 19:23, Kevin Wolf wrote:
> Am 22.11.2013 um 06:24 hat Fam Zheng geschrieben:
>> Drive backup is a read only operation on source bs. We want to allow
>> this specific case to enable image-fleecing. Note that when
>> image-fleecing job starts, the job still add its blocker to source bs,
>> and any other operation on it will be blocked by that.
>>
>> Signed-off-by: Fam Zheng <famz@redhat.com>
>> ---
>>   block.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/block.c b/block.c
>> index a5da656..d30be51 100644
>> --- a/block.c
>> +++ b/block.c
>> @@ -1179,6 +1179,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
>>                              "device is used as backing hd of '%s'",
>>                              bs->device_name);
>>                   bdrv_op_block_all(bs->backing_hd, bs->backing_blocker);
>> +                bdrv_op_unblock(bs->backing_hd, BLOCK_OP_TYPE_BACKUP,
>> +                                bs->backing_blocker);
>>                   pstrcpy(bs->backing_file, sizeof(bs->backing_file),
>>                           bs->backing_hd->filename);
>>                   pstrcpy(bs->backing_format, sizeof(bs->backing_format),
>
> We probably need separate blockers for "can be a backup source" and "can
> be a backup target". Because I think this allows using it as a
> read-write target as well, which was not intended.
>

Yes. Will do it.

> Do we need to cover this in other parts of the code as well, like when
> adding a new BDS during external snapshot creation?
>

Does it have a name? If not I think we are safe there.

Fam
Kevin Wolf Nov. 26, 2013, 11:02 a.m. UTC | #3
Am 26.11.2013 um 04:06 hat Fam Zheng geschrieben:
> On 2013年11月25日 19:23, Kevin Wolf wrote:
> >Am 22.11.2013 um 06:24 hat Fam Zheng geschrieben:
> >>Drive backup is a read only operation on source bs. We want to allow
> >>this specific case to enable image-fleecing. Note that when
> >>image-fleecing job starts, the job still add its blocker to source bs,
> >>and any other operation on it will be blocked by that.
> >>
> >>Signed-off-by: Fam Zheng <famz@redhat.com>
> >>---
> >>  block.c | 2 ++
> >>  1 file changed, 2 insertions(+)
> >>
> >>diff --git a/block.c b/block.c
> >>index a5da656..d30be51 100644
> >>--- a/block.c
> >>+++ b/block.c
> >>@@ -1179,6 +1179,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
> >>                             "device is used as backing hd of '%s'",
> >>                             bs->device_name);
> >>                  bdrv_op_block_all(bs->backing_hd, bs->backing_blocker);
> >>+                bdrv_op_unblock(bs->backing_hd, BLOCK_OP_TYPE_BACKUP,
> >>+                                bs->backing_blocker);
> >>                  pstrcpy(bs->backing_file, sizeof(bs->backing_file),
> >>                          bs->backing_hd->filename);
> >>                  pstrcpy(bs->backing_format, sizeof(bs->backing_format),
> >
> >We probably need separate blockers for "can be a backup source" and "can
> >be a backup target". Because I think this allows using it as a
> >read-write target as well, which was not intended.
> >
> 
> Yes. Will do it.
> 
> >Do we need to cover this in other parts of the code as well, like when
> >adding a new BDS during external snapshot creation?
> >
> 
> Does it have a name? If not I think we are safe there.

Not yet, but I think it won't be long until we do have named nodes
created this way, so considering it now certainly can't hurt.

Kevin
diff mbox

Patch

diff --git a/block.c b/block.c
index a5da656..d30be51 100644
--- a/block.c
+++ b/block.c
@@ -1179,6 +1179,8 @@  int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
                            "device is used as backing hd of '%s'",
                            bs->device_name);
                 bdrv_op_block_all(bs->backing_hd, bs->backing_blocker);
+                bdrv_op_unblock(bs->backing_hd, BLOCK_OP_TYPE_BACKUP,
+                                bs->backing_blocker);
                 pstrcpy(bs->backing_file, sizeof(bs->backing_file),
                         bs->backing_hd->filename);
                 pstrcpy(bs->backing_format, sizeof(bs->backing_format),