[lxc-devel] [lxd/master] lvm: mount xfs snapshots with "nouuid"

brauner on Github lxc-bot at linuxcontainers.org
Sun Sep 24 19:16:15 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 610 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170924/fa7c6448/attachment.bin>
-------------- next part --------------
From 41f676942270591b35e5fb23ee2ad9438fa2b1a0 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sun, 24 Sep 2017 20:18:43 +0200
Subject: [PATCH 1/2] lvm: non-functional changes

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

diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go
index 5ebace5b9..150b30374 100644
--- a/lxd/storage_lvm.go
+++ b/lxd/storage_lvm.go
@@ -1409,7 +1409,8 @@ func (s *storageLvm) ContainerSnapshotRename(snapshotContainer container, newCon
 }
 
 func (s *storageLvm) ContainerSnapshotStart(container container) (bool, error) {
-	logger.Debugf("Initializing LVM storage volume for snapshot \"%s\" on storage pool \"%s\".", s.volume.Name, s.pool.Name)
+	logger.Debugf(`Initializing LVM storage volume for snapshot "%s" on `+
+		`storage pool "%s"`, s.volume.Name, s.pool.Name)
 
 	poolName := s.getOnDiskPoolName()
 	containerName := container.Name()
@@ -1432,14 +1433,20 @@ func (s *storageLvm) ContainerSnapshotStart(container container) (bool, error) {
 	lvFsType := s.getLvmFilesystem()
 	containerMntPoint := getSnapshotMountPoint(s.pool.Name, containerName)
 	if !shared.IsMountPoint(containerMntPoint) {
-		mountFlags, mountOptions := lxdResolveMountoptions(s.getLvmMountOptions())
+		mntOptString := s.getLvmMountOptions()
+		mountFlags, mountOptions := lxdResolveMountoptions(mntOptString)
 		err = tryMount(containerLvmPath, containerMntPoint, lvFsType, mountFlags, mountOptions)
 		if err != nil {
-			return false, fmt.Errorf("Error mounting snapshot LV path='%s': %s", containerMntPoint, err)
+			logger.Errorf(`Failed to mount LVM snapshot "%s" with `+
+				`filesystem "%s" options "%s" onto "%s": %s`,
+				s.volume.Name, lvFsType, mntOptString,
+				containerMntPoint, err)
+			return false, err
 		}
 	}
 
-	logger.Debugf("Initialized LVM storage volume for snapshot \"%s\" on storage pool \"%s\".", s.volume.Name, s.pool.Name)
+	logger.Debugf(`Initialized LVM storage volume for snapshot "%s" on `+
+		`storage pool "%s"`, s.volume.Name, s.pool.Name)
 
 	if wasWritableAtCheck {
 		return false, nil

From 563c1bba203e505295afd3e57af8e02d7b38e2a2 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sun, 24 Sep 2017 21:03:43 +0200
Subject: [PATCH 2/2] lvm: mount xfs snapshots with "nouuid"

xfs explicitly mentions:

"nouuid Don't check for double mounted file systems using the file system uuid.
	This is useful to mount LVM snapshot volumes, and often  used  in
	combination with "norecovery" for mounting read-only snapshots."

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd/storage_lvm.go | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go
index 150b30374..f355d3e30 100644
--- a/lxd/storage_lvm.go
+++ b/lxd/storage_lvm.go
@@ -1435,6 +1435,14 @@ func (s *storageLvm) ContainerSnapshotStart(container container) (bool, error) {
 	if !shared.IsMountPoint(containerMntPoint) {
 		mntOptString := s.getLvmMountOptions()
 		mountFlags, mountOptions := lxdResolveMountoptions(mntOptString)
+
+		if lvFsType == "xfs" {
+			idx := strings.Index(mountOptions, "nouuid")
+			if idx < 0 {
+				mountOptions += ",nouuid"
+			}
+		}
+
 		err = tryMount(containerLvmPath, containerMntPoint, lvFsType, mountFlags, mountOptions)
 		if err != nil {
 			logger.Errorf(`Failed to mount LVM snapshot "%s" with `+


More information about the lxc-devel mailing list