Browse Source

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 <bo.li.liu@oracle.com>
Liu Bo 9 years ago
parent
commit
b2e27fee53
1 changed files with 5 additions and 1 deletions
  1. 5 1
      daemon/graphdriver/btrfs/btrfs.go

+ 5 - 1
daemon/graphdriver/btrfs/btrfs.go

@@ -256,10 +256,14 @@ func (d *Driver) Create(id, parent, mountLabel string) error {
 			return err
 			return err
 		}
 		}
 	} else {
 	} else {
-		parentDir, err := d.Get(parent, "")
+		parentDir := d.subvolumesDirID(parent)
+		st, err := os.Stat(parentDir)
 		if err != nil {
 		if err != nil {
 			return err
 			return err
 		}
 		}
+		if !st.IsDir() {
+			return fmt.Errorf("%s: not a direcotory", parentDir)
+		}
 		if err := subvolSnapshot(parentDir, subvolumes, id); err != nil {
 		if err := subvolSnapshot(parentDir, subvolumes, id); err != nil {
 			return err
 			return err
 		}
 		}