[Devel] [RH7 PATCH] cbt: fix blk_cbt_set endless loop

Vasily Averin vvs at virtuozzo.com
Tue Feb 9 06:34:02 PST 2016


On 09.02.2016 17:19, Dmitry Monakhov wrote:
> - If (count % BITS_PER_PAGE == 0) we stuck in endless loop.
> - (!set) case was also wrong
> 
> https://jira.sw.ru/browse/PSBM-43936
> 
> Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
Reviewed-by:	Vasily Averin <vvs at virtuozzo.com>

> ---
>  block/blk-cbt.c |    7 +++----
>  1 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/block/blk-cbt.c b/block/blk-cbt.c
> index 99d4a76..7a4303f 100644
> --- a/block/blk-cbt.c
> +++ b/block/blk-cbt.c
> @@ -93,10 +93,9 @@ static int __blk_cbt_set(struct cbt_info  *cbt, blkcnt_t block,
>  	while(count) {
>  		unsigned long idx = block >> (PAGE_SHIFT + 3);
>  		unsigned long off = block & (BITS_PER_PAGE -1);
> -		unsigned long len = count & (BITS_PER_PAGE -1);
> +		unsigned long len = min_t(unsigned long, BITS_PER_PAGE - off,
> +					  count);
>  
> -		if (off + len > BITS_PER_PAGE)
> -			len = BITS_PER_PAGE - off;
>  		page = rcu_dereference(cbt->map[idx]);
>  		if (page) {
>  			spin_lock_page(page);
> @@ -107,7 +106,7 @@ static int __blk_cbt_set(struct cbt_info  *cbt, blkcnt_t block,
>  			continue;
>  		} else {
>  			if (!set) {
> -				len = count & (BITS_PER_PAGE -1);
> +				/* Nothing to do */
>  				count -= len;
>  				block += len;
>  				continue;
> 


More information about the Devel mailing list