blkcg: separate blkcg_conf_get_disk() out of blkg_conf_prep()
Separate out blkcg_conf_get_disk() so that it can be used by blkcg policy interface file input parsers before the policy is actually enabled. This doesn't introduce any functional changes. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
86a5bba5c2
commit
015d254cb0
@ -753,6 +753,44 @@ static struct blkcg_gq *blkg_lookup_check(struct blkcg *blkcg,
|
|||||||
return __blkg_lookup(blkcg, q, true /* update_hint */);
|
return __blkg_lookup(blkcg, q, true /* update_hint */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* blkg_conf_prep - parse and prepare for per-blkg config update
|
||||||
|
* @inputp: input string pointer
|
||||||
|
*
|
||||||
|
* Parse the device node prefix part, MAJ:MIN, of per-blkg config update
|
||||||
|
* from @input and get and return the matching gendisk. *@inputp is
|
||||||
|
* updated to point past the device node prefix. Returns an ERR_PTR()
|
||||||
|
* value on error.
|
||||||
|
*
|
||||||
|
* Use this function iff blkg_conf_prep() can't be used for some reason.
|
||||||
|
*/
|
||||||
|
struct gendisk *blkcg_conf_get_disk(char **inputp)
|
||||||
|
{
|
||||||
|
char *input = *inputp;
|
||||||
|
unsigned int major, minor;
|
||||||
|
struct gendisk *disk;
|
||||||
|
int key_len, part;
|
||||||
|
|
||||||
|
if (sscanf(input, "%u:%u%n", &major, &minor, &key_len) != 2)
|
||||||
|
return ERR_PTR(-EINVAL);
|
||||||
|
|
||||||
|
input += key_len;
|
||||||
|
if (!isspace(*input))
|
||||||
|
return ERR_PTR(-EINVAL);
|
||||||
|
input = skip_spaces(input);
|
||||||
|
|
||||||
|
disk = get_gendisk(MKDEV(major, minor), &part);
|
||||||
|
if (!disk)
|
||||||
|
return ERR_PTR(-ENODEV);
|
||||||
|
if (part) {
|
||||||
|
put_disk_and_module(disk);
|
||||||
|
return ERR_PTR(-ENODEV);
|
||||||
|
}
|
||||||
|
|
||||||
|
*inputp = input;
|
||||||
|
return disk;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* blkg_conf_prep - parse and prepare for per-blkg config update
|
* blkg_conf_prep - parse and prepare for per-blkg config update
|
||||||
* @blkcg: target block cgroup
|
* @blkcg: target block cgroup
|
||||||
@ -772,25 +810,11 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
|
|||||||
struct gendisk *disk;
|
struct gendisk *disk;
|
||||||
struct request_queue *q;
|
struct request_queue *q;
|
||||||
struct blkcg_gq *blkg;
|
struct blkcg_gq *blkg;
|
||||||
unsigned int major, minor;
|
int ret;
|
||||||
int key_len, part, ret;
|
|
||||||
char *body;
|
|
||||||
|
|
||||||
if (sscanf(input, "%u:%u%n", &major, &minor, &key_len) != 2)
|
disk = blkcg_conf_get_disk(&input);
|
||||||
return -EINVAL;
|
if (IS_ERR(disk))
|
||||||
|
return PTR_ERR(disk);
|
||||||
body = input + key_len;
|
|
||||||
if (!isspace(*body))
|
|
||||||
return -EINVAL;
|
|
||||||
body = skip_spaces(body);
|
|
||||||
|
|
||||||
disk = get_gendisk(MKDEV(major, minor), &part);
|
|
||||||
if (!disk)
|
|
||||||
return -ENODEV;
|
|
||||||
if (part) {
|
|
||||||
ret = -ENODEV;
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
q = disk->queue;
|
q = disk->queue;
|
||||||
|
|
||||||
@ -856,7 +880,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
|
|||||||
success:
|
success:
|
||||||
ctx->disk = disk;
|
ctx->disk = disk;
|
||||||
ctx->blkg = blkg;
|
ctx->blkg = blkg;
|
||||||
ctx->body = body;
|
ctx->body = input;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail_unlock:
|
fail_unlock:
|
||||||
|
@ -234,6 +234,7 @@ struct blkg_conf_ctx {
|
|||||||
char *body;
|
char *body;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct gendisk *blkcg_conf_get_disk(char **inputp);
|
||||||
int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
|
int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
|
||||||
char *input, struct blkg_conf_ctx *ctx);
|
char *input, struct blkg_conf_ctx *ctx);
|
||||||
void blkg_conf_finish(struct blkg_conf_ctx *ctx);
|
void blkg_conf_finish(struct blkg_conf_ctx *ctx);
|
||||||
|
Loading…
Reference in New Issue
Block a user