[Devel] [PATCH RHEL7 COMMIT] ploop: push_backup: optimize ploop_pb_get_pending()
Konstantin Khorenko
khorenko at virtuozzo.com
Fri May 20 05:48:27 PDT 2016
The commit is pushed to "branch-rh7-3.10.0-327.18.2.vz7.14.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.18.2.vz7.14.5
------>
commit 6130b647da6a3f732194155a34a0a77632614f3d
Author: Maxim Patlasov <mpatlasov at virtuozzo.com>
Date: Fri May 20 16:48:27 2016 +0400
ploop: push_backup: optimize ploop_pb_get_pending()
Pack as many adjacent preq-s to each extent as possible.
https://jira.sw.ru/browse/PSBM-45000
Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
---
drivers/block/ploop/push_backup.c | 46 +++++++++++++++++++++++++++++++++------
1 file changed, 39 insertions(+), 7 deletions(-)
diff --git a/drivers/block/ploop/push_backup.c b/drivers/block/ploop/push_backup.c
index 46ea2da..ba64468 100644
--- a/drivers/block/ploop/push_backup.c
+++ b/drivers/block/ploop/push_backup.c
@@ -351,7 +351,8 @@ static struct ploop_request *ploop_pb_get_req_from_tree(struct rb_root *tree,
}
static struct ploop_request *
-ploop_pb_get_first_req_from_tree(struct rb_root *tree)
+ploop_pb_get_first_req_from_tree(struct rb_root *tree,
+ struct ploop_request **npreq)
{
static struct ploop_request *p;
struct rb_node *n = rb_first(tree);
@@ -359,6 +360,15 @@ ploop_pb_get_first_req_from_tree(struct rb_root *tree)
if (!n)
return NULL;
+ if (npreq) {
+ struct rb_node *next = rb_next(n);
+ if (next)
+ *npreq = rb_entry(next, struct ploop_request,
+ reloc_link);
+ else
+ *npreq = NULL;
+ }
+
p = rb_entry(n, struct ploop_request, reloc_link);
rb_erase(&p->reloc_link, tree);
return p;
@@ -367,13 +377,20 @@ ploop_pb_get_first_req_from_tree(struct rb_root *tree)
static struct ploop_request *
ploop_pb_get_first_req_from_pending(struct ploop_pushbackup_desc *pbd)
{
- return ploop_pb_get_first_req_from_tree(&pbd->pending_tree);
+ return ploop_pb_get_first_req_from_tree(&pbd->pending_tree, NULL);
+}
+
+static struct ploop_request *
+ploop_pb_get_first_reqs_from_pending(struct ploop_pushbackup_desc *pbd,
+ struct ploop_request **npreq)
+{
+ return ploop_pb_get_first_req_from_tree(&pbd->pending_tree, npreq);
}
static struct ploop_request *
ploop_pb_get_first_req_from_reported(struct ploop_pushbackup_desc *pbd)
{
- return ploop_pb_get_first_req_from_tree(&pbd->reported_tree);
+ return ploop_pb_get_first_req_from_tree(&pbd->reported_tree, NULL);
}
static struct ploop_request *
@@ -463,13 +480,12 @@ int ploop_pb_get_pending(struct ploop_pushbackup_desc *pbd,
cluster_t *clu_p, cluster_t *len_p, unsigned n_done)
{
bool blocking = !n_done;
- struct ploop_request *preq;
+ struct ploop_request *preq, *npreq;
int err = 0;
spin_lock(&pbd->ppb_lock);
- /* OPTIMIZE ME LATER: rb_first() once, then rb_next() */
- preq = ploop_pb_get_first_req_from_pending(pbd);
+ preq = ploop_pb_get_first_reqs_from_pending(pbd, &npreq);
if (!preq) {
struct ploop_device *plo = pbd->plo;
@@ -498,7 +514,7 @@ int ploop_pb_get_pending(struct ploop_pushbackup_desc *pbd,
pbd->ppb_waiting = false;
init_completion(&pbd->ppb_comp);
- preq = ploop_pb_get_first_req_from_pending(pbd);
+ preq = ploop_pb_get_first_reqs_from_pending(pbd, &npreq);
if (!preq) {
if (!test_bit(PLOOP_S_PUSH_BACKUP, &plo->state))
err = -EINTR;
@@ -515,6 +531,22 @@ int ploop_pb_get_pending(struct ploop_pushbackup_desc *pbd,
*clu_p = preq->req_cluster;
*len_p = 1;
+ while (npreq && npreq->req_cluster == *clu_p + *len_p) {
+ struct rb_node *next = rb_next(&npreq->reloc_link);
+
+ preq = npreq;
+ if (next)
+ npreq = rb_entry(next, struct ploop_request,
+ reloc_link);
+ else
+ npreq = NULL;
+
+ rb_erase(&preq->reloc_link, &pbd->pending_tree);
+ ploop_pb_add_req_to_reported(pbd, preq);
+
+ (*len_p)++;
+ }
+
get_pending_unlock:
spin_unlock(&pbd->ppb_lock);
return err;
More information about the Devel
mailing list