Skip to content

Commit 2da8ca8

Browse files
committed
cgroup: replace cftype->read_seq_string() with cftype->seq_show()
In preparation of conversion to kernfs, cgroup file handling is updated so that it can be easily mapped to kernfs. This patch replaces cftype->read_seq_string() with cftype->seq_show() which is not limited to single_open() operation and will map directcly to kernfs seq_file interface. The conversions are mechanical. As ->seq_show() doesn't have @css and @cft, the functions which make use of them are converted to use seq_css() and seq_cft() respectively. In several occassions, e.f. if it has seq_string in its name, the function name is updated to fit the new method better. This patch does not introduce any behavior changes. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Aristeu Rozanski <arozansk@redhat.com> Acked-by: Vivek Goyal <vgoyal@redhat.com> Acked-by: Michal Hocko <mhocko@suse.cz> Acked-by: Daniel Wagner <daniel.wagner@bmw-carit.de> Acked-by: Li Zefan <lizefan@huawei.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: Ingo Molnar <mingo@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Balbir Singh <bsingharora@gmail.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Neil Horman <nhorman@tuxdriver.com>
1 parent 7da1127 commit 2da8ca8

11 files changed

Lines changed: 128 additions & 164 deletions

File tree

‎block/blk-throttle.c‎

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,13 +1303,10 @@ static u64 tg_prfill_cpu_rwstat(struct seq_file *sf,
13031303
return __blkg_prfill_rwstat(sf, pd, &rwstat);
13041304
}
13051305

1306-
static int tg_print_cpu_rwstat(struct cgroup_subsys_state *css,
1307-
struct cftype *cft, struct seq_file *sf)
1306+
static int tg_print_cpu_rwstat(struct seq_file *sf, void *v)
13081307
{
1309-
struct blkcg *blkcg = css_to_blkcg(css);
1310-
1311-
blkcg_print_blkgs(sf, blkcg, tg_prfill_cpu_rwstat, &blkcg_policy_throtl,
1312-
cft->private, true);
1308+
blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), tg_prfill_cpu_rwstat,
1309+
&blkcg_policy_throtl, seq_cft(sf)->private, true);
13131310
return 0;
13141311
}
13151312

@@ -1335,19 +1332,17 @@ static u64 tg_prfill_conf_uint(struct seq_file *sf, struct blkg_policy_data *pd,
13351332
return __blkg_prfill_u64(sf, pd, v);
13361333
}
13371334

1338-
static int tg_print_conf_u64(struct cgroup_subsys_state *css,
1339-
struct cftype *cft, struct seq_file *sf)
1335+
static int tg_print_conf_u64(struct seq_file *sf, void *v)
13401336
{
1341-
blkcg_print_blkgs(sf, css_to_blkcg(css), tg_prfill_conf_u64,
1342-
&blkcg_policy_throtl, cft->private, false);
1337+
blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), tg_prfill_conf_u64,
1338+
&blkcg_policy_throtl, seq_cft(sf)->private, false);
13431339
return 0;
13441340
}
13451341

1346-
static int tg_print_conf_uint(struct cgroup_subsys_state *css,
1347-
struct cftype *cft, struct seq_file *sf)
1342+
static int tg_print_conf_uint(struct seq_file *sf, void *v)
13481343
{
1349-
blkcg_print_blkgs(sf, css_to_blkcg(css), tg_prfill_conf_uint,
1350-
&blkcg_policy_throtl, cft->private, false);
1344+
blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), tg_prfill_conf_uint,
1345+
&blkcg_policy_throtl, seq_cft(sf)->private, false);
13511346
return 0;
13521347
}
13531348

@@ -1428,40 +1423,40 @@ static struct cftype throtl_files[] = {
14281423
{
14291424
.name = "throttle.read_bps_device",
14301425
.private = offsetof(struct throtl_grp, bps[READ]),
1431-
.read_seq_string = tg_print_conf_u64,
1426+
.seq_show = tg_print_conf_u64,
14321427
.write_string = tg_set_conf_u64,
14331428
.max_write_len = 256,
14341429
},
14351430
{
14361431
.name = "throttle.write_bps_device",
14371432
.private = offsetof(struct throtl_grp, bps[WRITE]),
1438-
.read_seq_string = tg_print_conf_u64,
1433+
.seq_show = tg_print_conf_u64,
14391434
.write_string = tg_set_conf_u64,
14401435
.max_write_len = 256,
14411436
},
14421437
{
14431438
.name = "throttle.read_iops_device",
14441439
.private = offsetof(struct throtl_grp, iops[READ]),
1445-
.read_seq_string = tg_print_conf_uint,
1440+
.seq_show = tg_print_conf_uint,
14461441
.write_string = tg_set_conf_uint,
14471442
.max_write_len = 256,
14481443
},
14491444
{
14501445
.name = "throttle.write_iops_device",
14511446
.private = offsetof(struct throtl_grp, iops[WRITE]),
1452-
.read_seq_string = tg_print_conf_uint,
1447+
.seq_show = tg_print_conf_uint,
14531448
.write_string = tg_set_conf_uint,
14541449
.max_write_len = 256,
14551450
},
14561451
{
14571452
.name = "throttle.io_service_bytes",
14581453
.private = offsetof(struct tg_stats_cpu, service_bytes),
1459-
.read_seq_string = tg_print_cpu_rwstat,
1454+
.seq_show = tg_print_cpu_rwstat,
14601455
},
14611456
{
14621457
.name = "throttle.io_serviced",
14631458
.private = offsetof(struct tg_stats_cpu, serviced),
1464-
.read_seq_string = tg_print_cpu_rwstat,
1459+
.seq_show = tg_print_cpu_rwstat,
14651460
},
14661461
{ } /* terminate */
14671462
};

0 commit comments

Comments
 (0)