mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-19 23:02:31 +00:00
blk-cgroup: remove blkg_lookup_check
The combinations of an error check with an ERR_PTR return and a lookup with a NULL return leads to ugly handling of the return values in the callers. Just open coding the check and the lookup is much simpler. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Andreas Herrmann <aherrmann@suse.de> Acked-by: Tejun Heo <tj@kernel.org> Link: https://lore.kernel.org/r/20220921180501.1539876-6-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
4a69f325aa
commit
f753526e32
@ -602,25 +602,6 @@ u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, u64 v)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(__blkg_prfill_u64);
|
EXPORT_SYMBOL_GPL(__blkg_prfill_u64);
|
||||||
|
|
||||||
/* Performs queue bypass and policy enabled checks then looks up blkg. */
|
|
||||||
static struct blkcg_gq *blkg_lookup_check(struct blkcg *blkcg,
|
|
||||||
const struct blkcg_policy *pol,
|
|
||||||
struct request_queue *q)
|
|
||||||
{
|
|
||||||
struct blkcg_gq *blkg;
|
|
||||||
|
|
||||||
WARN_ON_ONCE(!rcu_read_lock_held());
|
|
||||||
lockdep_assert_held(&q->queue_lock);
|
|
||||||
|
|
||||||
if (!blkcg_policy_enabled(q, pol))
|
|
||||||
return ERR_PTR(-EOPNOTSUPP);
|
|
||||||
|
|
||||||
blkg = blkg_lookup(blkcg, q);
|
|
||||||
if (blkg)
|
|
||||||
blkg_update_hint(blkcg, blkg);
|
|
||||||
return blkg;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* blkcg_conf_open_bdev - parse and open bdev for per-blkg config update
|
* blkcg_conf_open_bdev - parse and open bdev for per-blkg config update
|
||||||
* @inputp: input string pointer
|
* @inputp: input string pointer
|
||||||
@ -697,14 +678,16 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
|
|||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
spin_lock_irq(&q->queue_lock);
|
spin_lock_irq(&q->queue_lock);
|
||||||
|
|
||||||
blkg = blkg_lookup_check(blkcg, pol, q);
|
if (!blkcg_policy_enabled(q, pol)) {
|
||||||
if (IS_ERR(blkg)) {
|
ret = -EOPNOTSUPP;
|
||||||
ret = PTR_ERR(blkg);
|
|
||||||
goto fail_unlock;
|
goto fail_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blkg)
|
blkg = blkg_lookup(blkcg, q);
|
||||||
|
if (blkg) {
|
||||||
|
blkg_update_hint(blkcg, blkg);
|
||||||
goto success;
|
goto success;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create blkgs walking down from blkcg_root to @blkcg, so that all
|
* Create blkgs walking down from blkcg_root to @blkcg, so that all
|
||||||
@ -740,14 +723,15 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
|
|||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
spin_lock_irq(&q->queue_lock);
|
spin_lock_irq(&q->queue_lock);
|
||||||
|
|
||||||
blkg = blkg_lookup_check(pos, pol, q);
|
if (!blkcg_policy_enabled(q, pol)) {
|
||||||
if (IS_ERR(blkg)) {
|
|
||||||
ret = PTR_ERR(blkg);
|
|
||||||
blkg_free(new_blkg);
|
blkg_free(new_blkg);
|
||||||
|
ret = -EOPNOTSUPP;
|
||||||
goto fail_preloaded;
|
goto fail_preloaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blkg = blkg_lookup(pos, q);
|
||||||
if (blkg) {
|
if (blkg) {
|
||||||
|
blkg_update_hint(pos, blkg);
|
||||||
blkg_free(new_blkg);
|
blkg_free(new_blkg);
|
||||||
} else {
|
} else {
|
||||||
blkg = blkg_create(pos, q, new_blkg);
|
blkg = blkg_create(pos, q, new_blkg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user