[Devel] [PATCH RHEL7 COMMIT] ploop: Track if we have delta with disable_merge

Vasily Averin vvs at virtuozzo.com
Tue Aug 24 14:39:41 MSK 2021


The commit is pushed to "branch-rh7-3.10.0-1160.36.2.vz7.182.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.36.2.vz7.182.1
------>
commit 004f568630f778a6fb3d2ecf5749b926a973b1de
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Tue Aug 24 14:39:41 2021 +0300

    ploop: Track if we have delta with disable_merge
    
    Add a notifier after delta list change, which
    will allow to skip disable merge in next patch.
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/block/ploop/dev.c   |  7 +++++++
 include/linux/ploop/ploop.h | 14 ++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 0a6c411..c4cb944 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -3519,6 +3519,7 @@ static int ploop_add_delta(struct ploop_device * plo, unsigned long arg)
 	mutex_lock(&plo->sysfs_mutex);
 	list_add(&delta->list, &plo->map.delta_list);
 	mutex_unlock(&plo->sysfs_mutex);
+	ploop_delta_list_changed(plo);
 	set_bit(PLOOP_S_CHANGED, &plo->state);
 
 	/*
@@ -3602,6 +3603,7 @@ static int ploop_replace_delta(struct ploop_device * plo, unsigned long arg)
 
 	ploop_map_destroy(&plo->map);
 	list_replace_init(&old_delta->list, &delta->list);
+	ploop_delta_list_changed(plo);
 	clear_bit(PLOOP_S_ABORT, &plo->state);
 
 	spin_lock_irq(plo->queue->queue_lock);
@@ -3892,6 +3894,7 @@ static int ploop_snapshot(struct ploop_device * plo, unsigned long arg,
 		list_add(&delta->list, &plo->map.delta_list);
 		clear_bit(PLOOP_MAP_IDENTICAL, &plo->map.flags);
 		mutex_unlock(&plo->sysfs_mutex);
+		ploop_delta_list_changed(plo);
 	}
 	ploop_relax(plo);
 
@@ -4010,6 +4013,7 @@ static int ploop_del_delta(struct ploop_device * plo, unsigned long arg)
 	ploop_quiesce(plo);
 	next = list_entry(delta->list.next, struct ploop_delta, list);
 	list_del(&delta->list);
+	ploop_delta_list_changed(plo);
 	if (list_empty(&plo->map.delta_list))
 		plo->cookie[0] = 0;
 	if (level != 0)
@@ -4111,6 +4115,7 @@ static void ploop_merge_complete(struct ploop_device * plo,
 	plo->trans_map = NULL;
 	plo->maintenance_type = PLOOP_MNTN_OFF;
 	mutex_unlock(&plo->sysfs_mutex);
+	ploop_delta_list_changed(plo);
 	ploop_map_destroy(map);
 	ploop_relax(plo);
 }
@@ -4194,6 +4199,7 @@ static int ploop_merge(struct ploop_device * plo)
 		plo->trans_map = map;
 		plo->maintenance_type = PLOOP_MNTN_MERGE;
 		mutex_unlock(&plo->sysfs_mutex);
+		ploop_delta_list_changed(plo);
 	} else {
 		/* Yes. All transient obstacles must be resolved
 		 * in prepare_merge. Failed start_merge means
@@ -4540,6 +4546,7 @@ static void destroy_deltas(struct ploop_device * plo, struct ploop_map * map)
 		mutex_lock(&plo->sysfs_mutex);
 		list_del(&delta->list);
 		mutex_unlock(&plo->sysfs_mutex);
+		ploop_delta_list_changed(plo);
 
 		kobject_del(&delta->kobj);
 		kobject_put(&plo->kobj);
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index 2256eb4..d0f6657 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -490,6 +490,7 @@ struct ploop_device
 	unsigned long		locking_state; /* plo locked by userspace */
 	unsigned int		fast_path_disabled_count;
 	unsigned int		discard_disabled_count;
+	bool			has_disable_merge;
 };
 
 enum
@@ -650,6 +651,19 @@ static inline struct ploop_delta * map_top_delta(struct ploop_map * map)
 	return list_first_entry(&map->delta_list, struct ploop_delta, list);
 }
 
+static inline void ploop_delta_list_changed(struct ploop_device *plo)
+{
+	bool has_disable_merge = false;
+	struct ploop_delta *delta;
+
+	list_for_each_entry(delta, &plo->map.delta_list, list) {
+		if (delta->io.ops->disable_merge)
+			has_disable_merge = true;
+	}
+
+	plo->has_disable_merge = has_disable_merge;
+}
+
 static inline unsigned int cluster_size_in_bytes(struct ploop_device *plo)
 {
 	return 1 << (plo->cluster_log + 9);


More information about the Devel mailing list