[lxc-devel] [lxd/master] dir: check whether pool is already mounted

brauner on Github lxc-bot at linuxcontainers.org
Sat Oct 14 17:14:05 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 381 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20171014/f3eeccf7/attachment.bin>
-------------- next part --------------
From d4694e181a7a2879a66474b31916fe75de402dec Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 14 Oct 2017 19:13:27 +0200
Subject: [PATCH] dir: check whether pool is already mounted

Closes #3938.

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

diff --git a/lxd/storage_dir.go b/lxd/storage_dir.go
index 68f2e08f2..a618156cf 100644
--- a/lxd/storage_dir.go
+++ b/lxd/storage_dir.go
@@ -204,6 +204,10 @@ func (s *storageDir) StoragePoolMount() (bool, error) {
 	mountSource := cleanSource
 	mountFlags := syscall.MS_BIND
 
+	if shared.IsMountPoint(poolMntPoint) {
+		return false, nil
+	}
+
 	err := syscall.Mount(mountSource, poolMntPoint, "", uintptr(mountFlags), "")
 	if err != nil {
 		logger.Errorf(`Failed to mount DIR storage pool "%s" onto `+
@@ -255,11 +259,13 @@ func (s *storageDir) StoragePoolUmount() (bool, error) {
 
 	defer removeLockFromMap()
 
-	if shared.IsMountPoint(poolMntPoint) {
-		err := syscall.Unmount(poolMntPoint, 0)
-		if err != nil {
-			return false, err
-		}
+	if !shared.IsMountPoint(poolMntPoint) {
+		return false, nil
+	}
+
+	err := syscall.Unmount(poolMntPoint, 0)
+	if err != nil {
+		return false, err
 	}
 
 	logger.Debugf("Unmounted DIR pool \"%s\".", s.pool.Name)


More information about the lxc-devel mailing list