Deprecate ListLocks and ClearLocks (#6233)

No locks are ever left in memory, we also
have a periodic interval of clearing stale locks
anyways. The lock instrumentation was not complete
and was seldom used.

Deprecate this for now and bring it back later if
it is really needed. This also in-turn seems to improve
performance slightly.
This commit is contained in:
Harshavardhana
2018-08-02 10:39:42 -07:00
committed by Nitish Tiwari
parent eb391a53c1
commit 556a51120c
23 changed files with 6 additions and 2042 deletions

View File

@@ -19,7 +19,6 @@ package cmd
import (
"context"
"sort"
"time"
"github.com/minio/minio/cmd/logger"
"github.com/minio/minio/pkg/bpool"
@@ -56,63 +55,6 @@ func (xl xlObjects) Shutdown(ctx context.Context) error {
return nil
}
// Locking operations
// List namespace locks held in object layer
func (xl xlObjects) ListLocks(ctx context.Context, bucket, prefix string, duration time.Duration) ([]VolumeLockInfo, error) {
xl.nsMutex.lockMapMutex.Lock()
defer xl.nsMutex.lockMapMutex.Unlock()
// Fetch current time once instead of fetching system time for every lock.
timeNow := UTCNow()
volumeLocks := []VolumeLockInfo{}
for param, debugLock := range xl.nsMutex.debugLockMap {
if param.volume != bucket {
continue
}
// N B empty prefix matches all param.path.
if !hasPrefix(param.path, prefix) {
continue
}
volLockInfo := VolumeLockInfo{
Bucket: param.volume,
Object: param.path,
LocksOnObject: debugLock.counters.total,
TotalBlockedLocks: debugLock.counters.blocked,
LocksAcquiredOnObject: debugLock.counters.granted,
}
// Filter locks that are held on bucket, prefix.
for opsID, lockInfo := range debugLock.lockInfo {
// filter locks that were held for longer than duration.
elapsed := timeNow.Sub(lockInfo.since)
if elapsed < duration {
continue
}
// Add locks that are held for longer than duration.
volLockInfo.LockDetailsOnObject = append(volLockInfo.LockDetailsOnObject,
OpsLockState{
OperationID: opsID,
LockSource: lockInfo.lockSource,
LockType: lockInfo.lType,
Status: lockInfo.status,
Since: lockInfo.since,
})
volumeLocks = append(volumeLocks, volLockInfo)
}
}
return volumeLocks, nil
}
// Clear namespace locks held in object layer
func (xl xlObjects) ClearLocks(ctx context.Context, volLocks []VolumeLockInfo) error {
// Remove lock matching bucket/prefix held longer than duration.
for _, volLock := range volLocks {
xl.nsMutex.ForceUnlock(volLock.Bucket, volLock.Object)
}
return nil
}
// byDiskTotal is a collection satisfying sort.Interface.
type byDiskTotal []DiskInfo