Re: [Qemu-devel] [Qemu-block] [PATCH for-2.10 14/16] block/qcow2: falloc/full preallocating growth
On Mon, Mar 20, 2017 at 04:15:59PM +0100, Max Reitz wrote: > On 20.03.2017 12:29, Stefan Hajnoczi wrote: > > On Mon, Mar 13, 2017 at 10:41:15PM +0100, Max Reitz wrote: > >> Implement the preallocation modes falloc and full for growing qcow2 > >> images. > >> > >> Signed-off-by: Max Reitz > >> --- > >> block/qcow2.c | 36 +++- > >> 1 file changed, 35 insertions(+), 1 deletion(-) > >> > >> diff --git a/block/qcow2.c b/block/qcow2.c > >> index 80fb815b15..b6b08d70da 100644 > >> --- a/block/qcow2.c > >> +++ b/block/qcow2.c > >> @@ -2604,7 +2604,9 @@ static int qcow2_truncate(BlockDriverState *bs, > >> int64_t offset, > >> int64_t new_l1_size; > >> int ret; > >> > >> -if (prealloc != PREALLOC_MODE_OFF && prealloc != > >> PREALLOC_MODE_METADATA) { > >> +if (prealloc != PREALLOC_MODE_OFF && prealloc != > >> PREALLOC_MODE_METADATA && > >> +prealloc != PREALLOC_MODE_FALLOC && prealloc != > >> PREALLOC_MODE_FULL) > > > > Now all cases are covered so this if statement can be dropped. If you > > are worried about new preallocation modes being added in the future then > > the error_setg() can be moved into the switch statement's default case. > > No, because the switch comes after we have already grown the L1 table. > That wouldn't be so nice. Oops :) Stefan signature.asc Description: PGP signature
Re: [Qemu-devel] [Qemu-block] [PATCH for-2.10 14/16] block/qcow2: falloc/full preallocating growth
On 20.03.2017 12:29, Stefan Hajnoczi wrote: > On Mon, Mar 13, 2017 at 10:41:15PM +0100, Max Reitz wrote: >> Implement the preallocation modes falloc and full for growing qcow2 >> images. >> >> Signed-off-by: Max Reitz >> --- >> block/qcow2.c | 36 +++- >> 1 file changed, 35 insertions(+), 1 deletion(-) >> >> diff --git a/block/qcow2.c b/block/qcow2.c >> index 80fb815b15..b6b08d70da 100644 >> --- a/block/qcow2.c >> +++ b/block/qcow2.c >> @@ -2604,7 +2604,9 @@ static int qcow2_truncate(BlockDriverState *bs, >> int64_t offset, >> int64_t new_l1_size; >> int ret; >> >> -if (prealloc != PREALLOC_MODE_OFF && prealloc != >> PREALLOC_MODE_METADATA) { >> +if (prealloc != PREALLOC_MODE_OFF && prealloc != PREALLOC_MODE_METADATA >> && >> +prealloc != PREALLOC_MODE_FALLOC && prealloc != PREALLOC_MODE_FULL) > > Now all cases are covered so this if statement can be dropped. If you > are worried about new preallocation modes being added in the future then > the error_setg() can be moved into the switch statement's default case. No, because the switch comes after we have already grown the L1 table. That wouldn't be so nice. Max signature.asc Description: OpenPGP digital signature
Re: [Qemu-devel] [Qemu-block] [PATCH for-2.10 14/16] block/qcow2: falloc/full preallocating growth
On Mon, Mar 13, 2017 at 10:41:15PM +0100, Max Reitz wrote: > Implement the preallocation modes falloc and full for growing qcow2 > images. > > Signed-off-by: Max Reitz > --- > block/qcow2.c | 36 +++- > 1 file changed, 35 insertions(+), 1 deletion(-) > > diff --git a/block/qcow2.c b/block/qcow2.c > index 80fb815b15..b6b08d70da 100644 > --- a/block/qcow2.c > +++ b/block/qcow2.c > @@ -2604,7 +2604,9 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t > offset, > int64_t new_l1_size; > int ret; > > -if (prealloc != PREALLOC_MODE_OFF && prealloc != PREALLOC_MODE_METADATA) > { > +if (prealloc != PREALLOC_MODE_OFF && prealloc != PREALLOC_MODE_METADATA > && > +prealloc != PREALLOC_MODE_FALLOC && prealloc != PREALLOC_MODE_FULL) Now all cases are covered so this if statement can be dropped. If you are worried about new preallocation modes being added in the future then the error_setg() can be moved into the switch statement's default case. signature.asc Description: PGP signature