mirror of
https://github.com/minio/minio.git
synced 2025-04-24 12:21:02 -04:00
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:
parent
1ede3967c1
commit
70e1cbda21
@ -49,6 +49,7 @@ type apiConfig struct {
|
|||||||
staleUploadsExpiry time.Duration
|
staleUploadsExpiry time.Duration
|
||||||
staleUploadsCleanupInterval time.Duration
|
staleUploadsCleanupInterval time.Duration
|
||||||
deleteCleanupInterval time.Duration
|
deleteCleanupInterval time.Duration
|
||||||
|
disableODirect bool
|
||||||
}
|
}
|
||||||
|
|
||||||
const cgroupLimitFile = "/sys/fs/cgroup/memory/memory.limit_in_bytes"
|
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.staleUploadsExpiry = cfg.StaleUploadsExpiry
|
||||||
t.staleUploadsCleanupInterval = cfg.StaleUploadsCleanupInterval
|
t.staleUploadsCleanupInterval = cfg.StaleUploadsCleanupInterval
|
||||||
t.deleteCleanupInterval = cfg.DeleteCleanupInterval
|
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 {
|
func (t *apiConfig) getListQuorum() int {
|
||||||
|
@ -1652,7 +1652,7 @@ func (s *xlStorage) ReadFileStream(ctx context.Context, volume, path string, off
|
|||||||
}
|
}
|
||||||
|
|
||||||
alignment := offset%xioutil.DirectioAlignSize == 0
|
alignment := offset%xioutil.DirectioAlignSize == 0
|
||||||
if !alignment {
|
if !alignment || globalAPIConfig.isDisableODirect() {
|
||||||
if err = disk.DisableDirectIO(file); err != nil {
|
if err = disk.DisableDirectIO(file); err != nil {
|
||||||
file.Close()
|
file.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -43,6 +43,7 @@ const (
|
|||||||
apiStaleUploadsCleanupInterval = "stale_uploads_cleanup_interval"
|
apiStaleUploadsCleanupInterval = "stale_uploads_cleanup_interval"
|
||||||
apiStaleUploadsExpiry = "stale_uploads_expiry"
|
apiStaleUploadsExpiry = "stale_uploads_expiry"
|
||||||
apiDeleteCleanupInterval = "delete_cleanup_interval"
|
apiDeleteCleanupInterval = "delete_cleanup_interval"
|
||||||
|
apiDisableODirect = "disable_odirect"
|
||||||
|
|
||||||
EnvAPIRequestsMax = "MINIO_API_REQUESTS_MAX"
|
EnvAPIRequestsMax = "MINIO_API_REQUESTS_MAX"
|
||||||
EnvAPIRequestsDeadline = "MINIO_API_REQUESTS_DEADLINE"
|
EnvAPIRequestsDeadline = "MINIO_API_REQUESTS_DEADLINE"
|
||||||
@ -59,6 +60,7 @@ const (
|
|||||||
EnvAPIStaleUploadsExpiry = "MINIO_API_STALE_UPLOADS_EXPIRY"
|
EnvAPIStaleUploadsExpiry = "MINIO_API_STALE_UPLOADS_EXPIRY"
|
||||||
EnvAPIDeleteCleanupInterval = "MINIO_API_DELETE_CLEANUP_INTERVAL"
|
EnvAPIDeleteCleanupInterval = "MINIO_API_DELETE_CLEANUP_INTERVAL"
|
||||||
EnvDeleteCleanupInterval = "MINIO_DELETE_CLEANUP_INTERVAL"
|
EnvDeleteCleanupInterval = "MINIO_DELETE_CLEANUP_INTERVAL"
|
||||||
|
EnvAPIDisableODirect = "MINIO_API_DISABLE_ODIRECT"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Deprecated key and ENVs
|
// Deprecated key and ENVs
|
||||||
@ -118,6 +120,10 @@ var (
|
|||||||
Key: apiDeleteCleanupInterval,
|
Key: apiDeleteCleanupInterval,
|
||||||
Value: "5m",
|
Value: "5m",
|
||||||
},
|
},
|
||||||
|
config.KV{
|
||||||
|
Key: apiDisableODirect,
|
||||||
|
Value: "off",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -135,6 +141,7 @@ type Config struct {
|
|||||||
StaleUploadsCleanupInterval time.Duration `json:"stale_uploads_cleanup_interval"`
|
StaleUploadsCleanupInterval time.Duration `json:"stale_uploads_cleanup_interval"`
|
||||||
StaleUploadsExpiry time.Duration `json:"stale_uploads_expiry"`
|
StaleUploadsExpiry time.Duration `json:"stale_uploads_expiry"`
|
||||||
DeleteCleanupInterval time.Duration `json:"delete_cleanup_interval"`
|
DeleteCleanupInterval time.Duration `json:"delete_cleanup_interval"`
|
||||||
|
DisableODirect bool `json:"disable_odirect"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON - Validate SS and RRS parity when unmarshalling JSON.
|
// 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
|
return cfg, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disableODirect := env.Get(EnvAPIDisableODirect, kvs.Get(apiDisableODirect)) == config.EnableOn
|
||||||
|
|
||||||
return Config{
|
return Config{
|
||||||
RequestsMax: requestsMax,
|
RequestsMax: requestsMax,
|
||||||
RequestsDeadline: requestsDeadline,
|
RequestsDeadline: requestsDeadline,
|
||||||
@ -267,5 +276,6 @@ func LookupConfig(kvs config.KVS) (cfg Config, err error) {
|
|||||||
StaleUploadsCleanupInterval: staleUploadsCleanupInterval,
|
StaleUploadsCleanupInterval: staleUploadsCleanupInterval,
|
||||||
StaleUploadsExpiry: staleUploadsExpiry,
|
StaleUploadsExpiry: staleUploadsExpiry,
|
||||||
DeleteCleanupInterval: deleteCleanupInterval,
|
DeleteCleanupInterval: deleteCleanupInterval,
|
||||||
|
DisableODirect: disableODirect,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -94,5 +94,11 @@ var (
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Type: "duration",
|
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",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user