From 9192baac2d6ef70bbc799d46df8bb9deb371e8ab Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 11 Aug 2015 18:00:36 -0700 Subject: [PATCH 1/2] graphdriver/zfs: privatize mountPath and zfsPath These functions are not part of the graphdriver.Driver interface and should therefore be private. Also, remove comments added by commit e27c904 as they are * pretty obvious * no longer required by golint Signed-off-by: Kir Kolyshkin Upstream-commit: f5f7fee2ecc964314b2a7b910fda71a157c90f16 Component: engine --- .../engine/daemon/graphdriver/zfs/zfs.go | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/components/engine/daemon/graphdriver/zfs/zfs.go b/components/engine/daemon/graphdriver/zfs/zfs.go index 1bae718fed..4b0cac3c5c 100644 --- a/components/engine/daemon/graphdriver/zfs/zfs.go +++ b/components/engine/daemon/graphdriver/zfs/zfs.go @@ -227,13 +227,11 @@ func (d *Driver) cloneFilesystem(name, parentName string) error { return snapshot.Destroy(zfs.DestroyDeferDeletion) } -// ZfsPath returns the filesystem path for the id provided. -func (d *Driver) ZfsPath(id string) string { +func (d *Driver) zfsPath(id string) string { return d.options.fsName + "/" + id } -// MountPath returns the mounted filesystem path for the id provided. -func (d *Driver) MountPath(id string) string { +func (d *Driver) mountPath(id string) string { return path.Join(d.options.mountPath, "graph", getMountpoint(id)) } @@ -252,7 +250,7 @@ func (d *Driver) Create(id string, parent string) error { return err } - dataset := zfs.Dataset{Name: d.ZfsPath(id)} + dataset := zfs.Dataset{Name: d.zfsPath(id)} if err := dataset.Destroy(zfs.DestroyRecursiveClones); err != nil { return err } @@ -262,7 +260,7 @@ func (d *Driver) Create(id string, parent string) error { } func (d *Driver) create(id, parent string) error { - name := d.ZfsPath(id) + name := d.zfsPath(id) if parent == "" { mountoptions := map[string]string{"mountpoint": "legacy"} fs, err := zfs.CreateFilesystem(name, mountoptions) @@ -273,12 +271,12 @@ func (d *Driver) create(id, parent string) error { } return err } - return d.cloneFilesystem(name, d.ZfsPath(parent)) + return d.cloneFilesystem(name, d.zfsPath(parent)) } // Remove deletes the dataset, filesystem and the cache for the given id. func (d *Driver) Remove(id string) error { - name := d.ZfsPath(id) + name := d.zfsPath(id) dataset := zfs.Dataset{Name: name} err := dataset.Destroy(zfs.DestroyRecursive) if err == nil { @@ -291,8 +289,8 @@ func (d *Driver) Remove(id string) error { // Get returns the mountpoint for the given id after creating the target directories if necessary. func (d *Driver) Get(id, mountLabel string) (string, error) { - mountpoint := d.MountPath(id) - filesystem := d.ZfsPath(id) + mountpoint := d.mountPath(id) + filesystem := d.zfsPath(id) options := label.FormatMountLabel("", mountLabel) logrus.Debugf(`[zfs] mount("%s", "%s", "%s")`, filesystem, mountpoint, options) @@ -311,7 +309,7 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { // Put removes the existing mountpoint for the given id if it exists. func (d *Driver) Put(id string) error { - mountpoint := d.MountPath(id) + mountpoint := d.mountPath(id) logrus.Debugf(`[zfs] unmount("%s")`, mountpoint) if err := mount.Unmount(mountpoint); err != nil { @@ -322,5 +320,5 @@ func (d *Driver) Put(id string) error { // Exists checks to see if the cache entry exists for the given id. func (d *Driver) Exists(id string) bool { - return d.filesystemsCache[d.ZfsPath(id)] == true + return d.filesystemsCache[d.zfsPath(id)] == true } From baa28c0e1c525a8d36b9cb3c1b6f39caca24dcd7 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 11 Aug 2015 18:11:41 -0700 Subject: [PATCH 2/2] graphdriver/zfs: fix GetMetadata() comment Commit e27c904 added a wrong and misleading comment to GetMetadata(). Fix it using the wording from commit 407a626 which introduced GetMetadata(). Signed-off-by: Kir Kolyshkin Upstream-commit: 15a232fd06e062f8aae4e89e1f520f44c875daeb Component: engine --- components/engine/daemon/graphdriver/zfs/zfs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/engine/daemon/graphdriver/zfs/zfs.go b/components/engine/daemon/graphdriver/zfs/zfs.go index 4b0cac3c5c..0142890b0d 100644 --- a/components/engine/daemon/graphdriver/zfs/zfs.go +++ b/components/engine/daemon/graphdriver/zfs/zfs.go @@ -200,7 +200,7 @@ func (d *Driver) Status() [][2]string { } } -// GetMetadata is used for implementing the graphdriver.ProtoDriver interface. ZFS does not currently have any meta data. +// GetMetadata returns image/container metadata related to graph driver func (d *Driver) GetMetadata(id string) (map[string]string, error) { return nil, nil }