Skip to contentSkip to conversation

cgroups: add documentation on extended attributes and simple_xattr functions

PATCH Applied Aristeu Rozanski 4 participants 8 messages Sep 11, 2012 – Sep 13, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover cgroups: add documentation on extended attributes and simple_xattr functions

cgroups: add documentation on extended attributes and simple_xattr functions

These patches add documentation on the new functions and current specific cgroup usage.

v2: include Li Zefan's requested changes

Cc Li Zefan <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Hillf Danton <[email protected]>
Cc Lennart Poettering <[email protected]>
Signature · 1 line
Aristeu
#1 lore raw

PATCH v2 1/2 cgroups: add documentation on extended attributes usage

v2: update cgroups.txt instead of creating a new file

Cc Li Zefan <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Hillf Danton <[email protected]>
Cc Lennart Poettering <[email protected]>
---
 Documentation/cgroups/cgroups.txt |   24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
Documentation/cgroups/cgroups.txt +22 -2
Index: github/Documentation/cgroups/cgroups.txt
===================================================================
@@ -29,7 +29,8 @@
   3.1 Overview
   3.2 Synchronization
   3.3 Subsystem API
-4. Questions
+4. Extended attributes usage
+5. Questions
 
 1. Control Groups
 =================
@@ -650,7 +651,26 @@
 the default hierarchy (which never has sub-cgroups) and a hierarchy
 that is being created/destroyed (and hence has no sub-cgroups).
 
-4. Questions
+4. Extended attribute usage
+===========================
+
+cgroup filesystem supports certain types of extended attributes in its
+directories and files.  The current supported types are:
+	- Trusted (XATTR_TRUSTED)
+	- Security (XATTR_SECURITY)
+
+Both require CAP_SYS_ADMIN capability to set.
+
+Like in tmpfs, the extended attributes in cgroup filesystem are stored
+using kernel memory and it's advised to keep the usage at minimum.  This
+is the reason why user defined extended attributes are not supported, since
+any user can do it and there's no limit in the value size.
+
+The current known users for this feature are SELinux to limit cgroup usage
+in containers and systemd for assorted meta data like main PID in a cgroup
+(systemd creates a cgroup per service).
+
+5. Questions
 ============
 
 Q: what's up with this '/bin/echo' ?
Acked-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] cgroups: add documentation on extended attributes usage

Quoted 9 lines

v2: update cgroups.txt instead of creating a new file

Cc Li Zefan <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Hillf Danton <[email protected]>
Cc Lennart Poettering <[email protected]>
Quoted 3 lines
---
 Documentation/cgroups/cgroups.txt |   24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
#3 lore raw

PATCH v2 2/2 fs: add missing documentation to simple_xattr functions

In reply to Aristeu Rozanski

v2: add function documentation instead of adding a separate file under
Documentation/

Cc Li Zefan <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Hillf Danton <[email protected]>
Cc Lennart Poettering <[email protected]>
---
 fs/xattr.c |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
fs/xattr.c +16 -2
Index: github/fs/xattr.c
===================================================================
@@ -892,8 +892,19 @@
 
 }
 
-/*
- * xattr SET operation for in-memory/pseudo filesystems
+/**
+ * simple_xattr_set: xattr SET operation for in-memory/pseudo filesystems
+ * @xattrs: simple_xattr list
+ * @name: name of the new extended attribute
+ * @value: value of the new extended attribute. If NULL, will remove the
+ *	   attribute
+ * @flags: if XATTR_CREATE is set, no already existing extended attribute may
+ *	   exist. If XATTR_REPLACE is set, the extended attribute should exist.
+ *
+ * returns -ENOMEM for allocation failures, -EEXIST in case XATTR_CREATE is
+ *	   set in flags and an extended attribute with the same name exists,
+ *	   -ENODATA if XATTR_REPLACE is set in flags but no entry with the
+ *	   specified name exists.
  */
 int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
 		     const void *value, size_t size, int flags)
@@ -950,6 +961,9 @@
 	return used;
 }
 
+/*
+ * Adds an extended attribute to the list
+ */
 void simple_xattr_list_add(struct simple_xattrs *xattrs,
 			   struct simple_xattr *new_xattr)
 {
#4 lore raw

Re: [PATCH v2 2/2] fs: add missing documentation to simple_xattr functions

On 09/11/2012 01:28 PM, Aristeu Rozanski wrote:

+/**
+ * simple_xattr_set: xattr SET operation for in-memory/pseudo filesystems

The format for the function name/description uses '-', not ':', as:

* simple_xattr_set - xattr SET operation for in-memory/pseudo filesystems

+ * @xattrs: simple_xattr list
+ * @name: name of the new extended attribute
+ * @value: value of the new extended attribute. If NULL, will remove the
+ * attribute

Missing @size parameter description.

+ * @flags: if XATTR_CREATE is set, no already existing extended attribute may
+ * exist. If XATTR_REPLACE is set, the extended attribute should exist.
+ *
+ * returns -ENOMEM for allocation failures, -EEXIST in case XATTR_CREATE is

+ *	   set in flags and an extended attribute with the same name exists,
+ *	   -ENODATA if XATTR_REPLACE is set in flags but no entry with the
+ *	   specified name exists.

*/
int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
const void *value, size_t size, int flags)

Signature · 1 line
~Randy
maintainer
#5 lore raw

Re: [PATCH v2 2/2] fs: add missing documentation to simple_xattr functions

Quoted 8 lines · Randy Dunlap

On 09/11/2012 01:28 PM, Aristeu Rozanski wrote:

+/**
+ * simple_xattr_set: xattr SET operation for in-memory/pseudo filesystems

The format for the function name/description uses '-', not ':', as:

Quoted 8 lines

* simple_xattr_set - xattr SET operation for in-memory/pseudo filesystems

+ * @xattrs: simple_xattr list
+ * @name: name of the new extended attribute
+ * @value: value of the new extended attribute. If NULL, will remove the
+ * attribute

Missing @size parameter description.

Updated the patch in place accordingly. Thanks.

From 4895768b6aab55bbdbebcf2da090cb1a5ccf5463 Mon Sep 17 00:00:00 2001
From: Aristeu Rozanski <[email protected]>
Date: Tue, 11 Sep 2012 16:28:11 -0400
Subject: [PATCH] fs: add missing documentation to simple_xattr functions

v2: add function documentation instead of adding a separate file under
Documentation/

tj: Updated comment a bit and rolled in Randy's suggestions.

Cc Li Zefan <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Hillf Danton <[email protected]>
Cc Lennart Poettering <[email protected]>
Cc Randy Dunlap <rdunlap-/[email protected]>
---
 fs/xattr.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
fs/xattr.c +16 -2
index e17e773..f053c11 100644
@@ -892,8 +892,19 @@ out:
 
 }
 
-/*
- * xattr SET operation for in-memory/pseudo filesystems
+/**
+ * simple_xattr_set - xattr SET operation for in-memory/pseudo filesystems
+ * @xattrs: target simple_xattr list
+ * @name: name of the new extended attribute
+ * @value: value of the new xattr. If %NULL, will remove the attribute
+ * @size: size of the new xattr
+ * @flags: %XATTR_{CREATE|REPLACE}
+ *
+ * %XATTR_CREATE is set, the xattr shouldn't exist already; otherwise fails
+ * with -EEXIST.  If %XATTR_REPLACE is set, the xattr should exist;
+ * otherwise, fails with -ENODATA.
+ *
+ * Returns 0 on success, -errno on failure.
  */
 int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
 		     const void *value, size_t size, int flags)
@@ -950,6 +961,9 @@ ssize_t simple_xattr_list(struct simple_xattrs *xattrs, char *buffer,
 	return used;
 }
 
+/*
+ * Adds an extended attribute to the list
+ */
 void simple_xattr_list_add(struct simple_xattrs *xattrs,
 			   struct simple_xattr *new_xattr)
 {
Signature · 1 line
1.7.7.3
#6 lore raw

Re: [PATCH v2 2/2] fs: add missing documentation to simple_xattr functions

Quoted 11 lines · Tejun Heo

Updated the patch in place accordingly. Thanks.

From 4895768b6aab55bbdbebcf2da090cb1a5ccf5463 Mon Sep 17 00:00:00 2001
From: Aristeu Rozanski <[email protected]>
Date: Tue, 11 Sep 2012 16:28:11 -0400
Subject: [PATCH] fs: add missing documentation to simple_xattr functions

v2: add function documentation instead of adding a separate file under
Documentation/

tj: Updated comment a bit and rolled in Randy's suggestions.

Thanks Tejun, Randy

Signature · 1 line
Aristeu
maintainer Applied
#7 lore raw
In reply to Aristeu Rozanski
Quoted 6 lines · Aristeu Rozanski

cgroups: add documentation on extended attributes and simple_xattr functions

These patches add documentation on the new functions and current specific cgroup usage.

v2: include Li Zefan's requested changes

Applied to for-3.7. Thanks!

Signature · 1 line
tejun