From 7de870993035f855e1d1299a2b5c2c90b792c238 Mon Sep 17 00:00:00 2001 From: Vivek Goyal Date: Wed, 31 Mar 2010 22:55:15 +0200 Subject: Add an option "cgroup_nodelete" to not delete cgroups after job completion o Add an option cgroup_nodelete to not remove cgroups created by fio after the job completion. This can help a user in inspecting various cgroup files after fio job completion. Signed-off-by: Vivek Goyal Signed-off-by: Jens Axboe --- cgroup.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'cgroup.c') diff --git a/cgroup.c b/cgroup.c index 14bbc57b..0e3a71eb 100644 --- a/cgroup.c +++ b/cgroup.c @@ -14,6 +14,7 @@ static struct fio_mutex *lock; struct cgroup_member { struct flist_head list; char *root; + unsigned int cgroup_nodelete; }; static char *find_cgroup_mnt(struct thread_data *td) @@ -43,14 +44,16 @@ static char *find_cgroup_mnt(struct thread_data *td) return mntpoint; } -static void add_cgroup(const char *name, struct flist_head *clist) +static void add_cgroup(struct thread_data *td, const char *name, + struct flist_head *clist) { struct cgroup_member *cm; cm = smalloc(sizeof(*cm)); INIT_FLIST_HEAD(&cm->list); cm->root = smalloc_strdup(name); - + if (td->o.cgroup_nodelete) + cm->cgroup_nodelete = 1; fio_mutex_down(lock); flist_add_tail(&cm->list, clist); fio_mutex_up(lock); @@ -65,7 +68,8 @@ void cgroup_kill(struct flist_head *clist) flist_for_each_safe(n, tmp, clist) { cm = flist_entry(n, struct cgroup_member, list); - rmdir(cm->root); + if (!cm->cgroup_nodelete) + rmdir(cm->root); flist_del(&cm->list); sfree(cm->root); sfree(cm); @@ -144,7 +148,7 @@ int cgroup_setup(struct thread_data *td, struct flist_head *clist, char **mnt) goto err; } } else - add_cgroup(root, clist); + add_cgroup(td, root, clist); if (td->o.cgroup_weight) { if (write_int_to_file(td, root, "blkio.weight", -- cgit v1.2.3