mirror of
https://github.com/minio/minio.git
synced 2025-05-22 01:53:55 -04:00
fix: ignoring O_DIRECT in case of erasure single disk (#15734)
fixes #15733 fixes #15735
This commit is contained in:
parent
9d6fddcfdf
commit
6e84283c66
@ -261,36 +261,19 @@ func newXLStorage(ep Endpoint) (s *xlStorage, err error) {
|
|||||||
s.formatData = formatData
|
s.formatData = formatData
|
||||||
s.formatFileInfo = formatFi
|
s.formatFileInfo = formatFi
|
||||||
|
|
||||||
if len(s.formatData) == 0 { // Unformatted disk check if O_DIRECT is supported.
|
// Return an error if ODirect is not supported
|
||||||
// Check if backend is writable and supports O_DIRECT
|
// unless it is a single erasure disk mode
|
||||||
uuid := mustGetUUID()
|
if err := s.checkODirectDiskSupport(); err == nil {
|
||||||
filePath := pathJoin(s.diskPath, ".writable-check-"+uuid+".tmp")
|
|
||||||
w, err := s.openFileDirect(filePath, os.O_CREATE|os.O_WRONLY|os.O_EXCL)
|
|
||||||
if err != nil {
|
|
||||||
// relax single drive mode without O_DIRECT support
|
|
||||||
if globalIsErasureSD && errors.Is(err, errUnsupportedDisk) {
|
|
||||||
s.oDirect = false
|
|
||||||
} else {
|
|
||||||
return s, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_, err = w.Write(alignedBuf)
|
|
||||||
w.Close()
|
|
||||||
if err != nil {
|
|
||||||
if isSysErrInvalidArg(err) {
|
|
||||||
err = errUnsupportedDisk
|
|
||||||
}
|
|
||||||
// relax single drive mode without O_DIRECT support
|
|
||||||
if globalIsErasureSD && errors.Is(err, errUnsupportedDisk) {
|
|
||||||
s.oDirect = false
|
|
||||||
} else {
|
|
||||||
return s, err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
s.oDirect = true
|
s.oDirect = true
|
||||||
|
} else {
|
||||||
|
if globalIsErasureSD && errors.Is(err, errUnsupportedDisk) {
|
||||||
|
s.oDirect = false
|
||||||
|
} else {
|
||||||
|
return s, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
renameAll(filePath, pathJoin(s.diskPath, minioMetaTmpDeletedBucket, uuid))
|
|
||||||
|
|
||||||
|
if len(s.formatData) == 0 {
|
||||||
// Create all necessary bucket folders if possible.
|
// Create all necessary bucket folders if possible.
|
||||||
if err = makeFormatErasureMetaVolumes(s); err != nil {
|
if err = makeFormatErasureMetaVolumes(s); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -304,7 +287,6 @@ func newXLStorage(ep Endpoint) (s *xlStorage, err error) {
|
|||||||
s.diskID = format.Erasure.This
|
s.diskID = format.Erasure.This
|
||||||
s.formatLastCheck = time.Now()
|
s.formatLastCheck = time.Now()
|
||||||
s.formatLegacy = format.Erasure.DistributionAlgo == formatErasureVersionV2DistributionAlgoV1
|
s.formatLegacy = format.Erasure.DistributionAlgo == formatErasureVersionV2DistributionAlgoV1
|
||||||
s.oDirect = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Success.
|
// Success.
|
||||||
@ -388,6 +370,29 @@ func (s *xlStorage) Healing() *healingTracker {
|
|||||||
return &h
|
return &h
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// checkODirectDiskSupport asks the disk to write some data
|
||||||
|
// with O_DIRECT support, return an error if any and return
|
||||||
|
// errUnsupportedDisk if there is no O_DIRECT support
|
||||||
|
func (s *xlStorage) checkODirectDiskSupport() error {
|
||||||
|
// Check if backend is writable and supports O_DIRECT
|
||||||
|
uuid := mustGetUUID()
|
||||||
|
filePath := pathJoin(s.diskPath, ".writable-check-"+uuid+".tmp")
|
||||||
|
defer renameAll(filePath, pathJoin(s.diskPath, minioMetaTmpDeletedBucket, uuid))
|
||||||
|
|
||||||
|
w, err := s.openFileDirect(filePath, os.O_CREATE|os.O_WRONLY|os.O_EXCL)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = w.Write(alignedBuf)
|
||||||
|
w.Close()
|
||||||
|
if err != nil {
|
||||||
|
if isSysErrInvalidArg(err) {
|
||||||
|
err = errUnsupportedDisk
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// readsMetadata and returns disk mTime information for xl.meta
|
// readsMetadata and returns disk mTime information for xl.meta
|
||||||
func (s *xlStorage) readMetadataWithDMTime(ctx context.Context, itemPath string) ([]byte, time.Time, error) {
|
func (s *xlStorage) readMetadataWithDMTime(ctx context.Context, itemPath string) ([]byte, time.Time, error) {
|
||||||
if contextCanceled(ctx) {
|
if contextCanceled(ctx) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user