pick disks which are common maximally used (#10600)

further optimization to ensure that good disks
are always used for listing, other than healing
we only use disks that are maximally used.
master
Harshavardhana 4 years ago committed by GitHub
parent 799758e54f
commit 2b4eb87d77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      cmd/disk-cache-backend.go
  2. 17
      cmd/erasure-common.go
  3. 8
      cmd/erasure-zones.go
  4. 3
      cmd/fs-v1.go
  5. 16
      cmd/server-main.go
  6. 2
      cmd/xl-storage.go
  7. 4
      pkg/disk/disk.go
  8. 5
      pkg/disk/stat_bsd.go
  9. 1
      pkg/disk/stat_linux.go
  10. 1
      pkg/disk/stat_linux_32bit.go
  11. 1
      pkg/disk/stat_linux_s390x.go
  12. 6
      pkg/disk/stat_netbsd.go
  13. 5
      pkg/disk/stat_openbsd.go
  14. 6
      pkg/disk/stat_solaris.go
  15. 5
      pkg/disk/stat_windows.go

@ -194,7 +194,7 @@ func (c *diskCache) diskUsageLow() bool {
logger.LogIf(ctx, err) logger.LogIf(ctx, err)
return false return false
} }
usedPercent := (di.Total - di.Free) * 100 / di.Total usedPercent := (di.Used / di.Total) * 100
low := int(usedPercent) < gcStopPct low := int(usedPercent) < gcStopPct
atomic.StoreUint64(&c.stats.UsagePercent, usedPercent) atomic.StoreUint64(&c.stats.UsagePercent, usedPercent)
if low { if low {
@ -218,7 +218,7 @@ func (c *diskCache) diskSpaceAvailable(size int64) bool {
logger.Info("diskCache: Received 0 total disk size") logger.Info("diskCache: Received 0 total disk size")
return false return false
} }
usedPercent := float64(di.Total-di.Free) * 100 / float64(di.Total) usedPercent := float64(di.Used) * 100 / float64(di.Total)
if usedPercent >= float64(gcTriggerPct) { if usedPercent >= float64(gcTriggerPct) {
atomic.StoreInt32(&c.stats.UsageState, 1) atomic.StoreInt32(&c.stats.UsageState, 1)
c.queueGC() c.queueGC()
@ -226,7 +226,7 @@ func (c *diskCache) diskSpaceAvailable(size int64) bool {
atomic.StoreUint64(&c.stats.UsagePercent, uint64(usedPercent)) atomic.StoreUint64(&c.stats.UsagePercent, uint64(usedPercent))
// Recalculate percentage with provided size added. // Recalculate percentage with provided size added.
usedPercent = float64(di.Total-di.Free+uint64(size)) * 100 / float64(di.Total) usedPercent = float64(di.Used+uint64(size)) * 100 / float64(di.Total)
return usedPercent < float64(c.quotaPct) return usedPercent < float64(c.quotaPct)
} }

@ -59,7 +59,7 @@ func (er erasureObjects) getLoadBalancedDisks() []StorageAPI {
var wg sync.WaitGroup var wg sync.WaitGroup
var mu sync.Mutex var mu sync.Mutex
var newDisks []StorageAPI var newDisks = map[uint64][]StorageAPI{}
// Based on the random shuffling return back randomized disks. // Based on the random shuffling return back randomized disks.
for _, i := range hashOrder(UTCNow().String(), len(disks)) { for _, i := range hashOrder(UTCNow().String(), len(disks)) {
i := i i := i
@ -79,13 +79,24 @@ func (er erasureObjects) getLoadBalancedDisks() []StorageAPI {
// - Future: skip busy disks // - Future: skip busy disks
return return
} }
mu.Lock() mu.Lock()
newDisks = append(newDisks, disks[i-1]) // Capture disks usage wise
newDisks[di.Used] = append(newDisks[di.Used], disks[i-1])
mu.Unlock() mu.Unlock()
}() }()
} }
wg.Wait() wg.Wait()
return newDisks
var max uint64
for k := range newDisks {
if k > max {
max = k
}
}
// Return disks which have maximum disk usage common.
return newDisks[max]
} }
// This function does the following check, suppose // This function does the following check, suppose

@ -662,7 +662,7 @@ func (z *erasureZones) listObjectsNonSlash(ctx context.Context, bucket, prefix,
for _, zone := range z.zones { for _, zone := range z.zones {
zonesEntryChs = append(zonesEntryChs, zonesEntryChs = append(zonesEntryChs,
zone.startMergeWalksN(ctx, bucket, prefix, "", true, endWalkCh, zone.listTolerancePerSet, false)) zone.startMergeWalksN(ctx, bucket, prefix, "", true, endWalkCh, zone.listTolerancePerSet, false))
zonesListTolerancePerSet = append(zonesListTolerancePerSet, zone.listTolerancePerSet-1) zonesListTolerancePerSet = append(zonesListTolerancePerSet, zone.listTolerancePerSet-2)
} }
var objInfos []ObjectInfo var objInfos []ObjectInfo
@ -784,7 +784,7 @@ func (z *erasureZones) listObjectsSplunk(ctx context.Context, bucket, prefix, ma
} }
zonesEntryChs = append(zonesEntryChs, entryChs) zonesEntryChs = append(zonesEntryChs, entryChs)
zonesEndWalkCh = append(zonesEndWalkCh, endWalkCh) zonesEndWalkCh = append(zonesEndWalkCh, endWalkCh)
zonesListTolerancePerSet = append(zonesListTolerancePerSet, zone.listTolerancePerSet-1) zonesListTolerancePerSet = append(zonesListTolerancePerSet, zone.listTolerancePerSet-2)
} }
entries := mergeZonesEntriesCh(zonesEntryChs, maxKeys, zonesListTolerancePerSet) entries := mergeZonesEntriesCh(zonesEntryChs, maxKeys, zonesListTolerancePerSet)
@ -876,7 +876,7 @@ func (z *erasureZones) listObjects(ctx context.Context, bucket, prefix, marker,
} }
zonesEntryChs = append(zonesEntryChs, entryChs) zonesEntryChs = append(zonesEntryChs, entryChs)
zonesEndWalkCh = append(zonesEndWalkCh, endWalkCh) zonesEndWalkCh = append(zonesEndWalkCh, endWalkCh)
zonesListTolerancePerSet = append(zonesListTolerancePerSet, zone.listTolerancePerSet-1) zonesListTolerancePerSet = append(zonesListTolerancePerSet, zone.listTolerancePerSet-2)
} }
entries := mergeZonesEntriesCh(zonesEntryChs, maxKeys, zonesListTolerancePerSet) entries := mergeZonesEntriesCh(zonesEntryChs, maxKeys, zonesListTolerancePerSet)
@ -1278,7 +1278,7 @@ func (z *erasureZones) listObjectVersions(ctx context.Context, bucket, prefix, m
} }
zonesEntryChs = append(zonesEntryChs, entryChs) zonesEntryChs = append(zonesEntryChs, entryChs)
zonesEndWalkCh = append(zonesEndWalkCh, endWalkCh) zonesEndWalkCh = append(zonesEndWalkCh, endWalkCh)
zonesListTolerancePerSet = append(zonesListTolerancePerSet, zone.listTolerancePerSet-1) zonesListTolerancePerSet = append(zonesListTolerancePerSet, zone.listTolerancePerSet-2)
} }
entries := mergeZonesEntriesVersionsCh(zonesEntryChs, maxKeys, zonesListTolerancePerSet) entries := mergeZonesEntriesVersionsCh(zonesEntryChs, maxKeys, zonesListTolerancePerSet)

@ -216,12 +216,11 @@ func (fs *FSObjects) StorageInfo(ctx context.Context, _ bool) (StorageInfo, []er
if err != nil { if err != nil {
return StorageInfo{}, []error{err} return StorageInfo{}, []error{err}
} }
used := di.Total - di.Free
storageInfo := StorageInfo{ storageInfo := StorageInfo{
Disks: []madmin.Disk{ Disks: []madmin.Disk{
{ {
TotalSpace: di.Total, TotalSpace: di.Total,
UsedSpace: used, UsedSpace: di.Used,
AvailableSpace: di.Free, AvailableSpace: di.Free,
DrivePath: fs.fsPath, DrivePath: fs.fsPath,
}, },

@ -319,6 +319,22 @@ func initAllSubsystems(ctx context.Context, newObject ObjectLayer) (err error) {
if err != nil { if err != nil {
return fmt.Errorf("Unable to list buckets to heal: %w", err) return fmt.Errorf("Unable to list buckets to heal: %w", err)
} }
rquorum := InsufficientReadQuorum{}
wquorum := InsufficientWriteQuorum{}
for _, bucket := range buckets {
if err = newObject.MakeBucketWithLocation(ctx, bucket.Name, BucketOptions{}); err != nil {
if errors.As(err, &wquorum) || errors.As(err, &rquorum) {
// Return the error upwards for the caller to retry.
return fmt.Errorf("Unable to heal bucket: %w", err)
}
if _, ok := err.(BucketExists); !ok {
// ignore any other error and log for investigation.
logger.LogIf(ctx, err)
continue
}
// Bucket already exists, nothing that needs to be done.
}
}
} else { } else {
buckets, err = newObject.ListBuckets(ctx) buckets, err = newObject.ListBuckets(ctx)
if err != nil { if err != nil {

@ -479,7 +479,7 @@ func (s *xlStorage) DiskInfo(context.Context) (info DiskInfo, err error) {
} }
dcinfo.Total = di.Total dcinfo.Total = di.Total
dcinfo.Free = di.Free dcinfo.Free = di.Free
dcinfo.Used = di.Total - di.Free dcinfo.Used = di.Used
dcinfo.FSType = di.FSType dcinfo.FSType = di.FSType
diskID, err := s.GetDiskID() diskID, err := s.GetDiskID()

@ -25,10 +25,8 @@ package disk
type Info struct { type Info struct {
Total uint64 Total uint64
Free uint64 Free uint64
Used uint64
Files uint64 Files uint64
Ffree uint64 Ffree uint64
FSType string FSType string
// Usage is calculated per tenant.
Usage uint64
} }

@ -19,6 +19,7 @@
package disk package disk
import ( import (
"fmt"
"syscall" "syscall"
) )
@ -37,5 +38,9 @@ func GetInfo(path string) (info Info, err error) {
Ffree: uint64(s.Ffree), Ffree: uint64(s.Ffree),
FSType: getFSType(s.Fstypename[:]), FSType: getFSType(s.Fstypename[:]),
} }
if info.Free > info.Total {
return info, fmt.Errorf("detected free space (%d) > total disk space (%d), fs corruption at (%s). please run 'fsck'", info.Free, info.Total, path)
}
info.Used = info.Total - info.Free
return info, nil return info, nil
} }

@ -45,5 +45,6 @@ func GetInfo(path string) (info Info, err error) {
if info.Free > info.Total { if info.Free > info.Total {
return info, fmt.Errorf("detected free space (%d) > total disk space (%d), fs corruption at (%s). please run 'fsck'", info.Free, info.Total, path) return info, fmt.Errorf("detected free space (%d) > total disk space (%d), fs corruption at (%s). please run 'fsck'", info.Free, info.Total, path)
} }
info.Used = info.Total - info.Free
return info, nil return info, nil
} }

@ -76,5 +76,6 @@ func GetInfo(path string) (info Info, err error) {
if info.Free > info.Total { if info.Free > info.Total {
return info, fmt.Errorf("detected free space (%d) > total disk space (%d), fs corruption at (%s). please run 'fsck'", info.Free, info.Total, path) return info, fmt.Errorf("detected free space (%d) > total disk space (%d), fs corruption at (%s). please run 'fsck'", info.Free, info.Total, path)
} }
info.Used = info.Total - info.Free
return info, nil return info, nil
} }

@ -76,5 +76,6 @@ func GetInfo(path string) (info Info, err error) {
if info.Free > info.Total { if info.Free > info.Total {
return info, fmt.Errorf("detected free space (%d) > total disk space (%d), fs corruption at (%s). please run 'fsck'", info.Free, info.Total, path) return info, fmt.Errorf("detected free space (%d) > total disk space (%d), fs corruption at (%s). please run 'fsck'", info.Free, info.Total, path)
} }
info.Used = info.Total - info.Free
return info, nil return info, nil
} }

@ -19,6 +19,8 @@
package disk package disk
import ( import (
"fmt"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
@ -36,5 +38,9 @@ func GetInfo(path string) (info Info, err error) {
Ffree: uint64(s.Ffree), Ffree: uint64(s.Ffree),
FSType: string(s.Fstypename[:]), FSType: string(s.Fstypename[:]),
} }
if info.Free > info.Total {
return info, fmt.Errorf("detected free space (%d) > total disk space (%d), fs corruption at (%s). please run 'fsck'", info.Free, info.Total, path)
}
info.Used = info.Total - info.Free
return info, nil return info, nil
} }

@ -19,6 +19,7 @@
package disk package disk
import ( import (
"fmt"
"syscall" "syscall"
) )
@ -37,5 +38,9 @@ func GetInfo(path string) (info Info, err error) {
Ffree: uint64(s.F_ffree), Ffree: uint64(s.F_ffree),
FSType: getFSType(s.F_fstypename[:]), FSType: getFSType(s.F_fstypename[:]),
} }
if info.Free > info.Total {
return info, fmt.Errorf("detected free space (%d) > total disk space (%d), fs corruption at (%s). please run 'fsck'", info.Free, info.Total, path)
}
info.Used = info.Total - info.Free
return info, nil return info, nil
} }

@ -19,6 +19,8 @@
package disk package disk
import ( import (
"fmt"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
@ -36,5 +38,9 @@ func GetInfo(path string) (info Info, err error) {
Ffree: uint64(s.Ffree), Ffree: uint64(s.Ffree),
FSType: getFSType(s.Fstr[:]), FSType: getFSType(s.Fstr[:]),
} }
if info.Free > info.Total {
return info, fmt.Errorf("detected free space (%d) > total disk space (%d), fs corruption at (%s). please run 'fsck'", info.Free, info.Total, path)
}
info.Used = info.Total - info.Free
return info, nil return info, nil
} }

@ -19,6 +19,7 @@
package disk package disk
import ( import (
"fmt"
"os" "os"
"syscall" "syscall"
"unsafe" "unsafe"
@ -90,5 +91,9 @@ func GetInfo(path string) (info Info, err error) {
info.Files = uint64(lpTotalNumberOfClusters) info.Files = uint64(lpTotalNumberOfClusters)
info.Ffree = uint64(lpNumberOfFreeClusters) info.Ffree = uint64(lpNumberOfFreeClusters)
if info.Free > info.Total {
return info, fmt.Errorf("detected free space (%d) > total disk space (%d), fs corruption at (%s). please run 'fsck'", info.Free, info.Total, path)
}
info.Used = info.Total - info.Free
return info, nil return info, nil
} }

Loading…
Cancel
Save