Commit a37ef2e3 authored by Jarek Poplawski's avatar Jarek Poplawski Committed by David S. Miller

[NET_SCHED] sch_cbq: deactivating when grafting, purging etc.

- deactivating of active classes when q.qlen drops to zero
  (cbq_drop)

- a redundant instruction removed from cbq_deactivate_class

PS: probably htb_deactivate in htb_delete and
cbq_deactivate_class in cbq_delete are also
redundant now.
Signed-off-by: default avatarJarek Poplawski <jarkao2@o2.pl>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 93366c53
...@@ -371,8 +371,6 @@ static void cbq_deactivate_class(struct cbq_class *this) ...@@ -371,8 +371,6 @@ static void cbq_deactivate_class(struct cbq_class *this)
return; return;
} }
} }
cl = cl_prev->next_alive;
return; return;
} }
} while ((cl_prev = cl) != q->active[prio]); } while ((cl_prev = cl) != q->active[prio]);
...@@ -1258,6 +1256,8 @@ static unsigned int cbq_drop(struct Qdisc* sch) ...@@ -1258,6 +1256,8 @@ static unsigned int cbq_drop(struct Qdisc* sch)
do { do {
if (cl->q->ops->drop && (len = cl->q->ops->drop(cl->q))) { if (cl->q->ops->drop && (len = cl->q->ops->drop(cl->q))) {
sch->q.qlen--; sch->q.qlen--;
if (!cl->q->q.qlen)
cbq_deactivate_class(cl);
return len; return len;
} }
} while ((cl = cl->next_alive) != cl_head); } while ((cl = cl->next_alive) != cl_head);
...@@ -1685,8 +1685,7 @@ static int cbq_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, ...@@ -1685,8 +1685,7 @@ static int cbq_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
#endif #endif
} }
sch_tree_lock(sch); sch_tree_lock(sch);
*old = cl->q; *old = xchg(&cl->q, new);
cl->q = new;
qdisc_tree_decrease_qlen(*old, (*old)->q.qlen); qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
qdisc_reset(*old); qdisc_reset(*old);
sch_tree_unlock(sch); sch_tree_unlock(sch);
...@@ -1704,6 +1703,14 @@ cbq_leaf(struct Qdisc *sch, unsigned long arg) ...@@ -1704,6 +1703,14 @@ cbq_leaf(struct Qdisc *sch, unsigned long arg)
return cl ? cl->q : NULL; return cl ? cl->q : NULL;
} }
static void cbq_qlen_notify(struct Qdisc *sch, unsigned long arg)
{
struct cbq_class *cl = (struct cbq_class *)arg;
if (cl->q->q.qlen == 0)
cbq_deactivate_class(cl);
}
static unsigned long cbq_get(struct Qdisc *sch, u32 classid) static unsigned long cbq_get(struct Qdisc *sch, u32 classid)
{ {
struct cbq_sched_data *q = qdisc_priv(sch); struct cbq_sched_data *q = qdisc_priv(sch);
...@@ -1988,12 +1995,17 @@ static int cbq_delete(struct Qdisc *sch, unsigned long arg) ...@@ -1988,12 +1995,17 @@ static int cbq_delete(struct Qdisc *sch, unsigned long arg)
{ {
struct cbq_sched_data *q = qdisc_priv(sch); struct cbq_sched_data *q = qdisc_priv(sch);
struct cbq_class *cl = (struct cbq_class*)arg; struct cbq_class *cl = (struct cbq_class*)arg;
unsigned int qlen;
if (cl->filters || cl->children || cl == &q->link) if (cl->filters || cl->children || cl == &q->link)
return -EBUSY; return -EBUSY;
sch_tree_lock(sch); sch_tree_lock(sch);
qlen = cl->q->q.qlen;
qdisc_reset(cl->q);
qdisc_tree_decrease_qlen(cl->q, qlen);
if (cl->next_alive) if (cl->next_alive)
cbq_deactivate_class(cl); cbq_deactivate_class(cl);
...@@ -2084,6 +2096,7 @@ static void cbq_walk(struct Qdisc *sch, struct qdisc_walker *arg) ...@@ -2084,6 +2096,7 @@ static void cbq_walk(struct Qdisc *sch, struct qdisc_walker *arg)
static struct Qdisc_class_ops cbq_class_ops = { static struct Qdisc_class_ops cbq_class_ops = {
.graft = cbq_graft, .graft = cbq_graft,
.leaf = cbq_leaf, .leaf = cbq_leaf,
.qlen_notify = cbq_qlen_notify,
.get = cbq_get, .get = cbq_get,
.put = cbq_put, .put = cbq_put,
.change = cbq_change_class, .change = cbq_change_class,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment