[Devel] [PATCH rh7 3/6] ploop: push_backup: extend pb_set
Maxim Patlasov
mpatlasov at virtuozzo.com
Tue Jun 14 17:53:41 PDT 2016
The patch adds more fields to pb_set: list, timer and name.
The list keeps ploop requests ordered by the time of arrival
to the tree: the first preq in the list is the oldest.
The patch only initializes "timer" and "name" fields. They
will be used by future patches.
Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
---
drivers/block/ploop/push_backup.c | 40 ++++++++++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)
diff --git a/drivers/block/ploop/push_backup.c b/drivers/block/ploop/push_backup.c
index 05dccfa..070e147 100644
--- a/drivers/block/ploop/push_backup.c
+++ b/drivers/block/ploop/push_backup.c
@@ -17,7 +17,11 @@
#define BITS_PER_PAGE (1UL << (PAGE_SHIFT + 3))
struct pb_set {
- struct rb_root tree;
+ struct rb_root tree;
+ struct list_head list;
+ struct timer_list timer;
+ char *name;
+ struct ploop_pushbackup_desc *pbd; /* points to parent pbd */
};
struct ploop_pushbackup_desc {
@@ -114,6 +118,26 @@ int ploop_pb_cbt_map_release(struct ploop_pushbackup_desc *pbd, bool do_merge)
return ret;
}
+static void ploop_pb_timeout_func(unsigned long data);
+
+static void ploop_pbs_init(struct pb_set *pbs,
+ struct ploop_pushbackup_desc *pbd, char *name)
+{
+ pbs->pbd = pbd;
+ pbs->name = name;
+ pbs->tree = RB_ROOT;
+ INIT_LIST_HEAD(&pbs->list);
+
+ init_timer(&pbs->timer);
+ pbs->timer.function = ploop_pb_timeout_func;
+ pbs->timer.data = (unsigned long)pbs;
+}
+
+static void ploop_pbs_fini(struct pb_set *pbs)
+{
+ del_timer_sync(&pbs->timer);
+}
+
struct ploop_pushbackup_desc *ploop_pb_alloc(struct ploop_device *plo)
{
struct ploop_pushbackup_desc *pbd;
@@ -140,8 +164,8 @@ struct ploop_pushbackup_desc *ploop_pb_alloc(struct ploop_device *plo)
spin_lock_init(&pbd->ppb_lock);
init_completion(&pbd->ppb_comp);
- pbd->pending_set.tree = RB_ROOT;
- pbd->reported_set.tree = RB_ROOT;
+ ploop_pbs_init(&pbd->pending_set, pbd, "pending");
+ ploop_pbs_init(&pbd->reported_set, pbd, "reported");
pbd->plo = plo;
return pbd;
@@ -390,6 +414,8 @@ static void ploop_pb_add_req_to_tree(struct ploop_request *preq,
p = &(*p)->rb_right;
}
+ list_add_tail(&preq->list, &pbs->list);
+
rb_link_node(&preq->reloc_link, parent, p);
rb_insert_color(&preq->reloc_link, tree);
}
@@ -410,6 +436,7 @@ static void remove_req_from_pbs(struct pb_set *pbs,
struct ploop_request *preq)
{
rb_erase(&preq->reloc_link, &pbs->tree);
+ list_del_init(&preq->list);
}
@@ -547,6 +574,9 @@ unsigned long ploop_pb_stop(struct ploop_pushbackup_desc *pbd, bool do_merge)
if (pbd == NULL)
return 0;
+ ploop_pbs_fini(&pbd->pending_set);
+ ploop_pbs_fini(&pbd->reported_set);
+
merge_status = ploop_pb_cbt_map_release(pbd, do_merge);
spin_lock(&pbd->ppb_lock);
@@ -820,3 +850,7 @@ int ploop_pb_destroy(struct ploop_device *plo, __u32 *status)
return 0;
}
+
+static void ploop_pb_timeout_func(unsigned long data)
+{
+}
More information about the Devel
mailing list