[Devel] [PATCH RHEL7 COMMIT] ploop: Introduce set- and clear- holes_bitmap wrappers
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Jun 14 19:13:07 MSK 2019
The commit is pushed to "branch-rh7-3.10.0-957.12.2.vz7.96.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.12.2.vz7.96.15
------>
commit 33021248ad30fe14d5392f76bf42877965045fd2
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Fri Jun 14 19:13:05 2019 +0300
ploop: Introduce set- and clear- holes_bitmap wrappers
Introduce helpers doing sanity check and use them
instead of direct set_bit() and clear_bit().
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/block/ploop/fmt_ploop1.c | 34 +++++++++++++++++++++++++++++-----
1 file changed, 29 insertions(+), 5 deletions(-)
diff --git a/drivers/block/ploop/fmt_ploop1.c b/drivers/block/ploop/fmt_ploop1.c
index 0d4c587f46b4..990ac79432ea 100644
--- a/drivers/block/ploop/fmt_ploop1.c
+++ b/drivers/block/ploop/fmt_ploop1.c
@@ -28,6 +28,30 @@ struct ploop1_private
u32 nr_clusters_in_bitmap;
};
+static void ploop_set_holes_bitmap_bit(unsigned int nr, struct ploop_delta *delta)
+{
+ struct ploop1_private *ph = delta->priv;
+
+ if (WARN_ON_ONCE(nr >= ph->nr_clusters_in_bitmap)) {
+ pr_err("nr=%u, nr_clusters=%u\n", nr, ph->nr_clusters_in_bitmap);
+ return;
+ }
+
+ set_bit(nr, delta->holes_bitmap);
+}
+
+static void ploop_clear_holes_bitmap_bit(unsigned int nr, struct ploop_delta *delta)
+{
+ struct ploop1_private *ph = delta->priv;
+
+ if (WARN_ON_ONCE(nr >= ph->nr_clusters_in_bitmap)) {
+ pr_err("nr=%u, nr_clusters=%u\n", nr, ph->nr_clusters_in_bitmap);
+ return;
+ }
+
+ clear_bit(nr, delta->holes_bitmap);
+}
+
int ploop1_map_index(struct ploop_delta * delta, unsigned long block, sector_t *sec)
{
struct ploop1_private * ph = delta->priv;
@@ -183,8 +207,8 @@ static int populate_holes_bitmap(struct ploop_delta *delta,
index = page_address(page);
for (i = off; i < INDEX_PER_PAGE && block + i - off < nr_blocks; i++) {
if (index[i] != 0) {
- clear_bit((index[i] >> ploop_map_log(delta->plo)),
- delta->holes_bitmap);
+ ploop_clear_holes_bitmap_bit(
+ index[i] >> ploop_map_log(delta->plo), delta);
}
}
@@ -352,7 +376,7 @@ ploop1_allocate(struct ploop_delta * delta, struct ploop_request * preq,
if (ret == 1 && cluster) {
/* Success. Mark cluster as occupied */
- clear_bit(cluster, delta->holes_bitmap);
+ ploop_clear_holes_bitmap_bit(cluster, delta);
/*
* FIXME: but what about failing requests,
* which return success? Should we add
@@ -731,7 +755,7 @@ ploop1_prepare_grow(struct ploop_delta * delta, u64 *new_size, int *reloc)
if (delta->holes_bitmap) {
i = delta->io.plo->grow_start;
while (i <= delta->io.plo->grow_end)
- clear_bit(i++, delta->holes_bitmap);
+ ploop_clear_holes_bitmap_bit(i++, delta);
}
}
@@ -817,7 +841,7 @@ static void ploop1_add_free_blk(struct ploop_delta *delta, struct ploop_request
cluster = blk >> ploop_map_log(delta->plo);
WARN_ON_ONCE(test_bit(cluster, delta->holes_bitmap));
- set_bit(cluster, delta->holes_bitmap);
+ ploop_set_holes_bitmap_bit(cluster, delta->holes_bitmap);
}
static struct ploop_delta_ops ploop1_delta_ops =
More information about the Devel
mailing list