add xfs support to devicemapper snapshotter
ext4 file system was supported before. This adds support for xfs as well. Containerd config file can have fs_type as an additional option with possible values as "xfs" and "ext4" for now. In future other fstype support can be added. A snapshot created from a committed snapshot inherits the file system type of the parent. Any new snapshots that has no parent is created with the file system type indicated in config. If there is no config for file system type is found, then ext4 is assumed. This allows users to use xfs as an optional file system type. Signed-off-by: Alakesh Haloi <alakeshh@amazon.com>
This commit is contained in:
@@ -47,6 +47,9 @@ type Config struct {
|
||||
|
||||
// Whether to discard blocks when removing a thin device.
|
||||
DiscardBlocks bool `toml:"discard_blocks"`
|
||||
|
||||
// Defines file system to use for snapshout device mount. Defaults to "ext4"
|
||||
FileSystemType fsType `toml:"fs_type"`
|
||||
}
|
||||
|
||||
// LoadConfig reads devmapper configuration file from disk in TOML format
|
||||
@@ -86,6 +89,10 @@ func (c *Config) parse() error {
|
||||
return errors.Wrapf(err, "failed to parse base image size: '%s'", c.BaseImageSize)
|
||||
}
|
||||
|
||||
if c.FileSystemType == "" {
|
||||
c.FileSystemType = fsTypeExt4
|
||||
}
|
||||
|
||||
c.BaseImageSizeBytes = uint64(baseImageSize)
|
||||
return nil
|
||||
}
|
||||
@@ -106,5 +113,15 @@ func (c *Config) Validate() error {
|
||||
result = multierror.Append(result, fmt.Errorf("base_image_size is required"))
|
||||
}
|
||||
|
||||
if c.FileSystemType != "" {
|
||||
switch c.FileSystemType {
|
||||
case fsTypeExt4, fsTypeXFS:
|
||||
default:
|
||||
result = multierror.Append(result, fmt.Errorf("unsupported Filesystem Type: %q", c.FileSystemType))
|
||||
}
|
||||
} else {
|
||||
result = multierror.Append(result, fmt.Errorf("filesystem type cannot be empty"))
|
||||
}
|
||||
|
||||
return result.ErrorOrNil()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user