From: Tejun Heo <tj@kernel.org>
To: axboe@kernel.dk, vgoyal@redhat.com
Cc: ctalbott@google.com, rni@google.com, linux-kernel@vger.kernel.org
Subject: [PATCH 13.5] blkcg: make blkg_lookup_create() return ERR_PTR value on failure
Date: Tue, 24 Jan 2012 11:29:56 -0800 [thread overview]
Message-ID: <20120124192956.GB421@google.com> (raw)
In-Reply-To: <1327360193-24679-1-git-send-email-tj@kernel.org>
Update blkg_lookup_create() so that it indicates the cause of failure
with ERR_PTR value. This is primarily to allow the caller to
determine whether the failure is transitional due to queue being
bypassed temporarily.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
---
block/blk-cgroup.c | 15 +++++++++------
block/blk-throttle.c | 2 +-
block/cfq-iosched.c | 5 ++++-
3 files changed, 14 insertions(+), 8 deletions(-)
Index: work/block/blk-cgroup.c
===================================================================
--- work.orig/block/blk-cgroup.c
+++ work/block/blk-cgroup.c
@@ -471,8 +471,7 @@ struct blkio_group *blkg_lookup_create(s
__releases(q->queue_lock) __acquires(q->queue_lock)
{
struct blkio_policy_type *pol = blkio_policy[plid];
- struct blkio_group *blkg = NULL;
- struct blkio_group *new_blkg = NULL;
+ struct blkio_group *blkg, *new_blkg = NULL;
WARN_ON_ONCE(!rcu_read_lock_held());
lockdep_assert_held(q->queue_lock);
@@ -484,14 +483,14 @@ struct blkio_group *blkg_lookup_create(s
* fail on a bypassing queue.
*/
if (unlikely(blk_queue_bypass(q)))
- return NULL;
+ return ERR_PTR(blk_queue_dead(q) ? -EINVAL : -EBUSY);
blkg = blkg_lookup(blkcg, q, plid);
if (blkg)
return blkg;
if (!css_tryget(&blkcg->css))
- return NULL;
+ return ERR_PTR(-EINVAL);
/*
* Allocate and initialize.
@@ -522,8 +521,10 @@ struct blkio_group *blkg_lookup_create(s
css_put(&blkcg->css);
/* did bypass get turned on inbetween? */
- if (unlikely(blk_queue_bypass(q)))
+ if (unlikely(blk_queue_bypass(q))) {
+ blkg = ERR_PTR(blk_queue_dead(q) ? -EINVAL : -EBUSY);
goto out;
+ }
/* did someone beat us to it? */
blkg = blkg_lookup(blkcg, q, plid);
@@ -531,8 +532,10 @@ struct blkio_group *blkg_lookup_create(s
goto out;
/* did alloc fail? */
- if (unlikely(!new_blkg || !new_blkg->stats_cpu))
+ if (unlikely(!new_blkg || !new_blkg->stats_cpu)) {
+ blkg = ERR_PTR(-ENOMEM);
goto out;
+ }
/* insert */
spin_lock(&blkcg->lock);
Index: work/block/blk-throttle.c
===================================================================
--- work.orig/block/blk-throttle.c
+++ work/block/blk-throttle.c
@@ -289,7 +289,7 @@ static struct throtl_grp *throtl_lookup_
blkg = blkg_lookup_create(blkcg, q, BLKIO_POLICY_THROTL);
/* if %NULL and @q is alive, fall back to root_tg */
- if (blkg)
+ if (!IS_ERR(blkg))
tg = tg_of_blkg(blkg);
else if (!blk_queue_dead(q))
tg = td->root_tg;
Index: work/block/cfq-iosched.c
===================================================================
--- work.orig/block/cfq-iosched.c
+++ work/block/cfq-iosched.c
@@ -1106,7 +1106,10 @@ static struct cfq_group *cfq_lookup_crea
struct blkio_group *blkg;
blkg = blkg_lookup_create(blkcg, cfqd->queue, BLKIO_POLICY_PROP);
- return cfqg_of_blkg(blkg);
+ if (!IS_ERR(blkg))
+ return cfqg_of_blkg(blkg);
+ else
+ return NULL;
}
static inline struct cfq_group *cfq_ref_get_cfqg(struct cfq_group *cfqg)
prev parent reply other threads:[~2012-01-24 19:30 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-23 23:09 [PATCHSET] blkcg: kill policy node and blkg->dev, take#3 Tejun Heo
2012-01-23 23:09 ` [PATCH 01/16] blkcg: make CONFIG_BLK_CGROUP bool Tejun Heo
2012-01-23 23:09 ` [PATCH 02/16] cfq: don't register propio policy if !CONFIG_CFQ_GROUP_IOSCHED Tejun Heo
2012-01-23 23:09 ` [PATCH 03/16] elevator: clear auxiliary data earlier during elevator switch Tejun Heo
2012-01-23 23:09 ` [PATCH 04/16] elevator: make elevator_init_fn() return 0/-errno Tejun Heo
2012-01-23 23:09 ` [PATCH 05/16] block: implement blk_queue_bypass_start/end() Tejun Heo
2012-01-23 23:09 ` [PATCH 06/16] block: extend queue bypassing to cover blkcg policies Tejun Heo
2012-01-23 23:09 ` [PATCH 07/16] blkcg: shoot down blkio_groups on elevator switch Tejun Heo
2012-01-23 23:09 ` [PATCH 08/16] blkcg: move rcu_read_lock() outside of blkio_group get functions Tejun Heo
2012-01-23 23:09 ` [PATCH 09/16] blkcg: update blkg get functions take blkio_cgroup as parameter Tejun Heo
2012-01-23 23:09 ` [PATCH 10/16] blkcg: use q and plid instead of opaque void * for blkio_group association Tejun Heo
2012-01-23 23:09 ` [PATCH 11/16] blkcg: add blkio_policy[] array and allow one policy per policy ID Tejun Heo
2012-01-23 23:09 ` [PATCH 12/16] blkcg: use the usual get blkg path for root blkio_group Tejun Heo
2012-01-23 23:09 ` [PATCH 13/16] blkcg: factor out blkio_group creation Tejun Heo
2012-01-24 16:23 ` [PATCH UPDATED " Tejun Heo
2012-01-24 16:25 ` Tejun Heo
2012-01-23 23:09 ` [PATCH 14/16] blkcg: don't allow or retain configuration of missing devices Tejun Heo
2012-01-24 15:42 ` Vivek Goyal
2012-01-24 15:53 ` Tejun Heo
2012-01-24 16:32 ` Vivek Goyal
2012-01-24 16:34 ` Tejun Heo
2012-01-24 19:30 ` [PATCH UPDATED " Tejun Heo
2012-01-24 19:46 ` Vivek Goyal
2012-01-23 23:09 ` [PATCH 15/16] blkcg: kill blkio_policy_node Tejun Heo
2012-01-23 23:09 ` [PATCH 16/16] blkcg: kill the mind-bending blkg->dev Tejun Heo
2012-01-24 19:29 ` Tejun Heo [this message]
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=20120124192956.GB421@google.com \
--to=tj@kernel.org \
--cc=axboe@kernel.dk \
--cc=ctalbott@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rni@google.com \
--cc=vgoyal@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).