You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
cgroup: implement cftype->write()
During the recent conversion to kernfs, cftype's seq_file operations are updated so that they are directly mapped to kernfs operations and thus can fully access the associated kernfs and cgroup contexts; however, write path hasn't seen similar updates and none of the existing write operations has access to, for example, the associated kernfs_open_file. Let's introduce a new operation cftype->write() which maps directly to the kernfs write operation and has access to all the arguments and contexts. This will replace ->write_string() and ->trigger() and ease manipulation of kernfs active protection from cgroup file operations. Two accessors - of_cft() and of_css() - are introduced to enable accessing the associated cgroup context from cftype->write() which only takes kernfs_open_file for the context information. The accessors for seq_file operations - seq_cft() and seq_css() - are rewritten to wrap the of_ accessors. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
This commit is contained in:
+23
-4
@@ -515,6 +515,15 @@ struct cftype {
|
||||
*/
|
||||
int (*trigger)(struct cgroup_subsys_state *css, unsigned int event);
|
||||
|
||||
/*
|
||||
* write() is the generic write callback which maps directly to
|
||||
* kernfs write operation and overrides all other operations.
|
||||
* Maximum write size is determined by ->max_write_len. Use
|
||||
* of_css/cft() to access the associated css and cft.
|
||||
*/
|
||||
ssize_t (*write)(struct kernfs_open_file *of,
|
||||
char *buf, size_t nbytes, loff_t off);
|
||||
|
||||
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
||||
struct lock_class_key lockdep_key;
|
||||
#endif
|
||||
@@ -552,14 +561,24 @@ static inline ino_t cgroup_ino(struct cgroup *cgrp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline struct cftype *seq_cft(struct seq_file *seq)
|
||||
/* cft/css accessors for cftype->write() operation */
|
||||
static inline struct cftype *of_cft(struct kernfs_open_file *of)
|
||||
{
|
||||
struct kernfs_open_file *of = seq->private;
|
||||
|
||||
return of->kn->priv;
|
||||
}
|
||||
|
||||
struct cgroup_subsys_state *seq_css(struct seq_file *seq);
|
||||
struct cgroup_subsys_state *of_css(struct kernfs_open_file *of);
|
||||
|
||||
/* cft/css accessors for cftype->seq_*() operations */
|
||||
static inline struct cftype *seq_cft(struct seq_file *seq)
|
||||
{
|
||||
return of_cft(seq->private);
|
||||
}
|
||||
|
||||
static inline struct cgroup_subsys_state *seq_css(struct seq_file *seq)
|
||||
{
|
||||
return of_css(seq->private);
|
||||
}
|
||||
|
||||
/*
|
||||
* Name / path handling functions. All are thin wrappers around the kernfs
|
||||
|
||||
Reference in New Issue
Block a user