All of lore.kernel.org
 help / color / mirror / Atom feed
From: weiping zhang <zhangweiping@didichuxing.com>
To: <axboe@kernel.dk>
Cc: <linux-block@vger.kernel.org>
Subject: [PATCH] blkcg: add a cleanup when active policy fail
Date: Mon, 21 Aug 2017 23:12:43 +0800	[thread overview]
Message-ID: <20170821151238.GA28794@localhost.didichuxing.com> (raw)

if alloc memory fail, all cpds which were allocated before should be cleaned up.

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
---
 block/blk-cgroup.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 0480892..7e21c4b 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1336,6 +1336,17 @@ int blkcg_activate_policy(struct request_queue *q,
 
 	spin_unlock_irq(q->queue_lock);
 out_bypass_end:
+	if (ret) {
+		spin_lock_irq(q->queue_lock);
+		list_for_each_entry(blkg, &q->blkg_list, q_node) {
+			if (blkg->pd[pol->plid]) {
+				if (pol->pd_free_fn)
+					pol->pd_free_fn(blkg->pd[pol->plid]);
+				blkg->pd[pol->plid] = NULL;
+			}
+		}
+		spin_unlock_irq(q->queue_lock);
+	}
 	if (q->mq_ops)
 		blk_mq_unfreeze_queue(q);
 	else
-- 
2.9.4

                 reply	other threads:[~2017-08-21 15:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170821151238.GA28794@localhost.didichuxing.com \
    --to=zhangweiping@didichuxing.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.