From a8a798a7c9b1da5beea8acfec16409d015ad85a7 Mon Sep 17 00:00:00 2001 From: Qiang Huang Date: Wed, 4 Mar 2015 13:45:44 +0800 Subject: [PATCH] cgroups: use Set instead of Apply in Freeze So Apply function of freezer can be as sample as other subsystems. Signed-off-by: Qiang Huang --- cgroups/fs/apply_raw.go | 7 ++++++- cgroups/fs/freezer.go | 19 ++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/cgroups/fs/apply_raw.go b/cgroups/fs/apply_raw.go index 12ece2fe..4943b775 100644 --- a/cgroups/fs/apply_raw.go +++ b/cgroups/fs/apply_raw.go @@ -171,11 +171,16 @@ func (m *Manager) Freeze(state configs.FreezerState) error { return err } + dir, err := d.path("freezer") + if err != nil { + return err + } + prevState := m.Cgroups.Freezer m.Cgroups.Freezer = state freezer := subsystems["freezer"] - err = freezer.Apply(d) + err = freezer.Set(dir, m.Cgroups) if err != nil { m.Cgroups.Freezer = prevState return err diff --git a/cgroups/fs/freezer.go b/cgroups/fs/freezer.go index d7c0da54..fc8241d1 100644 --- a/cgroups/fs/freezer.go +++ b/cgroups/fs/freezer.go @@ -12,20 +12,13 @@ type FreezerGroup struct { } func (s *FreezerGroup) Apply(d *data) error { - switch d.c.Freezer { - case configs.Frozen, configs.Thawed: - dir, err := d.path("freezer") - if err != nil { - return err - } + dir, err := d.join("freezer") + if err != nil && !cgroups.IsNotFound(err) { + return err + } - if err := s.Set(dir, d.c); err != nil { - return err - } - default: - if _, err := d.join("freezer"); err != nil && !cgroups.IsNotFound(err) { - return err - } + if err := s.Set(dir, d.c); err != nil { + return err } return nil