diff mbox

[RFC,11/14] allow writing to the backing file

Message ID 1423710438-14377-12-git-send-email-wency@cn.fujitsu.com
State New
Headers show

Commit Message

Wen Congyang Feb. 12, 2015, 3:07 a.m. UTC
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 block.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Max Reitz Feb. 23, 2015, 10:03 p.m. UTC | #1
On 2015-02-11 at 22:07, Wen Congyang wrote:
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>   block.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

I don't think this is a good idea. With this patch, every time you open 
a COW file (with a backing file) R/W, the backing file will be writable. 
I'd rather like a way to explicitly overwrite the R/W mode of the 
backing file; but by default, in my opinion, it should stay read-only.

Max

> diff --git a/block.c b/block.c
> index 067c44b..96cf973 100644
> --- a/block.c
> +++ b/block.c
> @@ -856,8 +856,8 @@ static int bdrv_inherited_flags(int flags)
>    */
>   static int bdrv_backing_flags(int flags)
>   {
> -    /* backing files always opened read-only */
> -    flags &= ~(BDRV_O_RDWR | BDRV_O_COPY_ON_READ);
> +    /* backing files are opened read-write for block replication */
> +    flags &= ~BDRV_O_COPY_ON_READ;
>   
>       /* snapshot=on is handled on the top layer */
>       flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_TEMPORARY);
Paolo Bonzini Feb. 26, 2015, 2:15 p.m. UTC | #2
On 23/02/2015 23:03, Max Reitz wrote:
> On 2015-02-11 at 22:07, Wen Congyang wrote:
>> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
>> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>> ---
>>   block.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> I don't think this is a good idea. With this patch, every time you open
> a COW file (with a backing file) R/W, the backing file will be writable.
> I'd rather like a way to explicitly overwrite the R/W mode of the
> backing file; but by default, in my opinion, it should stay read-only.

I agree.

Perhaps blkcolo_open or colo_svm_init can take care of setting
BDRV_O_RDWR on the backing file?  They could also use bdrv_reopen.

Paolo

> Max
> 
>> diff --git a/block.c b/block.c
>> index 067c44b..96cf973 100644
>> --- a/block.c
>> +++ b/block.c
>> @@ -856,8 +856,8 @@ static int bdrv_inherited_flags(int flags)
>>    */
>>   static int bdrv_backing_flags(int flags)
>>   {
>> -    /* backing files always opened read-only */
>> -    flags &= ~(BDRV_O_RDWR | BDRV_O_COPY_ON_READ);
>> +    /* backing files are opened read-write for block replication */
>> +    flags &= ~BDRV_O_COPY_ON_READ;
>>         /* snapshot=on is handled on the top layer */
>>       flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_TEMPORARY);
>
diff mbox

Patch

diff --git a/block.c b/block.c
index 067c44b..96cf973 100644
--- a/block.c
+++ b/block.c
@@ -856,8 +856,8 @@  static int bdrv_inherited_flags(int flags)
  */
 static int bdrv_backing_flags(int flags)
 {
-    /* backing files always opened read-only */
-    flags &= ~(BDRV_O_RDWR | BDRV_O_COPY_ON_READ);
+    /* backing files are opened read-write for block replication */
+    flags &= ~BDRV_O_COPY_ON_READ;
 
     /* snapshot=on is handled on the top layer */
     flags &= ~(BDRV_O_SNAPSHOT | BDRV_O_TEMPORARY);