mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
fix: speed up drive mux registration (#12319)
in setups with lots of drives the server startup is slow, initialize all local drives in parallel before registering with muxer. this speeds up when there are multiple pools and large collection of drives.
This commit is contained in:
parent
bb7fbcdc09
commit
4f5d75f22b
@ -31,6 +31,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tinylib/msgp/msgp"
|
"github.com/tinylib/msgp/msgp"
|
||||||
@ -1003,18 +1004,39 @@ func logFatalErrs(err error, endpoint Endpoint, exit bool) {
|
|||||||
|
|
||||||
// registerStorageRPCRouter - register storage rpc router.
|
// registerStorageRPCRouter - register storage rpc router.
|
||||||
func registerStorageRESTHandlers(router *mux.Router, endpointServerPools EndpointServerPools) {
|
func registerStorageRESTHandlers(router *mux.Router, endpointServerPools EndpointServerPools) {
|
||||||
for _, ep := range endpointServerPools {
|
storageDisks := make([][]*xlStorage, len(endpointServerPools))
|
||||||
for _, endpoint := range ep.Endpoints {
|
for poolIdx, ep := range endpointServerPools {
|
||||||
|
storageDisks[poolIdx] = make([]*xlStorage, len(ep.Endpoints))
|
||||||
|
}
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
for poolIdx, ep := range endpointServerPools {
|
||||||
|
for setIdx, endpoint := range ep.Endpoints {
|
||||||
if !endpoint.IsLocal {
|
if !endpoint.IsLocal {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
storage, err := newXLStorage(endpoint)
|
wg.Add(1)
|
||||||
if err != nil {
|
go func(poolIdx, setIdx int, endpoint Endpoint) {
|
||||||
// if supported errors don't fail, we proceed to
|
defer wg.Done()
|
||||||
// printing message and moving forward.
|
var err error
|
||||||
logFatalErrs(err, endpoint, false)
|
storageDisks[poolIdx][setIdx], err = newXLStorage(endpoint)
|
||||||
|
if err != nil {
|
||||||
|
// if supported errors don't fail, we proceed to
|
||||||
|
// printing message and moving forward.
|
||||||
|
logFatalErrs(err, endpoint, false)
|
||||||
|
}
|
||||||
|
}(poolIdx, setIdx, endpoint)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
|
for _, setDisks := range storageDisks {
|
||||||
|
for _, storage := range setDisks {
|
||||||
|
if storage == nil {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endpoint := storage.Endpoint()
|
||||||
|
|
||||||
server := &storageRESTServer{storage: storage}
|
server := &storageRESTServer{storage: storage}
|
||||||
|
|
||||||
subrouter := router.PathPrefix(path.Join(storageRESTPrefix, endpoint.Path)).Subrouter()
|
subrouter := router.PathPrefix(path.Join(storageRESTPrefix, endpoint.Path)).Subrouter()
|
||||||
|
Loading…
Reference in New Issue
Block a user