[lxc-devel] [lxd/master] new config option, storage.lvm_mount_options
nobuto-m on Github
lxc-bot at linuxcontainers.org
Wed Sep 14 11:13:17 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 430 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160914/0a71fffd/attachment.bin>
-------------- next part --------------
From 024da67846ef783b202cc23d7e81a83376ef218a 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] 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 52e6a3a..c64a2a2 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_mount_options storage.lvm_volume_size storage.zfs_pool_name \
storage.zfs_remove_snapshots images.compression_algorithm \
images.remot_cache_expiry images.auto_update_interval \
images.auto_update_cached"
diff --git a/doc/configuration.md b/doc/configuration.md
index 7665f2c..5e12411 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 82d6726..dce6fe9 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 2799032..21641d5 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.Logf("Error mounting image LV for unpacking: %v", err)
return fmt.Errorf("Error mounting image LV: %v", err)
More information about the lxc-devel
mailing list