[Devel] [PATCH rh7] cbt: blk_cbt_update_size() must return if cbt->block_max not changed

Maxim Patlasov mpatlasov at virtuozzo.com
Wed Jun 8 19:00:33 PDT 2016


It's useless to recreate cbt every time as we called for the same
block-device size. Actually, it's worthy only if cbt->block_max
increases.

Since commit b8e560a299 (fix cbt->block_max calculation), we calculate
cbt->block_max precisely:

>       cbt->block_max  = (size + blocksize - 1) >> cbt->block_bits;

Hence, the following check:

	if ((new_sz + bsz) >> cbt->block_bits <= cbt->block_max)
		goto err_mtx;

must be corrected accordingly.

Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
---
 block/blk-cbt.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-cbt.c b/block/blk-cbt.c
index 3a2b197..4f2ce26 100644
--- a/block/blk-cbt.c
+++ b/block/blk-cbt.c
@@ -440,7 +440,7 @@ void blk_cbt_update_size(struct block_device *bdev)
 		return;
 	}
 	bsz = 1 << cbt->block_bits;
-	if ((new_sz + bsz) >> cbt->block_bits <= cbt->block_max)
+	if ((new_sz + bsz - 1) >> cbt->block_bits <= cbt->block_max)
 		goto err_mtx;
 
 	new = do_cbt_alloc(q, cbt->uuid, new_sz, bsz);



More information about the Devel mailing list