[lxc-devel] [lxd/master] Bugfixes
stgraber on Github
lxc-bot at linuxcontainers.org
Tue Feb 21 21:46:38 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170221/f6bf1fb9/attachment.bin>
-------------- next part --------------
From e2b6d0897b1ca9cf878f3cb2e837fa4ed1f69215 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 21 Feb 2017 16:25:36 -0500
Subject: [PATCH 1/2] btrfs: Always pass the mount options
---
lxd/storage_btrfs.go | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index dcfaa01..b3d297b 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -22,6 +22,8 @@ import (
log "gopkg.in/inconshreveable/log15.v2"
)
+var btrfsMntOptions = "user_subvol_rm_allowed"
+
type storageBtrfs struct {
storageShared
}
@@ -202,7 +204,7 @@ func (s *storageBtrfs) StoragePoolCreate() error {
// cannot call StoragePoolMount() since it will try to do the
// reverse operation. So instead we shamelessly mount using the
// block device path at the time of pool creation.
- err1 = syscall.Mount(source, poolMntPoint, "btrfs", 0, "")
+ err1 = syscall.Mount(source, poolMntPoint, "btrfs", 0, btrfsMntOptions)
} else {
_, err1 = s.StoragePoolMount()
}
@@ -349,7 +351,6 @@ func (s *storageBtrfs) StoragePoolMount() (bool, error) {
return false, nil
}
- poolMntOptions := "user_subvol_rm_allowed"
mountSource := source
if filepath.IsAbs(source) {
if !shared.IsBlockdevPath(source) && s.d.BackingFs != "btrfs" {
@@ -382,7 +383,7 @@ func (s *storageBtrfs) StoragePoolMount() (bool, error) {
}
// This is a block device.
- err := syscall.Mount(mountSource, poolMntPoint, "btrfs", 0, poolMntOptions)
+ err := syscall.Mount(mountSource, poolMntPoint, "btrfs", 0, btrfsMntOptions)
if err != nil {
return false, err
}
From 16b424291098b23d732fe7aeeb4a6185f5d7d787 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 21 Feb 2017 16:27:37 -0500
Subject: [PATCH 2/2] btrfs: Drop dead code
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/storage_btrfs.go | 65 ++++------------------------------------------------
1 file changed, 4 insertions(+), 61 deletions(-)
diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index b3d297b..8ba340a 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -48,26 +48,6 @@ func (s *storageBtrfs) getCustomSubvolumePath(poolName string) string {
return shared.VarPath("storage-pools", poolName, "custom")
}
-// subvol=containers/<container_name>
-func (s *storageBtrfs) getContainerMntOptions(name string) string {
- return fmt.Sprintf("subvol=containers/%s", name)
-}
-
-// subvol=snapshots/<snapshot_name>
-func (s *storageBtrfs) getSnapshotMntOptions(name string) string {
- return fmt.Sprintf("subvol=snapshots/%s", name)
-}
-
-// subvol=images/<fingerprint>
-func (s *storageBtrfs) getImageMntOptions(imageFingerprint string) string {
- return fmt.Sprintf("subvol=images/%s", imageFingerprint)
-}
-
-// subvol=custom/<custom_name>
-func (s *storageBtrfs) getCustomMntOptions() string {
- return fmt.Sprintf("subvol=custom/%s", s.volume.Name)
-}
-
func (s *storageBtrfs) StorageCoreInit() (*storageCore, error) {
sCore := storageCore{}
sCore.sType = storageTypeBtrfs
@@ -501,53 +481,16 @@ func (s *storageBtrfs) StoragePoolVolumeDelete() error {
}
func (s *storageBtrfs) StoragePoolVolumeMount() (bool, error) {
- source := s.pool.Config["source"]
- if source == "" {
- return false, fmt.Errorf("No \"source\" property found for the storage pool.")
- }
-
- // Check if the storage volume is already mounted.
- customMntPoint := getStoragePoolVolumeMountPoint(s.pool.Name, s.volume.Name)
- if shared.IsMountPoint(customMntPoint) {
- return false, nil
- }
-
- // Mount the storage volume on its mountpoint.
- customMntOptions := ""
- if !shared.IsBlockdevPath(source) {
- // mount("/dev/loop<n>", "/path/to/target", "btrfs", 0, "subvol=subvol/name")
- loopF, err := prepareLoopDev(source)
- if err != nil {
- return false, fmt.Errorf("Could not prepare loop device.")
- }
- loopDev := loopF.Name()
- defer loopF.Close()
-
- // Pass the btrfs subvolume name as mountoption.
- customMntOptions = s.getCustomMntOptions()
- err = syscall.Mount(loopDev, customMntPoint, "btrfs", 0, customMntOptions)
- if err != nil {
- return false, err
- }
- } else {
- err := syscall.Mount(source, customMntPoint, "btrfs", 0, customMntOptions)
- if err != nil {
- return false, err
- }
+ // The storage pool must be mounted.
+ _, err := s.StoragePoolMount()
+ if err != nil {
+ return false, err
}
return true, nil
}
func (s *storageBtrfs) StoragePoolVolumeUmount() (bool, error) {
- customMntPoint := getStoragePoolVolumeMountPoint(s.pool.Name, s.volume.Name)
- if shared.IsMountPoint(customMntPoint) {
- err := syscall.Unmount(customMntPoint, 0)
- if err != nil {
- return false, err
- }
- }
-
return true, nil
}
More information about the lxc-devel
mailing list