[RHEL7,COMMIT] ploop: Ignore clusters above holes_bitmap

Submitted by Konstantin Khorenko on June 14, 2019, 4:13 p.m.

Details

Message ID 201906141613.x5EGD68N009336@finist-ce7.sw.ru
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko June 14, 2019, 4:13 p.m.
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 9e79e31468f60f4d7e43a4d0f47a3cebf58a0e09
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Fri Jun 14 19:13:06 2019 +0300

    ploop: Ignore clusters above holes_bitmap
    
    On grow we may assign cluster above holes_bitmap
    in case of old holes_bitmap is not enough to fit
    intensive io. Handle this.
    
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/fmt_ploop1.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/fmt_ploop1.c b/drivers/block/ploop/fmt_ploop1.c
index 990ac79432ea..8a890577e35d 100644
--- a/drivers/block/ploop/fmt_ploop1.c
+++ b/drivers/block/ploop/fmt_ploop1.c
@@ -207,8 +207,13 @@  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) {
-				ploop_clear_holes_bitmap_bit(
-						index[i] >> ploop_map_log(delta->plo), delta);
+				unsigned int cluster = index[i] >> ploop_map_log(delta->plo);
+				/*
+				 * On grow cluster above nr_clusters_in_bitmap may
+				 * be assigned. Ignore it.
+				 */
+				if (likely(cluster < ph->nr_clusters_in_bitmap))
+					ploop_clear_holes_bitmap_bit(cluster, delta);
 			}
 		}
 
@@ -823,6 +828,7 @@  static int ploop1_complete_grow(struct ploop_delta * delta, u64 new_size)
 
 static void ploop1_add_free_blk(struct ploop_delta *delta, struct ploop_request *preq)
 {
+	struct ploop1_private *ph = delta->priv;
 	struct map_node *m = preq->map;
 	cluster_t cluster;
 	map_index_t blk;
@@ -839,6 +845,13 @@  static void ploop1_add_free_blk(struct ploop_delta *delta, struct ploop_request
 		return;
 
 	cluster = blk >> ploop_map_log(delta->plo);
+	if (cluster > ph->nr_clusters_in_bitmap) {
+		/*
+		 * On grow cluster above nr_clusters_in_bitmap
+		 * may be assigned. Here we handle that.
+		 */
+		return;
+	}
 
 	WARN_ON_ONCE(test_bit(cluster, delta->holes_bitmap));
 	ploop_set_holes_bitmap_bit(cluster, delta->holes_bitmap);