qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCHv2 11/11] iscsi: assert that sectors are aligned


From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCHv2 11/11] iscsi: assert that sectors are aligned to LUN blocksize
Date: Wed, 10 Jul 2013 13:38:29 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Am 27.06.2013 um 15:11 hat Peter Lieven geschrieben:
> if the blocksize of an iSCSI LUN is bigger than the BDRV_SECTOR_SIZE
> it is possible that sector_num or nb_sectors are not correctly
> alligned.
> 
> to avoid corruption we fail requests which are misaligned.
> 
> Signed-off-by: Peter Lieven <address@hidden>
> ---
>  block/iscsi.c |   27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/block/iscsi.c b/block/iscsi.c
> index 0567b46..bff2e1f 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -298,6 +298,13 @@ static int64_t sector_lun2qemu(int64_t sector, IscsiLun 
> *iscsilun)
>      return sector * iscsilun->block_size / BDRV_SECTOR_SIZE;
>  }
>  
> +static int64_t is_request_lun_aligned(int64_t sector_num, int nb_sectors,
> +                                      IscsiLun *iscsilun)

This should certainly return bool instead of int64_t?

> +{
> +    return ((sector_num * BDRV_SECTOR_SIZE) % iscsilun->block_size ||
> +            (nb_sectors * BDRV_SECTOR_SIZE) % iscsilun->block_size) ? 0 : 1;

'x ? 0 : 1' is usually written '!x'.

Kevin



reply via email to

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