aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/cgroup.h
diff options
context:
space:
mode:
authorAristeu Rozanski <aris@redhat.com>2012-08-23 16:53:30 -0400
committerTejun Heo <tj@kernel.org>2012-08-24 18:55:33 -0400
commit03b1cde6b22f625ae832b939bc7379ec1466aec5 (patch)
tree0aecdc872a6ab2a00a8026e1898d4f3492cca87b /include/linux/cgroup.h
parent13af07df9b7e49f1987cf36aa048dc6c49d0f93d (diff)
cgroup: add xattr support
This is one of the items in the plumber's wish list. For use cases: >> What would the use case be for this? > > Attaching meta information to services, in an easily discoverable > way. For example, in systemd we create one cgroup for each service, and > could then store data like the main pid of the specific service as an > xattr on the cgroup itself. That way we'd have almost all service state > in the cgroupfs, which would make it possible to terminate systemd and > later restart it without losing any state information. But there's more: > for example, some very peculiar services cannot be terminated on > shutdown (i.e. fakeraid DM stuff) and it would be really nice if the > services in question could just mark that on their cgroup, by setting an > xattr. On the more desktopy side of things there are other > possibilities: for example there are plans defining what an application > is along the lines of a cgroup (i.e. an app being a collection of > processes). With xattrs one could then attach an icon or human readable > program name on the cgroup. > > The key idea is that this would allow attaching runtime meta information > to cgroups and everything they model (services, apps, vms), that doesn't > need any complex userspace infrastructure, has good access control > (i.e. because the file system enforces that anyway, and there's the > "trusted." xattr namespace), notifications (inotify), and can easily be > shared among applications. > > Lennart v7: - no changes v6: - remove user xattr namespace, only allow trusted and security v5: - check for capabilities before setting/removing xattrs v4: - no changes v3: - instead of config option, use mount option to enable xattr support Original-patch-by: Li Zefan <lizefan@huawei.com> Cc: Li Zefan <lizefan@huawei.com> Cc: Tejun Heo <tj@kernel.org> Cc: Hugh Dickins <hughd@google.com> Cc: Hillf Danton <dhillf@gmail.com> Cc: Lennart Poettering <lpoetter@redhat.com> Signed-off-by: Li Zefan <lizefan@huawei.com> Signed-off-by: Aristeu Rozanski <aris@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'include/linux/cgroup.h')
-rw-r--r--include/linux/cgroup.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index c90eaa803440..145901f5ef99 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -17,6 +17,7 @@
17#include <linux/rwsem.h> 17#include <linux/rwsem.h>
18#include <linux/idr.h> 18#include <linux/idr.h>
19#include <linux/workqueue.h> 19#include <linux/workqueue.h>
20#include <linux/xattr.h>
20 21
21#ifdef CONFIG_CGROUPS 22#ifdef CONFIG_CGROUPS
22 23
@@ -216,6 +217,9 @@ struct cgroup {
216 /* List of events which userspace want to receive */ 217 /* List of events which userspace want to receive */
217 struct list_head event_list; 218 struct list_head event_list;
218 spinlock_t event_list_lock; 219 spinlock_t event_list_lock;
220
221 /* directory xattrs */
222 struct simple_xattrs xattrs;
219}; 223};
220 224
221/* 225/*
@@ -309,6 +313,9 @@ struct cftype {
309 /* CFTYPE_* flags */ 313 /* CFTYPE_* flags */
310 unsigned int flags; 314 unsigned int flags;
311 315
316 /* file xattrs */
317 struct simple_xattrs xattrs;
318
312 int (*open)(struct inode *inode, struct file *file); 319 int (*open)(struct inode *inode, struct file *file);
313 ssize_t (*read)(struct cgroup *cgrp, struct cftype *cft, 320 ssize_t (*read)(struct cgroup *cgrp, struct cftype *cft,
314 struct file *file, 321 struct file *file,
@@ -394,7 +401,7 @@ struct cftype {
394 */ 401 */
395struct cftype_set { 402struct cftype_set {
396 struct list_head node; /* chained at subsys->cftsets */ 403 struct list_head node; /* chained at subsys->cftsets */
397 const struct cftype *cfts; 404 struct cftype *cfts;
398}; 405};
399 406
400struct cgroup_scanner { 407struct cgroup_scanner {
@@ -406,8 +413,8 @@ struct cgroup_scanner {
406 void *data; 413 void *data;
407}; 414};
408 415
409int cgroup_add_cftypes(struct cgroup_subsys *ss, const struct cftype *cfts); 416int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
410int cgroup_rm_cftypes(struct cgroup_subsys *ss, const struct cftype *cfts); 417int cgroup_rm_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
411 418
412int cgroup_is_removed(const struct cgroup *cgrp); 419int cgroup_is_removed(const struct cgroup *cgrp);
413 420