allow locks with object affinity to spread across pools (#16312)

This commit is contained in:
Harshavardhana 2022-12-23 20:55:45 -08:00 committed by GitHub
parent acc9c033ed
commit 5b8fe2e89a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 1 deletions

View File

@ -32,6 +32,7 @@ import (
"time"
"github.com/dustin/go-humanize"
"github.com/google/uuid"
"github.com/minio/madmin-go/v2"
"github.com/minio/minio-go/v7/pkg/s3utils"
"github.com/minio/minio-go/v7/pkg/set"
@ -50,6 +51,9 @@ type erasureServerPools struct {
rebalMu sync.RWMutex
rebalMeta *rebalanceMeta
deploymentID [16]byte
distributionAlgo string
serverPools []*erasureSets
// Shut down async operations
@ -124,6 +128,14 @@ func newErasureServerPools(ctx context.Context, endpointServerPools EndpointServ
if err != nil {
return nil, err
}
if deploymentID != "" && bytes.Equal(z.deploymentID[:], []byte{}) {
z.deploymentID = uuid.MustParse(deploymentID)
}
if distributionAlgo != "" && z.distributionAlgo == "" {
z.distributionAlgo = distributionAlgo
}
}
z.decommissionCancelers = make([]context.CancelFunc, len(z.serverPools))
@ -154,7 +166,11 @@ func newErasureServerPools(ctx context.Context, endpointServerPools EndpointServ
}
func (z *erasureServerPools) NewNSLock(bucket string, objects ...string) RWLocker {
return z.serverPools[0].NewNSLock(bucket, objects...)
poolID := hashKey(z.distributionAlgo, "", len(z.serverPools), z.deploymentID)
if len(objects) >= 1 {
poolID = hashKey(z.distributionAlgo, objects[0], len(z.serverPools), z.deploymentID)
}
return z.serverPools[poolID].NewNSLock(bucket, objects...)
}
// GetDisksID will return disks by their ID.