• Li Zefan's avatar
    cgroup: fix mount failure in a corner case · 970317aa
    Li Zefan authored
      # cat test.sh
      #! /bin/bash
    
      mount -t cgroup -o cpu xxx /cgroup
      umount /cgroup
    
      mount -t cgroup -o cpu,cpuacct xxx /cgroup
      umount /cgroup
      # ./test.sh
      mount: xxx already mounted or /cgroup busy
      mount: according to mtab, xxx is already mounted on /cgroup
    
    It's because the cgroupfs_root of the first mount was under destruction
    asynchronously.
    
    Fix this by delaying and then retrying mount for this case.
    
    v3:
    - put the refcnt immediately after getting it. (Tejun)
    
    v2:
    - use percpu_ref_tryget_live() rather that introducing
      percpu_ref_alive(). (Tejun)
    - adjust comment.
    
    tj: Updated the comment a bit.
    
    Cc: <stable@vger.kernel.org> # 3.15
    Signed-off-by: default avatarLi Zefan <lizefan@huawei.com>
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    970317aa
cgroup.c 145 KB