qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH] block/iscsi: precache the allocation status of


From: Paolo Bonzini
Subject: Re: [Qemu-block] [PATCH] block/iscsi: precache the allocation status of a target
Date: Thu, 30 Jun 2016 17:59:01 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1


On 30/06/2016 13:08, Peter Lieven wrote:
> this fills up the allocationmap at iscsi_open. This helps
> to reduce the number of get_block_status requests during runtime
> significantly.
> 
> Signed-off-by: Peter Lieven <address@hidden>
> ---
>  block/iscsi.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/block/iscsi.c b/block/iscsi.c
> index 0cdcedb..04fb0a3 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -1774,6 +1774,22 @@ static int iscsi_open(BlockDriverState *bs, QDict 
> *options, int flags,
>                                       iscsilun->block_size) >> 
> BDRV_SECTOR_BITS;
>          if (iscsilun->lbprz) {
>              ret = iscsi_allocmap_init(iscsilun, bs->open_flags);
> +            if (ret == 0) {
> +                unsigned int max_reqs = 64;
> +                int64_t sector_num = 0;
> +                while (max_reqs-- && sector_num < bs->total_sectors) {
> +                    int n;
> +                    BlockDriverState *file;
> +                    ret = bdrv_get_block_status(bs, sector_num,
> +                                                BDRV_REQUEST_MAX_SECTORS,
> +                                                &n, &file);
> +                    if (ret < 0) {
> +                        break;
> +                    }
> +                    sector_num += n;
> +                    ret = 0;
> +                }
> +            }
>          }
>      }
>  
> 

This can take a long time and the disks may not even be ever used.  I
don't think it's a good idea.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]