[lxc-devel] [lxd/master] zfs: try to work around zfs EBUSY bug

brauner on Github lxc-bot at linuxcontainers.org
Wed Apr 26 12:38:45 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 581 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170426/609e165b/attachment.bin>
-------------- next part --------------
From 20e877eb728b6c279d383be0500319776ac9a7c3 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 26 Apr 2017 14:35:49 +0200
Subject: [PATCH] zfs: try to work around zfs EBUSY bug

Until we have an upstream fix for https://github.com/zfsonlinux/zfs/issues/5796
we need to work around zfs's EBUSY bug. So use syscall.Mount() directly and
simply move on when EBUSY is returned.

Closes #3228.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd/storage_zfs.go | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go
index e54e5a6..1805c1d 100644
--- a/lxd/storage_zfs.go
+++ b/lxd/storage_zfs.go
@@ -430,8 +430,17 @@ func (s *storageZfs) ContainerMount(name string, path string) (bool, error) {
 	var imgerr error
 	ourMount := false
 	if !shared.IsMountPoint(containerPoolVolumeMntPoint) {
-		imgerr = s.zfsPoolVolumeMount(fs)
-		ourMount = true
+		source := fmt.Sprintf("%s/%s", s.getOnDiskPoolName(), fs)
+		zfsMountOptions := fmt.Sprintf("rw,zfsutil,mntpoint=%s", containerPoolVolumeMntPoint)
+		mountErr := syscall.Mount(source, containerPoolVolumeMntPoint, "zfs", 0, zfsMountOptions)
+		if mountErr != nil {
+			if mountErr != syscall.EBUSY {
+				return false, mountErr
+			}
+			// EBUSY error in zfs are related to a bug we're
+			// tracking. So ignore them for now and proceed.
+			logger.Warnf("ZFS returned EBUSY while \"%s\" is actually not a mountpoint.", containerPoolVolumeMntPoint)
+		}
 	}
 
 	lxdStorageMapLock.Lock()


More information about the lxc-devel mailing list