Patchwork block: use DIV_ROUND_UP in bdrv_co_do_readv

login
register
mail settings
Submitter Fam Zheng
Date Sept. 26, 2013, 11:55 a.m.
Message ID <1380196533-18525-1-git-send-email-famz@redhat.com>
Download mbox | patch
Permalink /patch/278179/
State New
Headers show

Comments

Fam Zheng - Sept. 26, 2013, 11:55 a.m.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Eric Blake - Sept. 26, 2013, 12:05 p.m.
On 09/26/2013 05:55 AM, Fam Zheng wrote:
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  block.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/block.c b/block.c
> index ea4956d..fe7b060 100644
> --- a/block.c
> +++ b/block.c
> @@ -2669,7 +2669,7 @@ static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs,
>              goto out;
>          }
>  
> -        total_sectors = (len + BDRV_SECTOR_SIZE - 1) >> BDRV_SECTOR_BITS;
> +        total_sectors = DIV_ROUND_UP(len, BDRV_SECTOR_SIZE);

Reviewed-by: Eric Blake <eblake@redhat.com>
Kevin Wolf - Sept. 26, 2013, 12:11 p.m.
Am 26.09.2013 um 14:05 hat Eric Blake geschrieben:
> On 09/26/2013 05:55 AM, Fam Zheng wrote:
> > Signed-off-by: Fam Zheng <famz@redhat.com>
> > ---
> >  block.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/block.c b/block.c
> > index ea4956d..fe7b060 100644
> > --- a/block.c
> > +++ b/block.c
> > @@ -2669,7 +2669,7 @@ static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs,
> >              goto out;
> >          }
> >  
> > -        total_sectors = (len + BDRV_SECTOR_SIZE - 1) >> BDRV_SECTOR_BITS;
> > +        total_sectors = DIV_ROUND_UP(len, BDRV_SECTOR_SIZE);
> 
> Reviewed-by: Eric Blake <eblake@redhat.com>

Thanks, applied to the block branch.

Kevin

Patch

diff --git a/block.c b/block.c
index ea4956d..fe7b060 100644
--- a/block.c
+++ b/block.c
@@ -2669,7 +2669,7 @@  static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs,
             goto out;
         }
 
-        total_sectors = (len + BDRV_SECTOR_SIZE - 1) >> BDRV_SECTOR_BITS;
+        total_sectors = DIV_ROUND_UP(len, BDRV_SECTOR_SIZE);
         max_nb_sectors = MAX(0, total_sectors - sector_num);
         if (max_nb_sectors > 0) {
             ret = drv->bdrv_co_readv(bs, sector_num,