[lxc-devel] [lxd/master] LVM mount options
stgraber on Github
lxc-bot at linuxcontainers.org
Fri Sep 16 22:20:14 UTC 2016
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/20160916/d00ee775/attachment.bin>
-------------- next part --------------
From 81cafeba51a73d3b920c9e418dbb9389e5b40771 Mon Sep 17 00:00:00 2001
From: Nobuto Murata <nobuto.murata at canonical.com>
Date: Wed, 14 Sep 2016 20:07:33 +0900
Subject: [PATCH 1/2] new config option, storage.lvm_mount_options
Signed-off-by: Nobuto Murata <nobuto.murata at canonical.com>
---
config/bash/lxd-client | 2 +-
doc/configuration.md | 1 +
lxd/daemon_config.go | 1 +
lxd/storage_lvm.go | 12 ++++++++----
4 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/config/bash/lxd-client b/config/bash/lxd-client
index c475c7f..b7fe02a 100644
--- a/config/bash/lxd-client
+++ b/config/bash/lxd-client
@@ -42,7 +42,7 @@ _have lxc && {
core.https_allowed_credentials core.proxy_https \
core.proxy_http core.proxy_ignore_host core.trust_password \
storage.lvm_vg_name storage.lvm_thinpool_name storage.lvm_fstype \
- storage.lvm_volume_size storage.zfs_pool_name \
+ storage.lvm_volume_size storage.lvm_mount_options storage.zfs_pool_name \
storage.zfs_remove_snapshots storage.zfs_use_refquota \
images.compression_algorithm \
images.remote_cache_expiry images.auto_update_interval \
diff --git a/doc/configuration.md b/doc/configuration.md
index d705a29..109ad18 100644
--- a/doc/configuration.md
+++ b/doc/configuration.md
@@ -31,6 +31,7 @@ core.trust\_password | string | - | -
storage.lvm\_vg\_name | string | - | - | LVM Volume Group name to be used for container and image storage. A default Thin Pool is created using 100% of the free space in the Volume Group, unless `storage.lvm_thinpool_name` is set.
storage.lvm\_thinpool\_name | string | "LXDPool" | - | LVM Thin Pool to use within the Volume Group specified in `storage.lvm_vg_name`, if the default pool parameters are undesirable.
storage.lvm\_fstype | string | ext4 | - | Format LV with filesystem, for now it's value can be only ext4 (default) or xfs.
+storage.lvm\_mount\_options | string | discard | - | Mount options for LV.
storage.lvm\_volume\_size | string | 10GiB | - | Size of the logical volume
storage.zfs\_pool\_name | string | - | - | ZFS pool name
storage.zfs\_remove\_snapshots | boolean | false | storage\_zfs\_remove\_snapshots | Automatically remove any needed snapshot when attempting a container restore
diff --git a/lxd/daemon_config.go b/lxd/daemon_config.go
index ccc30d9..5af70ad 100644
--- a/lxd/daemon_config.go
+++ b/lxd/daemon_config.go
@@ -180,6 +180,7 @@ func daemonConfigInit(db *sql.DB) error {
"images.remote_cache_expiry": &daemonConfigKey{valueType: "int", defaultValue: "10", trigger: daemonConfigTriggerExpiry},
"storage.lvm_fstype": &daemonConfigKey{valueType: "string", defaultValue: "ext4", validValues: []string{"ext4", "xfs"}},
+ "storage.lvm_mount_options": &daemonConfigKey{valueType: "string", defaultValue: "discard"},
"storage.lvm_thinpool_name": &daemonConfigKey{valueType: "string", defaultValue: "LXDPool", validator: storageLVMValidateThinPoolName},
"storage.lvm_vg_name": &daemonConfigKey{valueType: "string", validator: storageLVMValidateVolumeGroupName, setter: daemonConfigSetStorage},
"storage.lvm_volume_size": &daemonConfigKey{valueType: "string", defaultValue: "10GiB"},
diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go
index 3f8fc5d..fe9fc1e 100644
--- a/lxd/storage_lvm.go
+++ b/lxd/storage_lvm.go
@@ -322,7 +322,8 @@ func (s *storageLvm) ContainerCreateFromImage(
}
}
- err = tryMount(lvpath, destPath, fstype, 0, "discard")
+ mountOptions := daemonConfig["storage.lvm_mount_options"].Get()
+ err = tryMount(lvpath, destPath, fstype, 0, mountOptions)
if err != nil {
s.ContainerDelete(container)
return fmt.Errorf("Error mounting snapshot LV: %v", err)
@@ -430,7 +431,8 @@ func (s *storageLvm) ContainerStart(container container) error {
lvpath := fmt.Sprintf("/dev/%s/%s", s.vgName, lvName)
fstype := daemonConfig["storage.lvm_fstype"].Get()
- err := tryMount(lvpath, container.Path(), fstype, 0, "discard")
+ mountOptions := daemonConfig["storage.lvm_mount_options"].Get()
+ err := tryMount(lvpath, container.Path(), fstype, 0, mountOptions)
if err != nil {
return fmt.Errorf(
"Error mounting snapshot LV path='%s': %v",
@@ -675,7 +677,8 @@ func (s *storageLvm) ContainerSnapshotStart(container container) error {
}
}
- err = tryMount(lvpath, container.Path(), fstype, 0, "discard")
+ mountOptions := daemonConfig["storage.lvm_mount_options"].Get()
+ err = tryMount(lvpath, container.Path(), fstype, 0, mountOptions)
if err != nil {
return fmt.Errorf(
"Error mounting snapshot LV path='%s': %v",
@@ -730,7 +733,8 @@ func (s *storageLvm) ImageCreate(fingerprint string) error {
}()
fstype := daemonConfig["storage.lvm_fstype"].Get()
- err = tryMount(lvpath, tempLVMountPoint, fstype, 0, "discard")
+ mountOptions := daemonConfig["storage.lvm_mount_options"].Get()
+ err = tryMount(lvpath, tempLVMountPoint, fstype, 0, mountOptions)
if err != nil {
shared.LogInfof("Error mounting image LV for unpacking: %v", err)
return fmt.Errorf("Error mounting image LV: %v", err)
From 1650380b91264a2d5ac7d7a48785f3081f0341fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 16 Sep 2016 18:19:27 -0400
Subject: [PATCH 2/2] Add API extension for lvm_mount_options
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes #2374
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
doc/api-extensions.md | 5 +++++
doc/configuration.md | 2 +-
lxd/api_1.0.go | 1 +
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/doc/api-extensions.md b/doc/api-extensions.md
index b636818..2bc8dc4 100644
--- a/doc/api-extensions.md
+++ b/doc/api-extensions.md
@@ -96,3 +96,8 @@ when being queried about disk utilization.
This effectively controls whether disk usage by snapshots should be
considered as part of the container's disk space usage.
+
+## storage\_lvm\_mount\_options
+Adds a new "storage.lvm\_mount\_options" daemon configuration option
+which defaults to "discard" and allows the user to set addition mount
+options for the filesystem used by the LVM LV.
diff --git a/doc/configuration.md b/doc/configuration.md
index 109ad18..cd5c7e6 100644
--- a/doc/configuration.md
+++ b/doc/configuration.md
@@ -31,7 +31,7 @@ core.trust\_password | string | - | -
storage.lvm\_vg\_name | string | - | - | LVM Volume Group name to be used for container and image storage. A default Thin Pool is created using 100% of the free space in the Volume Group, unless `storage.lvm_thinpool_name` is set.
storage.lvm\_thinpool\_name | string | "LXDPool" | - | LVM Thin Pool to use within the Volume Group specified in `storage.lvm_vg_name`, if the default pool parameters are undesirable.
storage.lvm\_fstype | string | ext4 | - | Format LV with filesystem, for now it's value can be only ext4 (default) or xfs.
-storage.lvm\_mount\_options | string | discard | - | Mount options for LV.
+storage.lvm\_mount\_options | string | discard | storage\_lvm\_mount\_options | Mount options for the LV filesystem
storage.lvm\_volume\_size | string | 10GiB | - | Size of the logical volume
storage.zfs\_pool\_name | string | - | - | ZFS pool name
storage.zfs\_remove\_snapshots | boolean | false | storage\_zfs\_remove\_snapshots | Automatically remove any needed snapshot when attempting a container restore
diff --git a/lxd/api_1.0.go b/lxd/api_1.0.go
index 933c06f..1fa1858 100644
--- a/lxd/api_1.0.go
+++ b/lxd/api_1.0.go
@@ -68,6 +68,7 @@ func api10Get(d *Daemon, r *http.Request) Response {
"directory_manipulation",
"container_cpu_time",
"storage_zfs_use_refquota",
+ "storage_lvm_mount_options",
},
"api_status": "stable",
More information about the lxc-devel
mailing list