diff mbox

[v3,04/19] block: update bs->total_sectors on writes

Message ID 1374762197-7261-5-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini July 25, 2013, 2:23 p.m. UTC
If a BlockDriverState is growable, after every write we need to
check if bs->total_sectors might have changed.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Kevin Wolf July 29, 2013, 1:13 p.m. UTC | #1
Am 25.07.2013 um 16:23 hat Paolo Bonzini geschrieben:
> If a BlockDriverState is growable, after every write we need to
> check if bs->total_sectors might have changed.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  block.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/block.c b/block.c
> index 6cd39fa..ebac2fa 100644
> --- a/block.c
> +++ b/block.c
> @@ -2651,6 +2651,9 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs,
>      if (bs->wr_highest_sector < sector_num + nb_sectors - 1) {
>          bs->wr_highest_sector = sector_num + nb_sectors - 1;
>      }
> +    if (bs->growable && ret >= 0) {
> +        bs->total_sectors = MAX(bs->total_sectors, sector_num + nb_sectors);
> +    }

Can we change bdrv_getlength() to use bs->total_sectors even for
growable images after this patch?

Kevin
Paolo Bonzini July 29, 2013, 1:47 p.m. UTC | #2
Il 29/07/2013 15:13, Kevin Wolf ha scritto:
> Am 25.07.2013 um 16:23 hat Paolo Bonzini geschrieben:
>> If a BlockDriverState is growable, after every write we need to
>> check if bs->total_sectors might have changed.
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  block.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/block.c b/block.c
>> index 6cd39fa..ebac2fa 100644
>> --- a/block.c
>> +++ b/block.c
>> @@ -2651,6 +2651,9 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs,
>>      if (bs->wr_highest_sector < sector_num + nb_sectors - 1) {
>>          bs->wr_highest_sector = sector_num + nb_sectors - 1;
>>      }
>> +    if (bs->growable && ret >= 0) {
>> +        bs->total_sectors = MAX(bs->total_sectors, sector_num + nb_sectors);
>> +    }
> 
> Can we change bdrv_getlength() to use bs->total_sectors even for
> growable images after this patch?

Probably, but not in 1.6. :)

Paolo
Kevin Wolf July 29, 2013, 2:10 p.m. UTC | #3
Am 29.07.2013 um 15:47 hat Paolo Bonzini geschrieben:
> Il 29/07/2013 15:13, Kevin Wolf ha scritto:
> > Am 25.07.2013 um 16:23 hat Paolo Bonzini geschrieben:
> >> If a BlockDriverState is growable, after every write we need to
> >> check if bs->total_sectors might have changed.
> >>
> >> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> >> ---
> >>  block.c | 3 +++
> >>  1 file changed, 3 insertions(+)
> >>
> >> diff --git a/block.c b/block.c
> >> index 6cd39fa..ebac2fa 100644
> >> --- a/block.c
> >> +++ b/block.c
> >> @@ -2651,6 +2651,9 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs,
> >>      if (bs->wr_highest_sector < sector_num + nb_sectors - 1) {
> >>          bs->wr_highest_sector = sector_num + nb_sectors - 1;
> >>      }
> >> +    if (bs->growable && ret >= 0) {
> >> +        bs->total_sectors = MAX(bs->total_sectors, sector_num + nb_sectors);
> >> +    }
> > 
> > Can we change bdrv_getlength() to use bs->total_sectors even for
> > growable images after this patch?
> 
> Probably, but not in 1.6. :)

"Probably" was my conclusion as well. The answer to this question is the
answer to whether this patch makes sense, I think. So I can give you a
Probably-reviewed-by if that's of any use. ;-)

FWIW, I've got the feeling that the whole series might be better suited
for block-next. Is there anything urgent in it?

Kevin
Paolo Bonzini July 29, 2013, 2:18 p.m. UTC | #4
Il 29/07/2013 16:10, Kevin Wolf ha scritto:
> Am 29.07.2013 um 15:47 hat Paolo Bonzini geschrieben:
>> Il 29/07/2013 15:13, Kevin Wolf ha scritto:
>>> Am 25.07.2013 um 16:23 hat Paolo Bonzini geschrieben:
>>>> If a BlockDriverState is growable, after every write we need to
>>>> check if bs->total_sectors might have changed.
>>>>
>>>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>>>> ---
>>>>  block.c | 3 +++
>>>>  1 file changed, 3 insertions(+)
>>>>
>>>> diff --git a/block.c b/block.c
>>>> index 6cd39fa..ebac2fa 100644
>>>> --- a/block.c
>>>> +++ b/block.c
>>>> @@ -2651,6 +2651,9 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs,
>>>>      if (bs->wr_highest_sector < sector_num + nb_sectors - 1) {
>>>>          bs->wr_highest_sector = sector_num + nb_sectors - 1;
>>>>      }
>>>> +    if (bs->growable && ret >= 0) {
>>>> +        bs->total_sectors = MAX(bs->total_sectors, sector_num + nb_sectors);
>>>> +    }
>>>
>>> Can we change bdrv_getlength() to use bs->total_sectors even for
>>> growable images after this patch?
>>
>> Probably, but not in 1.6. :)
> 
> "Probably" was my conclusion as well. The answer to this question is the
> answer to whether this patch makes sense, I think. So I can give you a
> Probably-reviewed-by if that's of any use. ;-)
> 
> FWIW, I've got the feeling that the whole series might be better suited
> for block-next. Is there anything urgent in it?

No, I don't think so.

Paolo
Peter Lieven Aug. 2, 2013, 7:05 a.m. UTC | #5
On 29.07.2013 16:18, Paolo Bonzini wrote:
> Il 29/07/2013 16:10, Kevin Wolf ha scritto:
>> Am 29.07.2013 um 15:47 hat Paolo Bonzini geschrieben:
>>> Il 29/07/2013 15:13, Kevin Wolf ha scritto:
>>>> Am 25.07.2013 um 16:23 hat Paolo Bonzini geschrieben:
>>>>> If a BlockDriverState is growable, after every write we need to
>>>>> check if bs->total_sectors might have changed.
>>>>>
>>>>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>>>>> ---
>>>>>   block.c | 3 +++
>>>>>   1 file changed, 3 insertions(+)
>>>>>
>>>>> diff --git a/block.c b/block.c
>>>>> index 6cd39fa..ebac2fa 100644
>>>>> --- a/block.c
>>>>> +++ b/block.c
>>>>> @@ -2651,6 +2651,9 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs,
>>>>>       if (bs->wr_highest_sector < sector_num + nb_sectors - 1) {
>>>>>           bs->wr_highest_sector = sector_num + nb_sectors - 1;
>>>>>       }
>>>>> +    if (bs->growable && ret >= 0) {
>>>>> +        bs->total_sectors = MAX(bs->total_sectors, sector_num + nb_sectors);
>>>>> +    }
>>>> Can we change bdrv_getlength() to use bs->total_sectors even for
>>>> growable images after this patch?
>>> Probably, but not in 1.6. :)
>> "Probably" was my conclusion as well. The answer to this question is the
>> answer to whether this patch makes sense, I think. So I can give you a
>> Probably-reviewed-by if that's of any use. ;-)
>>
>> FWIW, I've got the feeling that the whole series might be better suited
>> for block-next. Is there anything urgent in it?
> No, I don't think so.
can you give an update what are to current plans/schedule to merge this series? I have
a few patches in the queue that in their current version depend on this series being merged.

Peter
Paolo Bonzini Aug. 17, 2013, 6:27 a.m. UTC | #6
Il 02/08/2013 09:05, Peter Lieven ha scritto:
> can you give an update what are to current plans/schedule to merge this
> series? I have
> a few patches in the queue that in their current version depend on this
> series being merged.

It should go in soon, perhaps a couple of weeks.

Paolo
Peter Lieven Sept. 2, 2013, 7:12 a.m. UTC | #7
On 17.08.2013 08:27, Paolo Bonzini wrote:
> Il 02/08/2013 09:05, Peter Lieven ha scritto:
>> can you give an update what are to current plans/schedule to merge this
>> series? I have
>> a few patches in the queue that in their current version depend on this
>> series being merged.
> It should go in soon, perhaps a couple of weeks.
That would be good. I would like to make the relevant changes to iscsi soon and
as I promised to convert everything in block/iscsi to coroutines this will be a lot.

Peter
diff mbox

Patch

diff --git a/block.c b/block.c
index 6cd39fa..ebac2fa 100644
--- a/block.c
+++ b/block.c
@@ -2651,6 +2651,9 @@  static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs,
     if (bs->wr_highest_sector < sector_num + nb_sectors - 1) {
         bs->wr_highest_sector = sector_num + nb_sectors - 1;
     }
+    if (bs->growable && ret >= 0) {
+        bs->total_sectors = MAX(bs->total_sectors, sector_num + nb_sectors);
+    }
 
     tracked_request_end(&req);