[Devel] [PATCH rh7] cbt: fix cbt->block_max calculation
Maxim Patlasov
mpatlasov at virtuozzo.com
Mon May 9 14:59:20 PDT 2016
When the size of block device is multiple of CBT blocksize, the following:
> cbt->block_max = (size + blocksize) >> cbt->block_bits;
is incorrect. This may end up in allocating one extra page in cbt->map and
also make various checks with cbt->block_max prone to error.
Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
---
block/blk-cbt.c | 2 +-
drivers/block/ploop/push_backup.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/blk-cbt.c b/block/blk-cbt.c
index 8c52bd8..8cdf1d6 100644
--- a/block/blk-cbt.c
+++ b/block/blk-cbt.c
@@ -252,7 +252,7 @@ static struct cbt_info* do_cbt_alloc(struct request_queue *q, __u8 *uuid,
return ERR_PTR(-ENOMEM);
cbt->block_bits = ilog2(blocksize);
- cbt->block_max = (size + blocksize) >> cbt->block_bits;
+ cbt->block_max = (size + blocksize - 1) >> cbt->block_bits;
spin_lock_init(&cbt->lock);
memcpy(cbt->uuid, uuid, sizeof(cbt->uuid));
cbt->cache = alloc_percpu(struct cbt_extent);
diff --git a/drivers/block/ploop/push_backup.c b/drivers/block/ploop/push_backup.c
index 05af67c..4d671a5 100644
--- a/drivers/block/ploop/push_backup.c
+++ b/drivers/block/ploop/push_backup.c
@@ -175,7 +175,7 @@ bool ploop_pb_check_bit(struct ploop_pushbackup_desc *pbd, cluster_t clu)
static int convert_map_to_map(struct ploop_pushbackup_desc *pbd)
{
struct page **from_map = pbd->cbt_map;
- blkcnt_t from_max = pbd->cbt_block_max - 1;
+ blkcnt_t from_max = pbd->cbt_block_max;
blkcnt_t from_bits = pbd->cbt_block_bits;
struct page **to_map = pbd->ppb_map;
More information about the Devel
mailing list