mirror of
https://github.com/pgsty/minio.git
synced 2026-08-09 15:53:28 +03:00
Locking: move locking code from xl-erasure to xl-objects. (#1673)
Fixes #1639 #1649 #1650 #1624
This commit is contained in:
committed by
Harshavardhana
parent
a0865122a7
commit
3c1ef3fee2
@@ -127,10 +127,6 @@ func (xl XL) MakeVol(volume string) error {
|
||||
return errInvalidArgument
|
||||
}
|
||||
|
||||
// Hold a write lock before creating a volume.
|
||||
nsMutex.Lock(volume, "")
|
||||
defer nsMutex.Unlock(volume, "")
|
||||
|
||||
// Err counters.
|
||||
createVolErr := 0 // Count generic create vol errs.
|
||||
volumeExistsErrCnt := 0 // Count all errVolumeExists errs.
|
||||
@@ -188,10 +184,6 @@ func (xl XL) DeleteVol(volume string) error {
|
||||
return errInvalidArgument
|
||||
}
|
||||
|
||||
// Hold a write lock for Delete volume.
|
||||
nsMutex.Lock(volume, "")
|
||||
defer nsMutex.Unlock(volume, "")
|
||||
|
||||
// Collect if all disks report volume not found.
|
||||
var volumeNotFoundErrCnt int
|
||||
|
||||
@@ -369,10 +361,6 @@ func (xl XL) listAllVolInfo(volume string) ([]VolInfo, bool, error) {
|
||||
|
||||
// healVolume - heals any missing volumes.
|
||||
func (xl XL) healVolume(volume string) error {
|
||||
// Acquire a read lock.
|
||||
nsMutex.RLock(volume, "")
|
||||
defer nsMutex.RUnlock(volume, "")
|
||||
|
||||
// Lists volume info for all online disks.
|
||||
volsInfo, heal, err := xl.listAllVolInfo(volume)
|
||||
if err != nil {
|
||||
@@ -420,10 +408,7 @@ func (xl XL) StatVol(volume string) (volInfo VolInfo, err error) {
|
||||
return VolInfo{}, errInvalidArgument
|
||||
}
|
||||
|
||||
// Acquire a read lock before reading.
|
||||
nsMutex.RLock(volume, "")
|
||||
volsInfo, heal, err := xl.listAllVolInfo(volume)
|
||||
nsMutex.RUnlock(volume, "")
|
||||
if err != nil {
|
||||
return VolInfo{}, err
|
||||
}
|
||||
@@ -500,10 +485,7 @@ func (xl XL) StatFile(volume, path string) (FileInfo, error) {
|
||||
return FileInfo{}, errInvalidArgument
|
||||
}
|
||||
|
||||
// Acquire read lock.
|
||||
nsMutex.RLock(volume, path)
|
||||
_, metadata, heal, err := xl.listOnlineDisks(volume, path)
|
||||
nsMutex.RUnlock(volume, path)
|
||||
if err != nil {
|
||||
return FileInfo{}, err
|
||||
}
|
||||
@@ -535,9 +517,6 @@ func (xl XL) DeleteFile(volume, path string) error {
|
||||
return errInvalidArgument
|
||||
}
|
||||
|
||||
nsMutex.Lock(volume, path)
|
||||
defer nsMutex.Unlock(volume, path)
|
||||
|
||||
errCount := 0
|
||||
// Update meta data file and remove part file
|
||||
for index, disk := range xl.storageDisks {
|
||||
@@ -590,14 +569,6 @@ func (xl XL) RenameFile(srcVolume, srcPath, dstVolume, dstPath string) error {
|
||||
return errInvalidArgument
|
||||
}
|
||||
|
||||
// Hold read lock at source before rename.
|
||||
nsMutex.RLock(srcVolume, srcPath)
|
||||
defer nsMutex.RUnlock(srcVolume, srcPath)
|
||||
|
||||
// Hold write lock at destination before rename.
|
||||
nsMutex.Lock(dstVolume, dstPath)
|
||||
defer nsMutex.Unlock(dstVolume, dstPath)
|
||||
|
||||
errCount := 0
|
||||
for _, disk := range xl.storageDisks {
|
||||
// Append "/" as srcPath and dstPath are either leaf-dirs or non-leaf-dris.
|
||||
|
||||
Reference in New Issue
Block a user