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
72 changes: 48 additions & 24 deletions src/control/server/config/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ func TestServerConfig_MarshalUnmarshal(t *testing.T) {
}
t.Logf("config B loaded from %s: %+v", testFile, string(configBPretty))

// Config A written from uncommented file with scm_hugepages_disabled: false
// set explicitly whereas when config B yaml gets written,
// scm_hugepages_disabled is omitted (omitempty) and therefore when read is
// set to true by default. Adjust configB because of this.
if len(configB.Engines) == 2 {
for _, e := range configB.Engines {
ramCfg := e.Storage.Tiers.ScmConfigs()[0]
ramCfg.Scm.DisableHugepages = false
}
}

if diff := cmp.Diff(configA, configB, defConfigCmpOpts...); diff != "" {
t.Fatalf("(-want, +got): %s", diff)
}
Expand Down Expand Up @@ -279,7 +290,7 @@ func TestServerConfig_Constructed(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/1").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(false),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:81:00.0", "0000:82:00.0").
Expand Down Expand Up @@ -309,7 +320,7 @@ func TestServerConfig_Constructed(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/2").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(false),
storage.NewTierConfig().
WithStorageClass("file").
WithBdevDeviceList("/tmp/daos-bdev1", "/tmp/daos-bdev2").
Expand Down Expand Up @@ -443,7 +454,8 @@ func TestServerConfig_MDonSSD_Constructed(t *testing.T) {
WithStorage(
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos").
WithStorageClass("ram"),
WithStorageClass("ram").
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:81:00.0").
Expand Down Expand Up @@ -698,7 +710,7 @@ func TestServerConfig_Validation(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/1").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:81:00.0", "0000:82:00.0").
Expand All @@ -711,7 +723,7 @@ func TestServerConfig_Validation(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/2").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:91:00.0", "0000:92:00.0").
Expand All @@ -733,7 +745,7 @@ func TestServerConfig_Validation(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/1").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:81:00.0", "0000:82:00.0").
Expand All @@ -756,7 +768,7 @@ func TestServerConfig_Validation(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/2").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:91:00.0", "0000:92:00.0").
Expand Down Expand Up @@ -787,7 +799,7 @@ func TestServerConfig_Validation(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/1").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:81:00.0", "0000:82:00.0").
Expand All @@ -808,7 +820,7 @@ func TestServerConfig_Validation(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/1").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:81:00.0", "0000:82:00.0").
Expand Down Expand Up @@ -838,7 +850,7 @@ func TestServerConfig_Validation(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/0").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:80:00.0").
Expand All @@ -850,7 +862,7 @@ func TestServerConfig_Validation(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/1").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:81:00.0"),
Expand All @@ -871,7 +883,7 @@ func TestServerConfig_Validation(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/1").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:81:00.0", "0000:82:00.0").
Expand All @@ -890,7 +902,7 @@ func TestServerConfig_Validation(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/1").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:81:00.0", "0000:82:00.0").
Expand Down Expand Up @@ -934,7 +946,7 @@ func TestServerConfig_Validation(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/1").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:81:00.0"),
Expand All @@ -953,7 +965,7 @@ func TestServerConfig_Validation(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/1").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:81:00.0").
Expand Down Expand Up @@ -1139,7 +1151,7 @@ func TestServerConfig_getMinNrHugepages(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/1").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:81:00.0", "0000:82:00.0").
Expand Down Expand Up @@ -1275,7 +1287,7 @@ func TestServerConfig_SetNrHugepages(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/1").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:81:00.0", "0000:82:00.0").
Expand All @@ -1295,7 +1307,7 @@ func TestServerConfig_SetNrHugepages(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/1").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:81:00.0", "0000:82:00.0").
Expand Down Expand Up @@ -1479,7 +1491,7 @@ func TestServerConfig_SetRamdiskSize(t *testing.T) {
storage.NewTierConfig().
WithScmMountPoint("/mnt/daos/1").
WithStorageClass("ram").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("nvme").
WithBdevDeviceList("0000:81:00.0", "0000:82:00.0").
Expand Down Expand Up @@ -1735,12 +1747,24 @@ func TestServerConfig_Parsing(t *testing.T) {
return nil
},
},
"allow_thp true allows scm_hugepages_disabled false": {
inTxt: " scm_hugepages_disabled: true",
outTxt: " scm_hugepages_disabled: false",
"implicitly set scm_hugepages_disabled true": {
inTxt: " scm_hugepages_disabled: false",
outTxt: "",
expCheck: func(c *Server) error {
for _, e := range c.Engines {
if !e.Storage.Tiers.ScmConfigs()[0].Scm.DisableHugepages {
return errors.New("expecting scm hugepages to be enabled")
}
}
return nil
},
},
"explicitly set scm_hugepages_disabled true": {
inTxt: " scm_hugepages_disabled: false",
outTxt: " scm_hugepages_disabled: true",
expCheck: func(c *Server) error {
for _, e := range c.Engines {
if e.Storage.Tiers.ScmConfigs()[0].Scm.DisableHugepages {
if !e.Storage.Tiers.ScmConfigs()[0].Scm.DisableHugepages {
return errors.New("expecting scm hugepages to be enabled")
}
}
Expand Down Expand Up @@ -2012,7 +2036,7 @@ func TestServerConfig_validateMultiEngineConfig(t *testing.T) {
storage.NewTierConfig().
WithStorageClass("ram").
WithScmMountPoint("b").
WithScmHugepagesDisabled(),
WithScmHugepagesDisabled(true),
),
expErr: FaultConfigScmDiffHugeEnabled(1, 0),
},
Expand Down
3 changes: 2 additions & 1 deletion src/control/server/engine/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ func TestConfig_Constructed(t *testing.T) {
WithStorageClass("ram").
WithScmRamdiskSize(42).
WithScmMountPoint("/mnt/daostest").
WithScmDeviceList("/dev/a", "/dev/b"),
WithScmDeviceList("/dev/a", "/dev/b").
WithScmHugepagesDisabled(true),
storage.NewTierConfig().
WithStorageClass("kdev").
WithBdevDeviceCount(2).
Expand Down
27 changes: 22 additions & 5 deletions src/control/server/storage/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ func (tc *TierConfig) WithStorageClass(cls string) *TierConfig {
}

// WithScmHugepagesDisabled disables hugepages for tmpfs.
func (tc *TierConfig) WithScmHugepagesDisabled() *TierConfig {
tc.Scm.DisableHugepages = true
func (tc *TierConfig) WithScmHugepagesDisabled(b bool) *TierConfig {
tc.Scm.DisableHugepages = b
return tc
}

Expand Down Expand Up @@ -241,6 +241,26 @@ func (tc *TierConfig) WithNumaNodeIndex(idx uint) *TierConfig {
return tc
}

// UnmarshalYAML sets SCM DisableHugepages to true unless configured otherwise.
func (tc *TierConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
// Set defaults before unmarshaling
type Alias TierConfig
defaults := &Alias{}
defaults.Scm.DisableHugepages = true // Default to disabling hugepages

if err := unmarshal(defaults); err != nil {
return err
}

// For classes other than RAM, reset to zero value as setting is irrelevant.
if defaults.Class != ClassRam {
defaults.Scm.DisableHugepages = false
}

*tc = TierConfig(*defaults)
return nil
}

type TierConfigs []*TierConfig

func (tcs TierConfigs) getBdevs(nvmeOnly bool) *BdevDeviceList {
Expand Down Expand Up @@ -593,9 +613,6 @@ func (sc *ScmConfig) Validate(class Class) error {
if len(sc.DeviceList) == 0 {
return errors.New("scm_list must be set when class is dcpm")
}
if sc.DisableHugepages {
return errors.New("scm_hugepages_disabled may not be set when class is dcpm")
}
case ClassRam:
if len(sc.DeviceList) > 0 {
return errors.New("scm_list may not be set when class is ram")
Expand Down
Loading
Loading