@ -34,11 +34,12 @@ import (
// OfflineDisk represents an unavailable disk.
// OfflineDisk represents an unavailable disk.
var OfflineDisk StorageAPI // zero value is nil
var OfflineDisk StorageAPI // zero value is nil
// partialUpload is a successful upload of an object
// partialOperation is a successful upload/delete of an object
// but not written in all disks (having quorum)
// but not written in all disks (having quorum)
type partialUpload struct {
type partialOperation struct {
bucket string
bucket string
object string
object string
versionID string
failedSet int
failedSet int
}
}
@ -62,7 +63,7 @@ type erasureObjects struct {
// Byte pools used for temporary i/o buffers.
// Byte pools used for temporary i/o buffers.
bp * bpool . BytePoolCap
bp * bpool . BytePoolCap
mrfUploadCh chan partialUpload
mrfOpCh chan partialOperation
}
}
// NewNSLock - initialize a new namespace RWLocker instance.
// NewNSLock - initialize a new namespace RWLocker instance.
@ -87,21 +88,17 @@ func (d byDiskTotal) Less(i, j int) bool {
}
}
// getDisksInfo - fetch disks info across all other storage API.
// getDisksInfo - fetch disks info across all other storage API.
func getDisksInfo ( disks [ ] StorageAPI , local bool ) ( disksInfo [ ] DiskInfo , errs [ ] error , onlineDisks , offlineDisks madmin . BackendDisks ) {
func getDisksInfo ( disks [ ] StorageAPI , endpoints [ ] string ) ( disksInfo [ ] DiskInfo , errs [ ] error , onlineDisks , offlineDisks madmin . BackendDisks ) {
disksInfo = make ( [ ] DiskInfo , len ( disks ) )
disksInfo = make ( [ ] DiskInfo , len ( disks ) )
onlineDisks = make ( madmin . BackendDisks )
onlineDisks = make ( madmin . BackendDisks )
offlineDisks = make ( madmin . BackendDisks )
offlineDisks = make ( madmin . BackendDisks )
for _ , disk := range disks {
for _ , ep := range endpoints {
if disk == OfflineDisk {
if _ , ok := offlineDisks [ ep ] ; ! ok {
continue
offlineDisks [ ep ] = 0
}
peerAddr := disk . Hostname ( )
if _ , ok := offlineDisks [ peerAddr ] ; ! ok {
offlineDisks [ peerAddr ] = 0
}
}
if _ , ok := onlineDisks [ peerAddr ] ; ! ok {
if _ , ok := onlineDisks [ ep ] ; ! ok {
onlineDisks [ peerAddr ] = 0
onlineDisks [ ep ] = 0
}
}
}
}
@ -130,36 +127,12 @@ func getDisksInfo(disks []StorageAPI, local bool) (disksInfo []DiskInfo, errs []
errs = g . Wait ( )
errs = g . Wait ( )
// Wait for the routines.
// Wait for the routines.
for i , diskInfoErr := range errs {
for i , diskInfoErr := range errs {
if disks [ i ] == OfflineDisk {
ep := endpoints [ i ]
continue
}
if diskInfoErr != nil {
if diskInfoErr != nil {
offlineDisks [ disks [ i ] . Hostname ( ) ] ++
offlineDisks [ ep ] ++
continue
}
onlineDisks [ disks [ i ] . Hostname ( ) ] ++
}
// Iterate over the passed endpoints arguments and check
// if there are still disks missing from the offline/online lists
// and update them accordingly.
missingOfflineDisks := make ( map [ string ] int )
for _ , zone := range globalEndpoints {
for _ , endpoint := range zone . Endpoints {
// if local is set and endpoint is not local
// we are not interested in remote disks.
if local && ! endpoint . IsLocal {
continue
continue
}
}
onlineDisks [ ep ] ++
if _ , ok := offlineDisks [ endpoint . Host ] ; ! ok {
missingOfflineDisks [ endpoint . Host ] ++
}
}
}
for missingDisk , n := range missingOfflineDisks {
onlineDisks [ missingDisk ] = 0
offlineDisks [ missingDisk ] = n
}
}
// Success.
// Success.
@ -167,8 +140,8 @@ func getDisksInfo(disks []StorageAPI, local bool) (disksInfo []DiskInfo, errs []
}
}
// Get an aggregated storage info across all disks.
// Get an aggregated storage info across all disks.
func getStorageInfo ( disks [ ] StorageAPI , local bool ) ( StorageInfo , [ ] error ) {
func getStorageInfo ( disks [ ] StorageAPI , endpoints [ ] string ) ( StorageInfo , [ ] error ) {
disksInfo , errs , onlineDisks , offlineDisks := getDisksInfo ( disks , local )
disksInfo , errs , onlineDisks , offlineDisks := getDisksInfo ( disks , endpoints )
// Sort so that the first element is the smallest.
// Sort so that the first element is the smallest.
sort . Sort ( byDiskTotal ( disksInfo ) )
sort . Sort ( byDiskTotal ( disksInfo ) )
@ -203,19 +176,23 @@ func getStorageInfo(disks []StorageAPI, local bool) (StorageInfo, []error) {
// StorageInfo - returns underlying storage statistics.
// StorageInfo - returns underlying storage statistics.
func ( er erasureObjects ) StorageInfo ( ctx context . Context , local bool ) ( StorageInfo , [ ] error ) {
func ( er erasureObjects ) StorageInfo ( ctx context . Context , local bool ) ( StorageInfo , [ ] error ) {
disks := er . getDisks ( )
disks := er . getDisks ( )
endpoints := er . getEndpoints ( )
if local {
if local {
var localDisks [ ] StorageAPI
var localDisks [ ] StorageAPI
for _ , disk := range disks {
var localEndpoints [ ] string
for i , disk := range disks {
if disk != nil {
if disk != nil {
if disk . IsLocal ( ) {
if disk . IsLocal ( ) {
// Append this local disk since local flag is true
// Append this local disk since local flag is true
localDisks = append ( localDisks , disk )
localDisks = append ( localDisks , disk )
localEndpoints = append ( localEndpoints , endpoints [ i ] )
}
}
}
}
}
}
disks = localDisks
disks = localDisks
endpoints = localEndpoints
}
}
return getStorageInfo ( disks , local )
return getStorageInfo ( disks , endpoints )
}
}
// GetMetrics - is not implemented and shouldn't be called.
// GetMetrics - is not implemented and shouldn't be called.