aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/cgroup.h25
-rw-r--r--kernel/cgroup.c26
2 files changed, 4 insertions, 47 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 50d8cc37498b..53e11da6e357 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -387,16 +387,6 @@ struct css_set {
387}; 387};
388 388
389/* 389/*
390 * cgroup_map_cb is an abstract callback API for reporting map-valued
391 * control files
392 */
393
394struct cgroup_map_cb {
395 int (*fill)(struct cgroup_map_cb *cb, const char *key, u64 value);
396 void *state;
397};
398
399/*
400 * struct cftype: handler definitions for cgroup control files 390 * struct cftype: handler definitions for cgroup control files
401 * 391 *
402 * When reading/writing to a file: 392 * When reading/writing to a file:
@@ -444,9 +434,6 @@ struct cftype {
444 struct cgroup_subsys *ss; 434 struct cgroup_subsys *ss;
445 435
446 int (*open)(struct inode *inode, struct file *file); 436 int (*open)(struct inode *inode, struct file *file);
447 ssize_t (*read)(struct cgroup_subsys_state *css, struct cftype *cft,
448 struct file *file,
449 char __user *buf, size_t nbytes, loff_t *ppos);
450 /* 437 /*
451 * read_u64() is a shortcut for the common case of returning a 438 * read_u64() is a shortcut for the common case of returning a
452 * single integer. Use it in place of read() 439 * single integer. Use it in place of read()
@@ -457,24 +444,12 @@ struct cftype {
457 */ 444 */
458 s64 (*read_s64)(struct cgroup_subsys_state *css, struct cftype *cft); 445 s64 (*read_s64)(struct cgroup_subsys_state *css, struct cftype *cft);
459 /* 446 /*
460 * read_map() is used for defining a map of key/value
461 * pairs. It should call cb->fill(cb, key, value) for each
462 * entry. The key/value pairs (and their ordering) should not
463 * change between reboots.
464 */
465 int (*read_map)(struct cgroup_subsys_state *css, struct cftype *cft,
466 struct cgroup_map_cb *cb);
467 /*
468 * read_seq_string() is used for outputting a simple sequence 447 * read_seq_string() is used for outputting a simple sequence
469 * using seqfile. 448 * using seqfile.
470 */ 449 */
471 int (*read_seq_string)(struct cgroup_subsys_state *css, 450 int (*read_seq_string)(struct cgroup_subsys_state *css,
472 struct cftype *cft, struct seq_file *m); 451 struct cftype *cft, struct seq_file *m);
473 452
474 ssize_t (*write)(struct cgroup_subsys_state *css, struct cftype *cft,
475 struct file *file,
476 const char __user *buf, size_t nbytes, loff_t *ppos);
477
478 /* 453 /*
479 * write_u64() is a shortcut for the common case of accepting 454 * write_u64() is a shortcut for the common case of accepting
480 * a single integer (as parsed by simple_strtoull) from 455 * a single integer (as parsed by simple_strtoull) from
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index f9f5fe3526ac..b132ff94fc6f 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2324,8 +2324,6 @@ static ssize_t cgroup_file_write(struct file *file, const char __user *buf,
2324 struct cftype *cft = __d_cft(file->f_dentry); 2324 struct cftype *cft = __d_cft(file->f_dentry);
2325 struct cgroup_subsys_state *css = cfe->css; 2325 struct cgroup_subsys_state *css = cfe->css;
2326 2326
2327 if (cft->write)
2328 return cft->write(css, cft, file, buf, nbytes, ppos);
2329 if (cft->write_u64 || cft->write_s64) 2327 if (cft->write_u64 || cft->write_s64)
2330 return cgroup_write_X64(css, cft, file, buf, nbytes, ppos); 2328 return cgroup_write_X64(css, cft, file, buf, nbytes, ppos);
2331 if (cft->write_string) 2329 if (cft->write_string)
@@ -2366,8 +2364,6 @@ static ssize_t cgroup_file_read(struct file *file, char __user *buf,
2366 struct cftype *cft = __d_cft(file->f_dentry); 2364 struct cftype *cft = __d_cft(file->f_dentry);
2367 struct cgroup_subsys_state *css = cfe->css; 2365 struct cgroup_subsys_state *css = cfe->css;
2368 2366
2369 if (cft->read)
2370 return cft->read(css, cft, file, buf, nbytes, ppos);
2371 if (cft->read_u64) 2367 if (cft->read_u64)
2372 return cgroup_read_u64(css, cft, file, buf, nbytes, ppos); 2368 return cgroup_read_u64(css, cft, file, buf, nbytes, ppos);
2373 if (cft->read_s64) 2369 if (cft->read_s64)
@@ -2380,25 +2376,12 @@ static ssize_t cgroup_file_read(struct file *file, char __user *buf,
2380 * supports string->u64 maps, but can be extended in future. 2376 * supports string->u64 maps, but can be extended in future.
2381 */ 2377 */
2382 2378
2383static int cgroup_map_add(struct cgroup_map_cb *cb, const char *key, u64 value)
2384{
2385 struct seq_file *sf = cb->state;
2386 return seq_printf(sf, "%s %llu\n", key, (unsigned long long)value);
2387}
2388
2389static int cgroup_seqfile_show(struct seq_file *m, void *arg) 2379static int cgroup_seqfile_show(struct seq_file *m, void *arg)
2390{ 2380{
2391 struct cfent *cfe = m->private; 2381 struct cfent *cfe = m->private;
2392 struct cftype *cft = cfe->type; 2382 struct cftype *cft = cfe->type;
2393 struct cgroup_subsys_state *css = cfe->css; 2383 struct cgroup_subsys_state *css = cfe->css;
2394 2384
2395 if (cft->read_map) {
2396 struct cgroup_map_cb cb = {
2397 .fill = cgroup_map_add,
2398 .state = m,
2399 };
2400 return cft->read_map(css, cft, &cb);
2401 }
2402 return cft->read_seq_string(css, cft, m); 2385 return cft->read_seq_string(css, cft, m);
2403} 2386}
2404 2387
@@ -2444,7 +2427,7 @@ static int cgroup_file_open(struct inode *inode, struct file *file)
2444 WARN_ON_ONCE(cfe->css && cfe->css != css); 2427 WARN_ON_ONCE(cfe->css && cfe->css != css);
2445 cfe->css = css; 2428 cfe->css = css;
2446 2429
2447 if (cft->read_map || cft->read_seq_string) { 2430 if (cft->read_seq_string) {
2448 file->f_op = &cgroup_seqfile_operations; 2431 file->f_op = &cgroup_seqfile_operations;
2449 err = single_open(file, cgroup_seqfile_show, cfe); 2432 err = single_open(file, cgroup_seqfile_show, cfe);
2450 } else if (cft->open) { 2433 } else if (cft->open) {
@@ -2658,12 +2641,11 @@ static umode_t cgroup_file_mode(const struct cftype *cft)
2658 if (cft->mode) 2641 if (cft->mode)
2659 return cft->mode; 2642 return cft->mode;
2660 2643
2661 if (cft->read || cft->read_u64 || cft->read_s64 || 2644 if (cft->read_u64 || cft->read_s64 || cft->read_seq_string)
2662 cft->read_map || cft->read_seq_string)
2663 mode |= S_IRUGO; 2645 mode |= S_IRUGO;
2664 2646
2665 if (cft->write || cft->write_u64 || cft->write_s64 || 2647 if (cft->write_u64 || cft->write_s64 || cft->write_string ||
2666 cft->write_string || cft->trigger) 2648 cft->trigger)
2667 mode |= S_IWUSR; 2649 mode |= S_IWUSR;
2668 2650
2669 return mode; 2651 return mode;