Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cmd/batch-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1771,22 +1771,22 @@ func (a adminAPIHandlers) StartBatchJob(w http.ResponseWriter, r *http.Request)
// Fill with default values
if job.Replicate != nil {
if job.Replicate.Source.Snowball.Disable == nil {
job.Replicate.Source.Snowball.Disable = ptr(false)
job.Replicate.Source.Snowball.Disable = new(false)
}
if job.Replicate.Source.Snowball.Batch == nil {
job.Replicate.Source.Snowball.Batch = ptr(100)
job.Replicate.Source.Snowball.Batch = new(100)
}
if job.Replicate.Source.Snowball.InMemory == nil {
job.Replicate.Source.Snowball.InMemory = ptr(true)
job.Replicate.Source.Snowball.InMemory = new(true)
}
if job.Replicate.Source.Snowball.Compress == nil {
job.Replicate.Source.Snowball.Compress = ptr(false)
job.Replicate.Source.Snowball.Compress = new(false)
}
if job.Replicate.Source.Snowball.SmallerThan == nil {
job.Replicate.Source.Snowball.SmallerThan = ptr("5MiB")
job.Replicate.Source.Snowball.SmallerThan = new("5MiB")
}
if job.Replicate.Source.Snowball.SkipErrs == nil {
job.Replicate.Source.Snowball.SkipErrs = ptr(true)
job.Replicate.Source.Snowball.SkipErrs = new(true)
}
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/batchjobmetric_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions cmd/data-usage-cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,11 +635,12 @@ func (d *dataUsageCache) forceCompact(limit int) {
// StringAll returns a detailed string representation of all entries in the cache.
func (d *dataUsageCache) StringAll() string {
// Remove bloom filter from print.
s := fmt.Sprintf("info:%+v\n", d.Info)
var s strings.Builder
s.WriteString(fmt.Sprintf("info:%+v\n", d.Info))
for k, v := range d.Cache {
s += fmt.Sprintf("\t%v: %+v\n", k, v)
s.WriteString(fmt.Sprintf("\t%v: %+v\n", k, v))
}
return strings.TrimSpace(s)
return strings.TrimSpace(s.String())
}

// String returns a human readable representation of the string.
Expand Down
2 changes: 1 addition & 1 deletion cmd/decommetric_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions cmd/dynamic-timeouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,10 @@ func (dt *dynamicTimeout) adjust(entries [dynamicTimeoutLogSize]time.Duration) {

if failPct > dynamicTimeoutIncreaseThresholdPct {
// We are hitting the timeout too often, so increase the timeout by 25%
timeout := min(
timeout := max(
// Set upper cap.
atomic.LoadInt64(&dt.timeout)*125/100, int64(maxDynamicTimeout))
// Safety, shouldn't happen
if timeout < dt.minimum {
timeout = dt.minimum
}
min(atomic.LoadInt64(&dt.timeout)*125/100, int64(maxDynamicTimeout)),
dt.minimum)
atomic.StoreInt64(&dt.timeout, timeout)
} else if failPct < dynamicTimeoutDecreaseThresholdPct {
// We are hitting the timeout relatively few times,
Expand Down
23 changes: 14 additions & 9 deletions cmd/erasure-common.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,21 @@ import (

func (er erasureObjects) getOnlineDisks() (newDisks []StorageAPI) {
disks := er.getDisks()

var wg sync.WaitGroup
var mu sync.Mutex
newDisks = make([]StorageAPI, 0, len(disks))

r := rand.New(rand.NewSource(time.Now().UnixNano()))

for _, i := range r.Perm(len(disks)) {
wg.Add(1)
go func() {
defer wg.Done()
if disks[i] == nil {
return
}
di, err := disks[i].DiskInfo(context.Background(), DiskInfoOptions{})
disk := disks[i] // avoids repeated indexing
if disk == nil {
// avoids spawning goroutines that immediately return
continue
}
wg.Go(func() {
di, err := disk.DiskInfo(context.Background(), DiskInfoOptions{})
if err != nil || di.Healing {
// - Do not consume disks which are not reachable
// unformatted or simply not accessible for some reason.
Expand All @@ -48,10 +52,11 @@ func (er erasureObjects) getOnlineDisks() (newDisks []StorageAPI) {
}

mu.Lock()
newDisks = append(newDisks, disks[i])
newDisks = append(newDisks, disk)
mu.Unlock()
}()
})
}

wg.Wait()
return newDisks
}
Expand Down
17 changes: 8 additions & 9 deletions cmd/erasure.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,24 +285,23 @@ func (er erasureObjects) getOnlineDisksWithHealingAndInfo(inclHealing bool) (new
infos := make([]DiskInfo, len(disks))
r := rand.New(rand.NewSource(time.Now().UnixNano()))
for _, i := range r.Perm(len(disks)) {
wg.Add(1)
go func() {
defer wg.Done()
disk := disks[i]
if disk == nil {
infos[i].Error = errDiskNotFound.Error()
continue
}

disk := disks[i]
if disk == nil {
infos[i].Error = errDiskNotFound.Error()
return
}
i, disk := i, disk

wg.Go(func() {
di, err := disk.DiskInfo(context.Background(), DiskInfoOptions{})
infos[i] = di
if err != nil {
// - Do not consume disks which are not reachable
// unformatted or simply not accessible for some reason.
infos[i].Error = err.Error()
}
}()
})
}
wg.Wait()

Expand Down
2 changes: 1 addition & 1 deletion cmd/healingmetric_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/iam-object-store.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ func (iamOS *IAMObjectStore) loadAllFromObjStore(ctx context.Context, cache *iam
if took := time.Since(listStartTime); took > maxIAMLoadOpTime {
var s strings.Builder
for k, v := range listedConfigItems {
fmt.Fprintf(&s, " %s: %d items\n", k, len(v))
s.WriteString(fmt.Sprintf(" %s: %d items\n", k, len(v)))
}
logger.Info("listAllIAMConfigItems took %.2fs with contents:\n%s", took.Seconds(), s.String())
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/lceventsrc_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions cmd/metacache-stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -769,8 +769,14 @@ type metacacheBlockWriter struct {
// Each block is the size of the capacity of the input channel.
// The caller should close to indicate the stream has ended.
func newMetacacheBlockWriter(in <-chan metaCacheEntry, nextBlock func(b *metacacheBlock) error) *metacacheBlockWriter {
blockEntries := cap(in)
if blockEntries <= 0 {
blockEntries = 1
}

w := metacacheBlockWriter{blockEntries: cap(in)}
w.wg.Add(1)
//TODO: this looks messy
go func() {
defer w.wg.Done()
var current metacacheBlock
Expand All @@ -784,6 +790,7 @@ func newMetacacheBlockWriter(in <-chan metaCacheEntry, nextBlock func(b *metacac

block := newMetacacheWriter(buf, 1<<20)
defer block.Close()

finishBlock := func() {
if err := block.Close(); err != nil {
w.streamErr = err
Expand Down
44 changes: 37 additions & 7 deletions cmd/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,19 +267,29 @@ func (sys *NotificationSys) LoadServiceAccount(ctx context.Context, accessKey st
func (sys *NotificationSys) BackgroundHealStatus(ctx context.Context) ([]madmin.BgHealState, []NotificationPeerErr) {
ng := WithNPeers(len(sys.peerClients))
states := make([]madmin.BgHealState, len(sys.peerClients))

for idx, client := range sys.peerClients {
idx := idx
client := client

var host xnet.Host
if client != nil && client.host != nil {
host = *client.host
}

ng.Go(ctx, func() error {
if client == nil {
if client == nil || client.host == nil {
return errPeerNotReachable
}

st, err := client.BackgroundHealStatus(ctx)
if err != nil {
return err
}

states[idx] = st
return nil
}, idx, *client.host)
}, idx, host)
}

return states, ng.Wait()
Expand Down Expand Up @@ -475,28 +485,48 @@ var errPeerNotReachable = errors.New("peer is not reachable")
func (sys *NotificationSys) GetLocks(ctx context.Context, r *http.Request) []*PeerLocks {
locksResp := make([]*PeerLocks, len(sys.peerClients))
g := errgroup.WithNErrs(len(sys.peerClients))

for index, client := range sys.peerClients {
index := index
client := client

peerAddr := ""
if client != nil && client.host != nil {
peerAddr = client.host.String()
}

g.Go(func() error {
if client == nil {
return errPeerNotReachable
}
serverLocksResp, err := sys.peerClients[index].GetLocks(ctx)

serverLocksResp, err := client.GetLocks(ctx)
if err != nil {
return err
}
locksResp[index] = &PeerLocks{
Addr: sys.peerClients[index].host.String(),
Addr: peerAddr,
Locks: serverLocksResp,
}
return nil
}, index)
}
for index, err := range g.Wait() {
reqInfo := (&logger.ReqInfo{}).AppendTags("peerAddress",
sys.peerClients[index].host.String())
if err == nil {
continue
}

client := sys.peerClients[index]

peerAddr := ""
if client != nil && client.host != nil {
peerAddr = client.host.String()
}

reqInfo := (&logger.ReqInfo{}).AppendTags("peerAddress", peerAddr)
ctx := logger.SetReqInfo(ctx, reqInfo)
peersLogOnceIf(ctx, err, sys.peerClients[index].host.String())

peersLogOnceIf(ctx, err, peerAddr)
}
locksResp = append(locksResp, &PeerLocks{
Addr: getHostName(r),
Expand Down
5 changes: 1 addition & 4 deletions cmd/os-dirent_namelen_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ func direntNamlen(dirent *syscall.Dirent) (uint64, error) {
const fixedHdr = uint16(unsafe.Offsetof(syscall.Dirent{}.Name))
nameBuf := (*[unsafe.Sizeof(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0]))
const nameBufLen = uint16(len(nameBuf))
limit := dirent.Reclen - fixedHdr
if limit > nameBufLen {
limit = nameBufLen
}
limit := min(dirent.Reclen-fixedHdr, nameBufLen)
// Avoid bugs in long file names
// https://github.com/golang/tools/commit/5f9a5413737ba4b4f692214aebee582b47c8be74
nameLen := bytes.IndexByte(nameBuf[:limit], 0)
Expand Down
4 changes: 2 additions & 2 deletions cmd/postpolicyform.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func parsePostPolicyForm(r io.Reader) (PostPolicyForm, error) {
for k, v := range condt {
if !isString(v) { // Pre-check value type.
// All values must be of type string.
return parsedPolicy, fmt.Errorf("Unknown type %s of conditional field value %s found in POST policy form", reflect.TypeOf(condt).String(), condt)
return parsedPolicy, fmt.Errorf("Unknown type %s of conditional field value %s found in POST policy form", reflect.TypeFor[map[string]any]().String(), condt)
}
// {"acl": "public-read" } is an alternate way to indicate - [ "eq", "$acl", "public-read" ]
// In this case we will just collapse this into "eq" for all use cases.
Expand Down Expand Up @@ -240,7 +240,7 @@ func parsePostPolicyForm(r io.Reader) (PostPolicyForm, error) {
default:
// Condition should be valid.
return parsedPolicy, fmt.Errorf("Unknown type %s of conditional field value %s found in POST policy form",
reflect.TypeOf(condt).String(), condt)
reflect.TypeFor[[]any]().String(), condt)
}
default:
return parsedPolicy, fmt.Errorf("Unknown field %s of type %s found in POST policy form",
Expand Down
2 changes: 1 addition & 1 deletion cmd/rebalancemetric_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/rebalstatus_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/scannermetric_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions cmd/server-startup-msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,12 @@ func printLambdaTargets() {
return
}

arnMsg := color.Blue("Object Lambda ARNs: ")
var arnMsg strings.Builder
arnMsg.WriteString(color.Blue("Object Lambda ARNs: "))
for _, arn := range globalLambdaTargetList.List(globalSite.Region()) {
arnMsg += color.Bold(fmt.Sprintf("%s ", arn))
arnMsg.WriteString(color.Bold(fmt.Sprintf("%s ", arn)))
}
logger.Startup(arnMsg + "\n")
logger.Startup(arnMsg.String() + "\n")
}

// Prints bucket notification configurations.
Expand Down
6 changes: 2 additions & 4 deletions cmd/sftp-server-driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,15 @@ func (f *sftpDriver) Filewrite(r *sftp.Request) (w io.WriterAt, err error) {
r: pr,
wg: &sync.WaitGroup{},
}
wa.wg.Add(1)
go func() {
wa.wg.Go(func() {
oi, err := clnt.PutObject(r.Context(), bucket, object, pr, -1, minio.PutObjectOptions{
ContentType: mimedb.TypeByExtension(path.Ext(object)),
DisableContentSha256: true,
Checksum: minio.ChecksumFullObjectCRC32C,
})
stopFn(oi.Size, err)
pr.CloseWithError(err)
wa.wg.Done()
}()
})
return wa, nil
}

Expand Down
8 changes: 1 addition & 7 deletions cmd/signature-v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,7 @@ func canonicalizedResourceV2(encodedResource, encodedQuery string) string {
queries := strings.Split(encodedQuery, "&")
keyval := make(map[string]string)
for _, query := range queries {
key := query
val := ""
index := strings.Index(query, "=")
if index != -1 {
key = query[:index]
val = query[index+1:]
}
key, val, _ := strings.Cut(query, "=")
keyval[key] = val
}

Expand Down
Loading