allow disabling O_DIRECT in certain environments for reads (#14115)

repeated reads on single large objects in HPC like
workloads, need the following option to disable
O_DIRECT for a more effective usage of the kernel
page-cache.

However this optional should be used in very specific
situations only, and shouldn't be enabled on all
servers.

NVMe servers benefit always from keeping O_DIRECT on.
This commit is contained in:
Harshavardhana 2022-01-17 08:34:14 -08:00 committed by GitHub
parent 1ede3967c1
commit 70e1cbda21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 1 deletions

View file

@ -49,6 +49,7 @@ type apiConfig struct {
staleUploadsExpiry time.Duration
staleUploadsCleanupInterval time.Duration
deleteCleanupInterval time.Duration
disableODirect bool
}
const cgroupLimitFile = "/sys/fs/cgroup/memory/memory.limit_in_bytes"
@ -150,6 +151,14 @@ func (t *apiConfig) init(cfg api.Config, setDriveCounts []int) {
t.staleUploadsExpiry = cfg.StaleUploadsExpiry
t.staleUploadsCleanupInterval = cfg.StaleUploadsCleanupInterval
t.deleteCleanupInterval = cfg.DeleteCleanupInterval
t.disableODirect = cfg.DisableODirect
}
func (t *apiConfig) isDisableODirect() bool {
t.mu.RLock()
defer t.mu.RUnlock()
return t.disableODirect
}
func (t *apiConfig) getListQuorum() int {

View file

@ -1652,7 +1652,7 @@ func (s *xlStorage) ReadFileStream(ctx context.Context, volume, path string, off
}
alignment := offset%xioutil.DirectioAlignSize == 0
if !alignment {
if !alignment || globalAPIConfig.isDisableODirect() {
if err = disk.DisableDirectIO(file); err != nil {
file.Close()
return nil, err

View file

@ -43,6 +43,7 @@ const (
apiStaleUploadsCleanupInterval = "stale_uploads_cleanup_interval"
apiStaleUploadsExpiry = "stale_uploads_expiry"
apiDeleteCleanupInterval = "delete_cleanup_interval"
apiDisableODirect = "disable_odirect"
EnvAPIRequestsMax = "MINIO_API_REQUESTS_MAX"
EnvAPIRequestsDeadline = "MINIO_API_REQUESTS_DEADLINE"
@ -59,6 +60,7 @@ const (
EnvAPIStaleUploadsExpiry = "MINIO_API_STALE_UPLOADS_EXPIRY"
EnvAPIDeleteCleanupInterval = "MINIO_API_DELETE_CLEANUP_INTERVAL"
EnvDeleteCleanupInterval = "MINIO_DELETE_CLEANUP_INTERVAL"
EnvAPIDisableODirect = "MINIO_API_DISABLE_ODIRECT"
)
// Deprecated key and ENVs
@ -118,6 +120,10 @@ var (
Key: apiDeleteCleanupInterval,
Value: "5m",
},
config.KV{
Key: apiDisableODirect,
Value: "off",
},
}
)
@ -135,6 +141,7 @@ type Config struct {
StaleUploadsCleanupInterval time.Duration `json:"stale_uploads_cleanup_interval"`
StaleUploadsExpiry time.Duration `json:"stale_uploads_expiry"`
DeleteCleanupInterval time.Duration `json:"delete_cleanup_interval"`
DisableODirect bool `json:"disable_odirect"`
}
// UnmarshalJSON - Validate SS and RRS parity when unmarshalling JSON.
@ -254,6 +261,8 @@ func LookupConfig(kvs config.KVS) (cfg Config, err error) {
return cfg, err
}
disableODirect := env.Get(EnvAPIDisableODirect, kvs.Get(apiDisableODirect)) == config.EnableOn
return Config{
RequestsMax: requestsMax,
RequestsDeadline: requestsDeadline,
@ -267,5 +276,6 @@ func LookupConfig(kvs config.KVS) (cfg Config, err error) {
StaleUploadsCleanupInterval: staleUploadsCleanupInterval,
StaleUploadsExpiry: staleUploadsExpiry,
DeleteCleanupInterval: deleteCleanupInterval,
DisableODirect: disableODirect,
}, nil
}

View file

@ -94,5 +94,11 @@ var (
Optional: true,
Type: "duration",
},
config.HelpKV{
Key: apiDisableODirect,
Description: "set to disable O_DIRECT for reads under special conditions. NOTE: it is not recommended to disable O_DIRECT without prior testing.",
Optional: true,
Type: "boolean",
},
}
)