mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
fix: check for O_DIRECT support for reads and writes (#11331)
In-case user enables O_DIRECT for reads and backend does not support it we shall proceed to turn it off instead and print a warning. This validation avoids any unexpected downtimes that users may incur.
This commit is contained in:
@@ -31,7 +31,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/minio/minio/cmd/config/storageclass"
|
||||
"github.com/minio/minio/pkg/disk"
|
||||
)
|
||||
|
||||
func TestCheckPathLength(t *testing.T) {
|
||||
@@ -128,10 +127,6 @@ func newXLStorageTestSetup() (*xlStorageDiskIDCheck, string, error) {
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
err = storage.MakeVol(context.Background(), minioMetaBucket)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
// Create a sample format.json file
|
||||
err = storage.WriteAll(context.Background(), minioMetaBucket, formatConfigFile, []byte(`{"version":"1","format":"xl","id":"592a41c2-b7cc-4130-b883-c4b5cb15965b","xl":{"version":"3","this":"da017d62-70e3-45f1-8a1a-587707e69ad1","sets":[["e07285a6-8c73-4962-89c6-047fb939f803","33b8d431-482d-4376-b63c-626d229f0a29","cff6513a-4439-4dc1-bcaa-56c9e880c352","da017d62-70e3-45f1-8a1a-587707e69ad1","9c9f21d5-1f15-4737-bce6-835faa0d9626","0a59b346-1424-4fc2-9fa2-a2e80541d0c1","7924a3dc-b69a-4971-9a2e-014966d6aebb","4d2b8dd9-4e48-444b-bdca-c89194b26042"]],"distributionAlgo":"CRCMOD"}}`))
|
||||
if err != nil {
|
||||
@@ -258,7 +253,7 @@ func TestXLStorageReadVersion(t *testing.T) {
|
||||
// create xlStorage test setup
|
||||
xlStorage, path, err := newXLStorageTestSetup()
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to create xlStorage test setup, %s", err)
|
||||
t.Fatalf("Unable to cfgreate xlStorage test setup, %s", err)
|
||||
}
|
||||
|
||||
defer os.RemoveAll(path)
|
||||
@@ -539,7 +534,7 @@ func TestXLStorageMakeVol(t *testing.T) {
|
||||
|
||||
// Initialize xlStorage storage layer for permission denied error.
|
||||
_, err = newLocalXLStorage(permDeniedDir)
|
||||
if err != nil && err != errFileAccessDenied {
|
||||
if err != nil && err != errDiskAccessDenied {
|
||||
t.Fatalf("Unable to initialize xlStorage, %s", err)
|
||||
}
|
||||
|
||||
@@ -638,7 +633,7 @@ func TestXLStorageDeleteVol(t *testing.T) {
|
||||
|
||||
// Initialize xlStorage storage layer for permission denied error.
|
||||
_, err = newLocalXLStorage(permDeniedDir)
|
||||
if err != nil && err != errFileAccessDenied {
|
||||
if err != nil && err != errDiskAccessDenied {
|
||||
t.Fatalf("Unable to initialize xlStorage, %s", err)
|
||||
}
|
||||
|
||||
@@ -890,7 +885,7 @@ func TestXLStorageListDir(t *testing.T) {
|
||||
|
||||
// Initialize xlStorage storage layer for permission denied error.
|
||||
_, err = newLocalXLStorage(permDeniedDir)
|
||||
if err != nil && err != errFileAccessDenied {
|
||||
if err != nil && err != errDiskAccessDenied {
|
||||
t.Fatalf("Unable to initialize xlStorage, %s", err)
|
||||
}
|
||||
|
||||
@@ -1014,7 +1009,7 @@ func TestXLStorageDeleteFile(t *testing.T) {
|
||||
|
||||
// Initialize xlStorage storage layer for permission denied error.
|
||||
_, err = newLocalXLStorage(permDeniedDir)
|
||||
if err != nil && err != errFileAccessDenied {
|
||||
if err != nil && err != errDiskAccessDenied {
|
||||
t.Fatalf("Unable to initialize xlStorage, %s", err)
|
||||
}
|
||||
|
||||
@@ -1221,7 +1216,7 @@ func TestXLStorageReadFile(t *testing.T) {
|
||||
|
||||
// Initialize xlStorage storage layer for permission denied error.
|
||||
_, err = newLocalXLStorage(permDeniedDir)
|
||||
if err != nil && err != errFileAccessDenied {
|
||||
if err != nil && err != errDiskAccessDenied {
|
||||
t.Fatalf("Unable to initialize xlStorage, %s", err)
|
||||
}
|
||||
|
||||
@@ -1391,7 +1386,7 @@ func TestXLStorageAppendFile(t *testing.T) {
|
||||
var xlStoragePermStorage StorageAPI
|
||||
// Initialize xlStorage storage layer for permission denied error.
|
||||
_, err = newLocalXLStorage(permDeniedDir)
|
||||
if err != nil && err != errFileAccessDenied {
|
||||
if err != nil && err != errDiskAccessDenied {
|
||||
t.Fatalf("Unable to initialize xlStorage, %s", err)
|
||||
}
|
||||
|
||||
@@ -1824,54 +1819,3 @@ func TestXLStorageVerifyFile(t *testing.T) {
|
||||
t.Fatal("expected to fail bitrot check")
|
||||
}
|
||||
}
|
||||
|
||||
// Checks for restrictions for min total disk space and inodes.
|
||||
func TestCheckDiskTotalMin(t *testing.T) {
|
||||
testCases := []struct {
|
||||
diskInfo disk.Info
|
||||
err error
|
||||
}{
|
||||
// Test 1 - when fstype is nfs.
|
||||
{
|
||||
diskInfo: disk.Info{
|
||||
Total: diskMinTotalSpace * 3,
|
||||
FSType: "NFS",
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
// Test 2 - when fstype is xfs and total inodes are less than 10k.
|
||||
{
|
||||
diskInfo: disk.Info{
|
||||
Total: diskMinTotalSpace * 3,
|
||||
FSType: "XFS",
|
||||
Files: 9999,
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
// Test 3 - when fstype is btrfs and total inodes is empty.
|
||||
{
|
||||
diskInfo: disk.Info{
|
||||
Total: diskMinTotalSpace * 3,
|
||||
FSType: "BTRFS",
|
||||
Files: 0,
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
// Test 4 - when fstype is xfs and total disk space is really small.
|
||||
{
|
||||
diskInfo: disk.Info{
|
||||
Total: diskMinTotalSpace - diskMinTotalSpace/1024,
|
||||
FSType: "XFS",
|
||||
Files: 9999,
|
||||
},
|
||||
err: errMinDiskSize,
|
||||
},
|
||||
}
|
||||
|
||||
// Validate all cases.
|
||||
for i, test := range testCases {
|
||||
if err := checkDiskMinTotal(test.diskInfo); test.err != err {
|
||||
t.Errorf("Test %d: Expected error %s, got %s", i+1, test.err, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user