[Devel] [PATCH RHEL7 COMMIT] cbt: fix cbt->block_max calculation
Konstantin Khorenko
khorenko at virtuozzo.com
Tue May 10 09:26:29 PDT 2016
The commit is pushed to "branch-rh7-3.10.0-327.10.1.vz7.12.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.10.1.vz7.12.17
------>
commit c16aa030e3245b595bba98d67c926f0a6f575752
Author: Maxim Patlasov <mpatlasov at virtuozzo.com>
Date: Tue May 10 20:26:29 2016 +0400
cbt: fix cbt->block_max calculation
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>
Acked-by: Dmitry Monakhov <dmonakhov at openvz.org>
---
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 056918c..6323243 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