Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

blk-cgroup: Simplify policy files registration

Use one set of files when there is no difference between default and
legacy files, similar to regular subsys files registration. No
functional change.

Signed-off-by: Michal Koutný <mkoutny@suse.com>
Acked-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Michal Koutný and committed by
Tejun Heo
4a893bdc 76f9409f

+14 -19
+5 -2
block/blk-cgroup.c
··· 1768 1768 mutex_unlock(&blkcg_pol_mutex); 1769 1769 1770 1770 /* everything is in place, add intf files for the new policy */ 1771 - if (pol->dfl_cftypes) 1771 + if (pol->dfl_cftypes == pol->legacy_cftypes) { 1772 + WARN_ON(cgroup_add_cftypes(&io_cgrp_subsys, 1773 + pol->dfl_cftypes)); 1774 + } else { 1772 1775 WARN_ON(cgroup_add_dfl_cftypes(&io_cgrp_subsys, 1773 1776 pol->dfl_cftypes)); 1774 - if (pol->legacy_cftypes) 1775 1777 WARN_ON(cgroup_add_legacy_cftypes(&io_cgrp_subsys, 1776 1778 pol->legacy_cftypes)); 1779 + } 1777 1780 mutex_unlock(&blkcg_pol_register_mutex); 1778 1781 return 0; 1779 1782
+7 -16
block/blk-ioprio.c
··· 113 113 kfree(blkcg); 114 114 } 115 115 116 - #define IOPRIO_ATTRS \ 117 - { \ 118 - .name = "prio.class", \ 119 - .seq_show = ioprio_show_prio_policy, \ 120 - .write = ioprio_set_prio_policy, \ 121 - }, \ 122 - { } /* sentinel */ 123 - 124 - /* cgroup v2 attributes */ 125 116 static struct cftype ioprio_files[] = { 126 - IOPRIO_ATTRS 127 - }; 128 - 129 - /* cgroup v1 attributes */ 130 - static struct cftype ioprio_legacy_files[] = { 131 - IOPRIO_ATTRS 117 + { 118 + .name = "prio.class", 119 + .seq_show = ioprio_show_prio_policy, 120 + .write = ioprio_set_prio_policy, 121 + }, 122 + { } /* sentinel */ 132 123 }; 133 124 134 125 static struct blkcg_policy ioprio_policy = { 135 126 .dfl_cftypes = ioprio_files, 136 - .legacy_cftypes = ioprio_legacy_files, 127 + .legacy_cftypes = ioprio_files, 137 128 138 129 .cpd_alloc_fn = ioprio_alloc_cpd, 139 130 .cpd_free_fn = ioprio_free_cpd,
+1
include/linux/cgroup.h
··· 113 113 114 114 int cgroup_add_dfl_cftypes(struct cgroup_subsys *ss, struct cftype *cfts); 115 115 int cgroup_add_legacy_cftypes(struct cgroup_subsys *ss, struct cftype *cfts); 116 + int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts); 116 117 int cgroup_rm_cftypes(struct cftype *cfts); 117 118 void cgroup_file_notify(struct cgroup_file *cfile); 118 119 void cgroup_file_show(struct cgroup_file *cfile, bool show);
+1 -1
kernel/cgroup/cgroup.c
··· 4451 4451 * function currently returns 0 as long as @cfts registration is successful 4452 4452 * even if some file creation attempts on existing cgroups fail. 4453 4453 */ 4454 - static int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts) 4454 + int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts) 4455 4455 { 4456 4456 int ret; 4457 4457