Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions doc/config_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5552,6 +5552,14 @@ Note that the claim must be contained in the access token.

<!-- config group server-openfga end -->
<!-- config group storage_btrfs-common start -->
```{config:option} btrfs.create_options storage_btrfs-common
:default: "-"
:scope: "global"
:shortdesc: "Additional options to pass to `mkfs.btrfs` when creating the pool"
:type: "string"

```

```{config:option} btrfs.mount_options storage_btrfs-common
:default: "`user_subvol_rm_allowed`"
:scope: "global"
Expand Down Expand Up @@ -6200,6 +6208,14 @@ Note that the claim must be contained in the access token.

<!-- config group storage_volume_btrfs-common end -->
<!-- config group storage_volume_ceph-common start -->
```{config:option} block.create_options storage_volume_ceph-common
:condition: "block-based volume with content type `filesystem`"
:default: "same as `volume.block.create_options`"
:shortdesc: "Additional options to pass to the file system creation tool when formatting the volume"
:type: "string"

```

```{config:option} block.filesystem storage_volume_ceph-common
:condition: "block-based volume with content type `filesystem`"
:default: "same as `volume.block.filesystem`"
Expand Down Expand Up @@ -6486,6 +6502,14 @@ Note that the claim must be contained in the access token.

<!-- config group storage_volume_dir-common end -->
<!-- config group storage_volume_linstor-common start -->
```{config:option} block.create_options storage_volume_linstor-common
:condition: "block-based volume with content type `filesystem`"
:default: "same as `volume.block.create_options`"
:shortdesc: "Additional options to pass to the file system creation tool when formatting the volume"
:type: "string"

```

```{config:option} block.filesystem storage_volume_linstor-common
:condition: "block-based volume with content type `filesystem`"
:default: "same as `volume.block.filesystem`"
Expand Down Expand Up @@ -6624,6 +6648,14 @@ Note that the claim must be contained in the access token.

<!-- config group storage_volume_linstor-common end -->
<!-- config group storage_volume_lvm-common start -->
```{config:option} block.create_options storage_volume_lvm-common
:condition: "block-based volume with content type `filesystem`"
:default: "same as `volume.block.create_options`"
:shortdesc: "Additional options to pass to the file system creation tool when formatting the volume"
:type: "string"

```

```{config:option} block.filesystem storage_volume_lvm-common
:condition: "block-based volume with content type `filesystem`"
:default: "same as `volume.block.filesystem`"
Expand Down Expand Up @@ -6753,6 +6785,14 @@ Note that the claim must be contained in the access token.

<!-- config group storage_volume_lvm-common end -->
<!-- config group storage_volume_truenas-common start -->
```{config:option} block.create_options storage_volume_truenas-common
:condition: "-"
:default: "same as `volume.block.create_options`"
:shortdesc: "Additional options to pass to the file system creation tool when formatting the volume"
:type: "string"

```

```{config:option} block.filesystem storage_volume_truenas-common
:condition: "-"
:default: "same as `volume.block.filesystem`"
Expand Down Expand Up @@ -6883,6 +6923,14 @@ Note that the claim must be contained in the access token.

<!-- config group storage_volume_truenas-common end -->
<!-- config group storage_volume_zfs-common start -->
```{config:option} block.create_options storage_volume_zfs-common
:condition: "block-based volume with content type `filesystem` (`zfs.block_mode` enabled)"
:default: "same as `volume.block.create_options`"
:shortdesc: "Additional options to pass to the file system creation tool when formatting the volume"
:type: "string"

```

```{config:option} block.filesystem storage_volume_zfs-common
:condition: "block-based volume with content type `filesystem` (`zfs.block_mode` enabled)"
:default: "same as `volume.block.filesystem`"
Expand Down
54 changes: 54 additions & 0 deletions internal/server/metadata/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -6252,6 +6252,15 @@
"storage_btrfs": {
"common": {
"keys": [
{
"btrfs.create_options": {
"default": "-",
"longdesc": "",
"scope": "global",
"shortdesc": "Additional options to pass to `mkfs.btrfs` when creating the pool",
"type": "string"
}
},
{
"btrfs.mount_options": {
"default": "`user_subvol_rm_allowed`",
Expand Down Expand Up @@ -7030,6 +7039,15 @@
"storage_volume_ceph": {
"common": {
"keys": [
{
"block.create_options": {
"condition": "block-based volume with content type `filesystem`",
"default": "same as `volume.block.create_options`",
"longdesc": "",
"shortdesc": "Additional options to pass to the file system creation tool when formatting the volume",
"type": "string"
}
},
{
"block.filesystem": {
"condition": "block-based volume with content type `filesystem`",
Expand Down Expand Up @@ -7363,6 +7381,15 @@
"storage_volume_linstor": {
"common": {
"keys": [
{
"block.create_options": {
"condition": "block-based volume with content type `filesystem`",
"default": "same as `volume.block.create_options`",
"longdesc": "",
"shortdesc": "Additional options to pass to the file system creation tool when formatting the volume",
"type": "string"
}
},
{
"block.filesystem": {
"condition": "block-based volume with content type `filesystem`",
Expand Down Expand Up @@ -7522,6 +7549,15 @@
"storage_volume_lvm": {
"common": {
"keys": [
{
"block.create_options": {
"condition": "block-based volume with content type `filesystem`",
"default": "same as `volume.block.create_options`",
"longdesc": "",
"shortdesc": "Additional options to pass to the file system creation tool when formatting the volume",
"type": "string"
}
},
{
"block.filesystem": {
"condition": "block-based volume with content type `filesystem`",
Expand Down Expand Up @@ -7671,6 +7707,15 @@
"storage_volume_truenas": {
"common": {
"keys": [
{
"block.create_options": {
"condition": "-",
"default": "same as `volume.block.create_options`",
"longdesc": "",
"shortdesc": "Additional options to pass to the file system creation tool when formatting the volume",
"type": "string"
}
},
{
"block.filesystem": {
"condition": "-",
Expand Down Expand Up @@ -7821,6 +7866,15 @@
"storage_volume_zfs": {
"common": {
"keys": [
{
"block.create_options": {
"condition": "block-based volume with content type `filesystem` (`zfs.block_mode` enabled)",
"default": "same as `volume.block.create_options`",
"longdesc": "",
"shortdesc": "Additional options to pass to the file system creation tool when formatting the volume",
"type": "string"
}
},
{
"block.filesystem": {
"condition": "block-based volume with content type `filesystem` (`zfs.block_mode` enabled)",
Expand Down
13 changes: 11 additions & 2 deletions internal/server/storage/drivers/driver_btrfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (d *btrfs) Create() error {
reverter.Add(func() { _ = os.Remove(d.config["source"]) })

// Format the file.
_, err = makeFSType(d.config["source"], "btrfs", &mkfsOptions{Label: d.name})
_, err = makeFSType(d.config["source"], "btrfs", &mkfsOptions{Label: d.name, ExtraArgs: d.config["btrfs.create_options"]})
if err != nil {
return fmt.Errorf("Failed to format sparse file: %w", err)
}
Expand All @@ -172,7 +172,7 @@ func (d *btrfs) Create() error {
}

// Format the block device.
_, err := makeFSType(d.config["source"], "btrfs", &mkfsOptions{Label: d.name})
_, err := makeFSType(d.config["source"], "btrfs", &mkfsOptions{Label: d.name, ExtraArgs: d.config["btrfs.create_options"]})
if err != nil {
return fmt.Errorf("Failed to format block device: %w", err)
}
Expand Down Expand Up @@ -345,6 +345,15 @@ func (d *btrfs) Validate(config map[string]string) error {
// default: `user_subvol_rm_allowed`
// shortdesc: Mount options for block devices
"btrfs.mount_options": validate.IsAny,

// gendoc:generate(entity=storage_btrfs, group=common, key=btrfs.create_options)
//
// ---
// type: string
// scope: global
// default: -
// shortdesc: Additional options to pass to `mkfs.btrfs` when creating the pool
"btrfs.create_options": validate.IsAny,
}

return d.validatePool(config, rules, nil)
Expand Down
23 changes: 19 additions & 4 deletions internal/server/storage/drivers/driver_ceph_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ func (d *ceph) CreateVolume(vol Volume, filler *VolumeFiller, op *operations.Ope
RBDFilesystem := vol.ConfigBlockFilesystem()

if vol.contentType == ContentTypeFS {
_, err = makeFSType(devPath, RBDFilesystem, nil)
volCreateOptions := vol.ExpandedConfig("block.create_options")
_, err = makeFSType(devPath, RBDFilesystem, &mkfsOptions{ExtraArgs: volCreateOptions})
if err != nil {
return err
}
Expand Down Expand Up @@ -798,9 +799,9 @@ func (d *ceph) HasVolume(vol Volume) (bool, error) {
// FillVolumeConfig populate volume with default config.
func (d *ceph) FillVolumeConfig(vol Volume) error {
// Copy volume.* configuration options from pool.
// Exclude 'block.filesystem' and 'block.mount_options'
// as this ones are handled below in this function and depends from volume type
err := d.fillVolumeConfig(&vol, "block.filesystem", "block.mount_options")
// Exclude 'block.filesystem', 'block.mount_options', and 'block.create_options'
// as these are handled below in this function and depend on the volume type
err := d.fillVolumeConfig(&vol, "block.filesystem", "block.mount_options", "block.create_options")
if err != nil {
return err
}
Expand Down Expand Up @@ -829,6 +830,11 @@ func (d *ceph) FillVolumeConfig(vol Volume) error {
// Unchangeable volume property: Set unconditionally.
vol.config["block.mount_options"] = "discard"
}

// Inherit filesystem creation options from pool if not set.
if vol.config["block.create_options"] == "" {
vol.config["block.create_options"] = d.config["volume.block.create_options"]
}
}

return nil
Expand All @@ -854,6 +860,15 @@ func (d *ceph) commonVolumeRules() map[string]func(value string) error {
// default: same as `volume.block.mount_options`
// shortdesc: Mount options for block-backed file system volumes
"block.mount_options": validate.IsAny,

// gendoc:generate(entity=storage_volume_ceph, group=common, key=block.create_options)
//
// ---
// type: string
// condition: block-based volume with content type `filesystem`
// default: same as `volume.block.create_options`
// shortdesc: Additional options to pass to the file system creation tool when formatting the volume
"block.create_options": validate.IsAny,
}
}

Expand Down
26 changes: 21 additions & 5 deletions internal/server/storage/drivers/driver_linstor_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
// FillVolumeConfig populate volume with default config.
func (d *linstor) FillVolumeConfig(vol Volume) error {
// Copy volume.* configuration options from pool.
// Exclude 'block.filesystem' and 'block.mount_options'
// as this ones are handled below in this function and depends from volume type.
err := d.fillVolumeConfig(&vol, "block.filesystem", "block.mount_options")
// Exclude 'block.filesystem', 'block.mount_options', and 'block.create_options'
// as these are handled below in this function and depend on the volume type.
err := d.fillVolumeConfig(&vol, "block.filesystem", "block.mount_options", "block.create_options")
if err != nil {
return err
}
Expand Down Expand Up @@ -62,6 +62,11 @@ func (d *linstor) FillVolumeConfig(vol Volume) error {
// Unchangeable volume property: Set unconditionally.
vol.config["block.mount_options"] = "discard"
}

// Inherit filesystem creation options from pool if not set.
if vol.config["block.create_options"] == "" {
vol.config["block.create_options"] = d.config["volume.block.create_options"]
}
}

return nil
Expand All @@ -88,6 +93,15 @@ func (d *linstor) commonVolumeRules() map[string]func(value string) error {
// shortdesc: Mount options for block-backed file system volumes
"block.mount_options": validate.IsAny,

// gendoc:generate(entity=storage_volume_linstor, group=common, key=block.create_options)
//
// ---
// type: string
// condition: block-based volume with content type `filesystem`
// default: same as `volume.block.create_options`
// shortdesc: Additional options to pass to the file system creation tool when formatting the volume
"block.create_options": validate.IsAny,

// gendoc:generate(entity=storage_volume_linstor, group=common, key=drbd.on_no_quorum)
//
// ---
Expand Down Expand Up @@ -303,8 +317,9 @@ func (d *linstor) CreateVolume(vol Volume, filler *VolumeFiller, op *operations.
}

volFilesystem := vol.ConfigBlockFilesystem()
volCreateOptions := vol.ExpandedConfig("block.create_options")

_, err = makeFSType(devPath, volFilesystem, nil)
_, err = makeFSType(devPath, volFilesystem, &mkfsOptions{ExtraArgs: volCreateOptions})
if err != nil {
return err
}
Expand All @@ -321,7 +336,8 @@ func (d *linstor) CreateVolume(vol Volume, filler *VolumeFiller, op *operations.
}

fsVolFilesystem := fsVol.ConfigBlockFilesystem()
_, err = makeFSType(fsVolDevPath, fsVolFilesystem, nil)
fsVolCreateOptions := fsVol.ExpandedConfig("block.create_options")
_, err = makeFSType(fsVolDevPath, fsVolFilesystem, &mkfsOptions{ExtraArgs: fsVolCreateOptions})

l.Debug("Created filesystem on the associated filesystem volume", logger.Ctx{"fsVolDevPath": fsVolDevPath, "fsVolFilesystem": fsVolFilesystem})
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion internal/server/storage/drivers/driver_lvm_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,9 @@ func (d *lvm) createLogicalVolume(vgName, thinPoolName string, vol Volume, makeT
}

if vol.contentType == ContentTypeFS {
_, err = makeFSType(volDevPath, vol.ConfigBlockFilesystem(), nil)
volFilesystem := vol.ConfigBlockFilesystem()
volCreateOptions := vol.ExpandedConfig("block.create_options")
_, err = makeFSType(volDevPath, volFilesystem, &mkfsOptions{ExtraArgs: volCreateOptions})
if err != nil {
return fmt.Errorf("Error making filesystem on LVM logical volume: %w", err)
}
Expand Down
18 changes: 16 additions & 2 deletions internal/server/storage/drivers/driver_lvm_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ func (d *lvm) HasVolume(vol Volume) (bool, error) {
// FillVolumeConfig populate volume with default config.
func (d *lvm) FillVolumeConfig(vol Volume) error {
// Copy volume.* configuration options from pool.
// Exclude "block.filesystem" and "block.mount_options" as they depend on volume type (handled below).
// Exclude "block.filesystem", "block.mount_options", and "block.create_options" as they depend on volume type (handled below).
// Exclude "lvm.stripes", "lvm.stripes.size" as they only work on non-thin storage pools (handled below).
err := d.fillVolumeConfig(&vol, "block.filesystem", "block.mount_options", "lvm.stripes", "lvm.stripes.size")
err := d.fillVolumeConfig(&vol, "block.filesystem", "block.mount_options", "block.create_options", "lvm.stripes", "lvm.stripes.size")
if err != nil {
return err
}
Expand Down Expand Up @@ -330,6 +330,11 @@ func (d *lvm) FillVolumeConfig(vol Volume) error {
// Unchangeable volume property: Set unconditionally.
vol.config["block.mount_options"] = "discard"
}

// Inherit filesystem creation options from pool if not set.
if vol.config["block.create_options"] == "" {
vol.config["block.create_options"] = d.config["volume.block.create_options"]
}
}

if d.clustered && (vol.IsVMBlock() || vol.IsCustomBlock()) {
Expand Down Expand Up @@ -370,6 +375,15 @@ func (d *lvm) commonVolumeRules() map[string]func(value string) error {
// shortdesc: Mount options for block-backed file system volumes
"block.mount_options": validate.IsAny,

// gendoc:generate(entity=storage_volume_lvm, group=common, key=block.create_options)
//
// ---
// type: string
// condition: block-based volume with content type `filesystem`
// default: same as `volume.block.create_options`
// shortdesc: Additional options to pass to the file system creation tool when formatting the volume
"block.create_options": validate.IsAny,

// gendoc:generate(entity=storage_volume_lvm, group=common, key=block.filesystem)
//
// ---
Expand Down
Loading