When cgroup_modify_cgroup() invokes cgroup_set_values_recursive(), some of the settings within the cgroup may not be writable. Avoid failing the entire write by ignoring write failures on settings that do not explicitly have the dirty flag set.
Signed-off-by: Tom Hromatka <tom.hroma...@oracle.com> --- src/api.c | 16 +++++++++++++--- src/libcgroup-internal.h | 3 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/api.c b/src/api.c index 40637a5305cc..4de07f39bd68 100644 --- a/src/api.c +++ b/src/api.c @@ -1892,7 +1892,8 @@ static int cg_set_control_value(char *path, const char *val) * @param controller The controller whose values are being updated */ STATIC int cgroup_set_values_recursive(const char * const base, - const struct cgroup_controller * const controller) + const struct cgroup_controller * const controller, + bool ignore_non_dirty_failures) { char *path = NULL; int error = 0, ret, j; @@ -1913,6 +1914,15 @@ STATIC int cgroup_set_values_recursive(const char * const base, free(path); path = NULL; + if (error && ignore_non_dirty_failures && + !controller->values[j]->dirty) { + /* We failed to set this value, but it wasn't + * marked as dirty, so ignore the failure. + */ + error = 0; + continue; + } + if (error) goto err; @@ -2142,7 +2152,7 @@ int cgroup_modify_cgroup(struct cgroup *cgroup) continue; error = cgroup_set_values_recursive(base, - cgroup->controller[i]); + cgroup->controller[i], true); if (error) goto err; } @@ -2393,7 +2403,7 @@ int cgroup_create_cgroup(struct cgroup *cgroup, int ignore_ownership) goto err; error = cgroup_set_values_recursive(base, - cgroup->controller[k]); + cgroup->controller[k], false); if (error) goto err; diff --git a/src/libcgroup-internal.h b/src/libcgroup-internal.h index 0367c60a91ec..1dfc92b5b51b 100644 --- a/src/libcgroup-internal.h +++ b/src/libcgroup-internal.h @@ -389,7 +389,8 @@ int cgroup_process_v1_mnt(char *controllers[], struct mntent *ent, int cgroup_process_v2_mnt(struct mntent *ent, int *mnt_tbl_idx); int cgroup_set_values_recursive(const char * const base, - const struct cgroup_controller * const controller); + const struct cgroup_controller * const controller, + bool ignore_non_dirty_failures); int cgroup_chown_chmod_tasks(const char * const cg_path, uid_t uid, gid_t gid, mode_t fperm); -- 2.26.2 _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel