* Dhaval Giani <[EMAIL PROTECTED]> [2008-12-11 02:13:39]:

> >> Dont't like awk, can we convert it to a read?
> >>
> >
> > Yep, I realized that. I will fix this.
> >
> 
> Ok, I necessarily don't like this. I am very much open to doing it more
> cleanly. 
> (Patch has been tested by running service cgconfig start/stpo and
> checking the permissions)
> --
> 
> libcgroup: Allow tasks to be moved back to a default cgroup
> 
> From: Balbir Singh <[EMAIL PROTECTED]>
> 
> I've been experimenting with task migration in cgroups and hit a
> strange problem
> 
> 1. By default all classes belong to the root group
> 2. When I migrate a group to a different group (I can migrate based on
>    permissions)
> 3. But when I am done, I can't migrate back to the root group since
>    all of it is owned by root
> 
> I am playing around with a fix that allows creation of a /default
> group and using cgrulesengd, we can classify all tasks to /default. I
> propose giving world read, write permissions to /default/tasks, so
> that a class can return back home when it is done with its work in
> other groups. I faced this issue when I created a thread pool and used
> different threads to move to various groups, but in the end they had
> no place to return back to :(
> 
> Here is a proposed fix. Thoughts? Comments? Flames?
> 
> Signed-off-by: Balbir Singh <[EMAIL PROTECTED]>
> Signed-off-by: Dhaval Giani <[EMAIL PROTECTED]>
> 
> ---
>  scripts/init.d/cgconfig |   22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> Index: trunk/scripts/init.d/cgconfig
> ===================================================================
> --- trunk.orig/scripts/init.d/cgconfig        2008-10-30 21:52:23.000000000 
> +0530
> +++ trunk/scripts/init.d/cgconfig     2008-12-11 02:11:08.000000000 +0530
> @@ -81,6 +81,28 @@ start() {
>          then
>                  #log_progress_msg "Starting cgconfig service: "
>                  cgconfigparser -l $CONFIG_FILE
> +             #
> +             # Create a default class for tasks to return back to
> +             #
> +             parse_mounts
> +             declare defaultcgroup
> +             if [ -f /etc/cgrules.conf ]
> +             then
> +                     defaultcgroup=`(grep ^\* /etc/cgrules.conf) | (read 
> user ctrl cgroup others; echo $cgroup)`

We also need to remember that grep can give us multiple lines due to
misconfiguration, so we need to pick up just the first matched line or
complain. I use grep -m 1 for that. The other concern is if
defaultcgroup matches to "*" due to bad setup or some other glob
expression, the script might not behave as expected

I propose using the following

                if [ -f /etc/cgrules.conf ]
                then
                        read user ctrl defaultcgroup <<< \
                                `grep -m1 ^\* /etc/cgrules.conf`
                fi
                if [[ -n $defaultcgroup && $defaultcgroup = "*" ]]
                then
                        log_warning_msg "/etc/cgrules.conf incorrect"
                        log_warning_msg "Overriding it"
                        defaultcgroup=
                fi


> +             fi
> +             if [ -z $defaultcgroup ]
> +             then
> +                     defaultcgroup=sysdefault/
> +             fi
> +             for i in `seq 1 $maxindex`
> +             do
> +                     #
> +                     # Ignore if directory already exists
> +                     #
> +                     mkdir ${MOUNTPOINT[$i]}/$defaultcgroup 2> /dev/null
> +                     chmod a+rw ${MOUNTPOINT[$i]}/$defaultcgroup/tasks
> +             done
> +
>          fi
>          [ $? == 0 ] && touch /var/lock/subsys/$servicename
>          return $?
> -- 
> regards,
> Dhaval
> 

-- 
        Balbir

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to