On Fri, Jun 25, 2010 at 5:33 AM, Eric Brower <[email protected]> wrote:
> Return ECGROUPNOTEQUAL when copying controller parameters fails-- this
> allows callers to differentiate between cgroup creation failures and
> controller configuration failures, and makes explicit that this function
> can return an error code but still have created the cgroup.  Callers,
> such as cgroup_create_cgroup_from_parent(), can now explicitly ignore
> (the unfortunately expected) controller configuration errors.
>
> diff --git a/src/api.c b/src/api.c
> index 4823006..a29fe80 100644
> --- a/src/api.c
> +++ b/src/api.c
> @@ -1310,6 +1310,8 @@ err:
>  *
>  * returns 0 on success. We recommend calling cg_delete_cgroup
>  * if this routine fails. That should do the cleanup operation.
> + * If ECGROUPNOTEQUAL is returned, the group was created successfully
> + * but not all controller parameters were successfully set.
>  */

Updating comments in include/libcgroup/groups.h, will help keep the
documentation up to date.

>  int cgroup_create_cgroup(struct cgroup *cgroup, int ignore_ownership)
>  {
> @@ -1374,8 +1376,8 @@ int cgroup_create_cgroup(struct cgroup *cgroup,
> int ignore_ownership)
>                for (j = 0; j < cgroup->controller[k]->index; j++) {
>                        ret = snprintf(path, FILENAME_MAX, "%s%s", base,
>                                        
> cgroup->controller[k]->values[j]->name);
> -                       cgroup_dbg("setting %s to %s, error %d\n", path,
> -                               cgroup->controller[k]->values[j]->name, ret);
> +                       cgroup_dbg("setting %s to \"%s\", pathlen %d\n", path,
> +                               cgroup->controller[k]->values[j]->value, ret);
>                        if (ret < 0 || ret >= FILENAME_MAX) {
>                                last_errno = errno;
>                                error = ECGOTHER;
> @@ -1390,10 +1392,15 @@ int cgroup_create_cgroup(struct cgroup
> *cgroup, int ignore_ownership)
>                         * are only conditionally created in the child.
>                         *
>                         * A middle ground would be to track that there
> -                        * was an error and return that value.
> +                        * was an error and return a diagnostic value--
> +                        * we don't get context for the error, but we can
> +                        * ignore it specifically if we wish.
>                         */
>                        if (error) {
> -                               retval = error;
> +                               cgroup_dbg("failed to set %s: %s (%d)\n",
> +                                       path,
> +                                       cgroup_strerror(error), error);
> +                               retval = ECGROUPNOTEQUAL;
>                                continue;
>                        }
>                }
> @@ -1508,6 +1555,9 @@ free_parent:
>  * @cgroup: cgroup data structure to be filled with parent values and then
>  *       passed down for creation
>  * @ignore_ownership: Ignore doing a chown on the newly created cgroup
> + * @return 0 on success, > 0 on failure.  If ECGROUPNOTEQUAL is returned,
> + * the group was created successfully, but not all controller parameters
> + * were copied from the parent successfully; unfortunately, this is 
> expected...
>  */
>  int cgroup_create_cgroup_from_parent(struct cgroup *cgroup,
>                                        int ignore_ownership)

Looks good to me
Acked-by: Balbir Singh <[email protected]>

Balbir

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to