From f06d92067da861d5b80a9b6bf0b36f7f9bf8d1a0 Mon Sep 17 00:00:00 2001 From: Liu Bo Date: Thu, 4 Feb 2016 10:25:24 -0800 Subject: [PATCH] Graphdriver/btrfs: Avoid using single d.Get() For btrfs driver, in d.Create(), Get() of parentDir is called but not followed by Put(). If we apply SElinux mount label, we need to mount btrfs subvolumes in d.Get(), without a Put() would end up with a later Remove() failure on "Device resourse is busy". This calls the subvolume helper function directly in d.Create(). Signed-off-by: Liu Bo Upstream-commit: b2e27fee53c269f9659bdab66852eaba4ffbe9c7 Component: engine --- components/engine/daemon/graphdriver/btrfs/btrfs.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/engine/daemon/graphdriver/btrfs/btrfs.go b/components/engine/daemon/graphdriver/btrfs/btrfs.go index d9750c95b2..48388f72fe 100644 --- a/components/engine/daemon/graphdriver/btrfs/btrfs.go +++ b/components/engine/daemon/graphdriver/btrfs/btrfs.go @@ -256,10 +256,14 @@ func (d *Driver) Create(id, parent, mountLabel string) error { return err } } else { - parentDir, err := d.Get(parent, "") + parentDir := d.subvolumesDirID(parent) + st, err := os.Stat(parentDir) if err != nil { return err } + if !st.IsDir() { + return fmt.Errorf("%s: not a direcotory", parentDir) + } if err := subvolSnapshot(parentDir, subvolumes, id); err != nil { return err }